APT : added ability to specify APPID to aptInit
This commit is contained in:
parent
30e765f52c
commit
7c28d9acce
@ -104,7 +104,7 @@ int main()
|
|||||||
{
|
{
|
||||||
initSrv();
|
initSrv();
|
||||||
|
|
||||||
aptInit();
|
aptInit(APPID_APPLICATION);
|
||||||
|
|
||||||
gspGpuInit();
|
gspGpuInit();
|
||||||
|
|
||||||
|
@ -8,15 +8,21 @@ typedef enum{
|
|||||||
APPID_APPLICATION = 0x300, // Application
|
APPID_APPLICATION = 0x300, // Application
|
||||||
}NS_APPID; // cf http://3dbrew.org/wiki/NS#AppIDs
|
}NS_APPID; // cf http://3dbrew.org/wiki/NS#AppIDs
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
APP_RUNNING,
|
||||||
|
APP_SUSPENDED,
|
||||||
|
APP_EXITING
|
||||||
|
}APP_STATUS;
|
||||||
|
|
||||||
extern Handle aptEvents[3];
|
extern Handle aptEvents[3];
|
||||||
|
|
||||||
void aptInit();
|
void aptInit(NS_APPID appID);
|
||||||
void aptExit();
|
void aptExit();
|
||||||
void aptOpenSession();
|
void aptOpenSession();
|
||||||
void aptCloseSession();
|
void aptCloseSession();
|
||||||
void aptSetupEventHandler();
|
void aptSetupEventHandler();
|
||||||
u32 aptGetStatus();
|
void aptSetStatus(APP_STATUS status);
|
||||||
void aptSetStatus(u32 status);
|
APP_STATUS aptGetStatus();
|
||||||
|
|
||||||
Result APT_GetLockHandle(Handle* handle, u16 flags, Handle* lockHandle);
|
Result APT_GetLockHandle(Handle* handle, u16 flags, Handle* lockHandle);
|
||||||
Result APT_Initialize(Handle* handle, NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2);
|
Result APT_Initialize(Handle* handle, NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2);
|
||||||
|
@ -6,4 +6,3 @@ Result SOC_Shutdown();
|
|||||||
int SOC_GetErrno();
|
int SOC_GetErrno();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
u32* getThreadCommandBuffer(void);
|
u32* getThreadCommandBuffer(void);
|
||||||
|
|
||||||
|
Result svc_controlMemory(u32* outaddr, u32 addr0, u32 addr1, u32 size, u32 operation, u32 permissions); //(outaddr is usually the same as the input addr0)
|
||||||
void svc_exitProcess(void);
|
void svc_exitProcess(void);
|
||||||
Result svc_createThread(Handle* thread, ThreadFunc entrypoint, u32 arg, u32* stacktop, s32 threadpriority, s32 processorid);
|
Result svc_createThread(Handle* thread, ThreadFunc entrypoint, u32 arg, u32* stacktop, s32 threadpriority, s32 processorid);
|
||||||
void svc_exitThread();
|
void svc_exitThread();
|
||||||
void svc_sleepThread(s64 ns);
|
void svc_sleepThread(s64 ns);
|
||||||
Result svc_createMutex(Handle* mutex, bool initialLocked);
|
Result svc_createMutex(Handle* mutex, bool initialLocked);
|
||||||
Result svc_releaseMutex(Handle handle);
|
Result svc_releaseMutex(Handle handle);
|
||||||
Result svc_controlMemory(u32* outaddr, u32 addr0, u32 addr1, u32 size, u32 operation, u32 permissions); //(outaddr is usually the same as the input addr0)
|
|
||||||
Result svc_createEvent(Handle* event, u8 resettype);
|
Result svc_createEvent(Handle* event, u8 resettype);
|
||||||
Result svc_clearEvent(Handle handle);
|
Result svc_clearEvent(Handle handle);
|
||||||
Result svc_createMemoryBlock(Handle* memblock, u32 addr, u32 size, u32 mypermission, u32 otherpermission);
|
Result svc_createMemoryBlock(Handle* memblock, u32 addr, u32 size, u32 mypermission, u32 otherpermission);
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#define APT_HANDLER_STACKSIZE (0x10000)
|
#define APT_HANDLER_STACKSIZE (0x10000)
|
||||||
|
|
||||||
|
NS_APPID currentAppId;
|
||||||
|
|
||||||
Handle aptLockHandle;
|
Handle aptLockHandle;
|
||||||
Handle aptuHandle;
|
Handle aptuHandle;
|
||||||
Handle aptEvents[3];
|
Handle aptEvents[3];
|
||||||
@ -37,7 +39,7 @@ void aptEventHandler(u32 arg)
|
|||||||
u8 signalType;
|
u8 signalType;
|
||||||
|
|
||||||
aptOpenSession();
|
aptOpenSession();
|
||||||
APT_InquireNotification(NULL, APPID_APPLICATION, &signalType); //check signal type
|
APT_InquireNotification(NULL, currentAppId, &signalType); //check signal type
|
||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
|
|
||||||
switch(signalType)
|
switch(signalType)
|
||||||
@ -46,6 +48,8 @@ void aptEventHandler(u32 arg)
|
|||||||
aptOpenSession();
|
aptOpenSession();
|
||||||
APT_PrepareToJumpToHomeMenu(NULL); //prepare for return to menu
|
APT_PrepareToJumpToHomeMenu(NULL); //prepare for return to menu
|
||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
|
|
||||||
|
aptSetStatus(APP_SUSPENDED);
|
||||||
|
|
||||||
GSPGPU_ReleaseRight(NULL); //disable GSP module access
|
GSPGPU_ReleaseRight(NULL); //disable GSP module access
|
||||||
|
|
||||||
@ -56,11 +60,11 @@ void aptEventHandler(u32 arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x1: //event 1 means app just started or we're returning to app
|
case 0x1: //event 1 means app just started, we're returning to app, exiting app etc.
|
||||||
{
|
{
|
||||||
u8 signalType;
|
u8 signalType;
|
||||||
aptOpenSession();
|
aptOpenSession();
|
||||||
APT_ReceiveParameter(NULL, APPID_APPLICATION, 0x1000, aptParameters, NULL, &signalType);
|
APT_ReceiveParameter(NULL, currentAppId, 0x1000, aptParameters, NULL, &signalType);
|
||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
|
|
||||||
switch(signalType)
|
switch(signalType)
|
||||||
@ -69,14 +73,15 @@ void aptEventHandler(u32 arg)
|
|||||||
break;
|
break;
|
||||||
case 0xB: //just returned from menu
|
case 0xB: //just returned from menu
|
||||||
GSPGPU_AcquireRight(NULL, 0x0);
|
GSPGPU_AcquireRight(NULL, 0x0);
|
||||||
|
aptSetStatus(APP_RUNNING);
|
||||||
break;
|
break;
|
||||||
case 0xC: //exiting application
|
case 0xC: //exiting application
|
||||||
aptOpenSession();
|
aptOpenSession();
|
||||||
APT_ReplySleepQuery(NULL, APPID_APPLICATION, 0x0);
|
APT_ReplySleepQuery(NULL, currentAppId, 0x0);
|
||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
|
|
||||||
runThread=false;
|
runThread=false;
|
||||||
aptSetStatus(1); //app exit signal
|
aptSetStatus(APP_EXITING); //app exit signal
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,15 +94,17 @@ void aptEventHandler(u32 arg)
|
|||||||
svc_exitThread();
|
svc_exitThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void aptInit()
|
void aptInit(NS_APPID appID)
|
||||||
{
|
{
|
||||||
//initialize APT stuff, escape load screen
|
//initialize APT stuff, escape load screen
|
||||||
srv_getServiceHandle(NULL, &aptuHandle, "APT:U");
|
srv_getServiceHandle(NULL, &aptuHandle, "APT:U");
|
||||||
APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle);
|
APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle);
|
||||||
svc_closeHandle(aptuHandle);
|
svc_closeHandle(aptuHandle);
|
||||||
|
|
||||||
|
currentAppId=appID;
|
||||||
|
|
||||||
aptOpenSession();
|
aptOpenSession();
|
||||||
APT_Initialize(NULL, APPID_APPLICATION, &aptEvents[0], &aptEvents[1]);
|
APT_Initialize(NULL, currentAppId, &aptEvents[0], &aptEvents[1]);
|
||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
|
|
||||||
aptOpenSession();
|
aptOpenSession();
|
||||||
@ -105,7 +112,7 @@ void aptInit()
|
|||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
|
|
||||||
aptOpenSession();
|
aptOpenSession();
|
||||||
APT_NotifyToWait(NULL, APPID_APPLICATION);
|
APT_NotifyToWait(NULL, currentAppId);
|
||||||
aptCloseSession();
|
aptCloseSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,16 +161,16 @@ void aptSetupEventHandler()
|
|||||||
svc_createThread(&aptEventHandlerThread, aptEventHandler, 0x0, (u32*)(&aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]), 0x31, 0xfffffffe);
|
svc_createThread(&aptEventHandlerThread, aptEventHandler, 0x0, (u32*)(&aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]), 0x31, 0xfffffffe);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 aptGetStatus()
|
APP_STATUS aptGetStatus()
|
||||||
{
|
{
|
||||||
u32 ret;
|
APP_STATUS ret;
|
||||||
svc_waitSynchronization1(aptStatusMutex, U64_MAX);
|
svc_waitSynchronization1(aptStatusMutex, U64_MAX);
|
||||||
ret=aptStatus;
|
ret=aptStatus;
|
||||||
svc_releaseMutex(aptStatusMutex);
|
svc_releaseMutex(aptStatusMutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void aptSetStatus(u32 status)
|
void aptSetStatus(APP_STATUS status)
|
||||||
{
|
{
|
||||||
svc_waitSynchronization1(aptStatusMutex, U64_MAX);
|
svc_waitSynchronization1(aptStatusMutex, U64_MAX);
|
||||||
aptStatus=status;
|
aptStatus=status;
|
||||||
|
@ -106,7 +106,7 @@ int main()
|
|||||||
{
|
{
|
||||||
initSrv();
|
initSrv();
|
||||||
|
|
||||||
aptInit();
|
aptInit(APPID_APPLICATION);
|
||||||
|
|
||||||
gspGpuInit();
|
gspGpuInit();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user