APT : added ability to specify APPID to aptInit

This commit is contained in:
smea 2014-02-01 19:56:36 +01:00
parent 30e765f52c
commit 7c28d9acce
6 changed files with 30 additions and 18 deletions

View File

@ -104,7 +104,7 @@ int main()
{
initSrv();
aptInit();
aptInit(APPID_APPLICATION);
gspGpuInit();

View File

@ -8,15 +8,21 @@ typedef enum{
APPID_APPLICATION = 0x300, // Application
}NS_APPID; // cf http://3dbrew.org/wiki/NS#AppIDs
typedef enum{
APP_RUNNING,
APP_SUSPENDED,
APP_EXITING
}APP_STATUS;
extern Handle aptEvents[3];
void aptInit();
void aptInit(NS_APPID appID);
void aptExit();
void aptOpenSession();
void aptCloseSession();
void aptSetupEventHandler();
u32 aptGetStatus();
void aptSetStatus(u32 status);
void aptSetStatus(APP_STATUS status);
APP_STATUS aptGetStatus();
Result APT_GetLockHandle(Handle* handle, u16 flags, Handle* lockHandle);
Result APT_Initialize(Handle* handle, NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2);

View File

@ -6,4 +6,3 @@ Result SOC_Shutdown();
int SOC_GetErrno();
#endif

View File

@ -3,13 +3,13 @@
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);
Result svc_createThread(Handle* thread, ThreadFunc entrypoint, u32 arg, u32* stacktop, s32 threadpriority, s32 processorid);
void svc_exitThread();
void svc_sleepThread(s64 ns);
Result svc_createMutex(Handle* mutex, bool initialLocked);
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_clearEvent(Handle handle);
Result svc_createMemoryBlock(Handle* memblock, u32 addr, u32 size, u32 mypermission, u32 otherpermission);

View File

@ -9,6 +9,8 @@
#define APT_HANDLER_STACKSIZE (0x10000)
NS_APPID currentAppId;
Handle aptLockHandle;
Handle aptuHandle;
Handle aptEvents[3];
@ -37,7 +39,7 @@ void aptEventHandler(u32 arg)
u8 signalType;
aptOpenSession();
APT_InquireNotification(NULL, APPID_APPLICATION, &signalType); //check signal type
APT_InquireNotification(NULL, currentAppId, &signalType); //check signal type
aptCloseSession();
switch(signalType)
@ -46,6 +48,8 @@ void aptEventHandler(u32 arg)
aptOpenSession();
APT_PrepareToJumpToHomeMenu(NULL); //prepare for return to menu
aptCloseSession();
aptSetStatus(APP_SUSPENDED);
GSPGPU_ReleaseRight(NULL); //disable GSP module access
@ -56,11 +60,11 @@ void aptEventHandler(u32 arg)
}
}
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;
aptOpenSession();
APT_ReceiveParameter(NULL, APPID_APPLICATION, 0x1000, aptParameters, NULL, &signalType);
APT_ReceiveParameter(NULL, currentAppId, 0x1000, aptParameters, NULL, &signalType);
aptCloseSession();
switch(signalType)
@ -69,14 +73,15 @@ void aptEventHandler(u32 arg)
break;
case 0xB: //just returned from menu
GSPGPU_AcquireRight(NULL, 0x0);
aptSetStatus(APP_RUNNING);
break;
case 0xC: //exiting application
aptOpenSession();
APT_ReplySleepQuery(NULL, APPID_APPLICATION, 0x0);
APT_ReplySleepQuery(NULL, currentAppId, 0x0);
aptCloseSession();
runThread=false;
aptSetStatus(1); //app exit signal
aptSetStatus(APP_EXITING); //app exit signal
break;
}
}
@ -89,15 +94,17 @@ void aptEventHandler(u32 arg)
svc_exitThread();
}
void aptInit()
void aptInit(NS_APPID appID)
{
//initialize APT stuff, escape load screen
srv_getServiceHandle(NULL, &aptuHandle, "APT:U");
APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle);
svc_closeHandle(aptuHandle);
currentAppId=appID;
aptOpenSession();
APT_Initialize(NULL, APPID_APPLICATION, &aptEvents[0], &aptEvents[1]);
APT_Initialize(NULL, currentAppId, &aptEvents[0], &aptEvents[1]);
aptCloseSession();
aptOpenSession();
@ -105,7 +112,7 @@ void aptInit()
aptCloseSession();
aptOpenSession();
APT_NotifyToWait(NULL, APPID_APPLICATION);
APT_NotifyToWait(NULL, currentAppId);
aptCloseSession();
}
@ -154,16 +161,16 @@ void aptSetupEventHandler()
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);
ret=aptStatus;
svc_releaseMutex(aptStatusMutex);
return ret;
}
void aptSetStatus(u32 status)
void aptSetStatus(APP_STATUS status)
{
svc_waitSynchronization1(aptStatusMutex, U64_MAX);
aptStatus=status;

View File

@ -106,7 +106,7 @@ int main()
{
initSrv();
aptInit();
aptInit(APPID_APPLICATION);
gspGpuInit();