APT : added some stuff, plus proper lock handle use in arm11u example.

This commit is contained in:
smea 2014-01-20 20:57:54 +01:00
parent 567685f814
commit 80b647d65e
6 changed files with 40 additions and 12 deletions

View File

@ -11,6 +11,7 @@
Handle srvHandle; Handle srvHandle;
Handle APTevents[2]; Handle APTevents[2];
Handle aptLockHandle;
void aptInit() void aptInit()
{ {
@ -18,19 +19,20 @@ void aptInit()
//initialize APT stuff, escape load screen //initialize APT stuff, escape load screen
srv_getServiceHandle(srvHandle, &aptuHandle, "APT:U"); srv_getServiceHandle(srvHandle, &aptuHandle, "APT:U");
APT_GetLockHandle(aptuHandle, 0x0, NULL); APT_GetLockHandle(aptuHandle, 0x0, &aptLockHandle);
svc_closeHandle(aptuHandle); svc_closeHandle(aptuHandle);
svc_sleepThread(0x50000);
srv_getServiceHandle(srvHandle, &aptuHandle, "APT:U"); svc_waitSynchronization1(aptLockHandle, U64_MAX); //APT lock handle is used because we need to wait for NS to be ready for us
APT_Initialize(aptuHandle, 0x300, &APTevents[0], &APTevents[1]); srv_getServiceHandle(srvHandle, &aptuHandle, "APT:U");
svc_closeHandle(aptuHandle); APT_Initialize(aptuHandle, 0x300, &APTevents[0], &APTevents[1]);
svc_sleepThread(0x50000); svc_closeHandle(aptuHandle);
svc_releaseMutex(aptLockHandle); //release the lock
srv_getServiceHandle(srvHandle, &aptuHandle, "APT:U"); svc_waitSynchronization1(aptLockHandle, U64_MAX);
APT_Enable(aptuHandle, 0x0); srv_getServiceHandle(srvHandle, &aptuHandle, "APT:U");
svc_closeHandle(aptuHandle); APT_Enable(aptuHandle, 0x0);
svc_sleepThread(0x50000); svc_closeHandle(aptuHandle);
svc_releaseMutex(aptLockHandle);
} }
u8* gspHeap; u8* gspHeap;

View File

@ -7,5 +7,6 @@ Result APT_Enable(Handle handle, u32 a);
Result APT_PrepareToJumpToHomeMenu(Handle handle); Result APT_PrepareToJumpToHomeMenu(Handle handle);
Result APT_JumpToHomeMenu(Handle handle, u32 a, u32 b, u32 c); Result APT_JumpToHomeMenu(Handle handle, u32 a, u32 b, u32 c);
u8 APT_InquireNotification(Handle handle, u32 appID); u8 APT_InquireNotification(Handle handle, u32 appID);
Result APT_NotifyToWait(Handle handle, u32 a);
#endif #endif

View File

@ -4,8 +4,10 @@
u32* svc_getData(void); u32* svc_getData(void);
void svc_exitProcess(void); void svc_exitProcess(void);
void svc_sleepThread(s64 ns); void svc_sleepThread(s64 ns);
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_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_mapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission); Result svc_mapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission);
Result svc_waitSynchronization1(Handle handle, s64 nanoseconds); Result svc_waitSynchronization1(Handle handle, s64 nanoseconds);
Result svc_waitSynchronizationN(s32* out, Handle* handles, s32 handlecount, bool waitAll, s64 nanoseconds); Result svc_waitSynchronizationN(s32* out, Handle* handles, s32 handlecount, bool waitAll, s64 nanoseconds);

View File

@ -4,6 +4,8 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#define U64_MAX (0xFFFFFFFFFFFFFFFF)
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
typedef unsigned int u32; typedef unsigned int u32;

View File

@ -11,7 +11,7 @@ void APT_GetLockHandle(Handle handle, u16 flags, Handle* lockHandle)
svcData[0]=0x10040; //request header code svcData[0]=0x10040; //request header code
svcData[1]=flags; svcData[1]=flags;
svc_sendSyncRequest(handle); //check return value... svc_sendSyncRequest(handle); //check return value...
if(lockHandle)*lockHandle=svcData[1]; if(lockHandle)*lockHandle=svcData[5];
} }
void APT_Initialize(Handle handle, u32 a, Handle* eventHandle1, Handle* eventHandle2) void APT_Initialize(Handle handle, u32 a, Handle* eventHandle1, Handle* eventHandle2)
@ -62,3 +62,12 @@ Result APT_JumpToHomeMenu(Handle handle, u32 a, u32 b, u32 c)
svc_sendSyncRequest(handle); //check return value... svc_sendSyncRequest(handle); //check return value...
return svcData[1]; return svcData[1];
} }
Result APT_NotifyToWait(Handle handle, u32 a)
{
u32* svcData=svc_getData();
svcData[0]=0x430040; //request header code
svcData[1]=a;
svc_sendSyncRequest(handle); //check return value...
return svcData[1];
}

View File

@ -35,6 +35,12 @@ svc_sleepThread:
svc 0x0A svc 0x0A
bx lr bx lr
.global svc_releaseMutex
.type svc_releaseMutex, %function
svc_releaseMutex:
svc 0x14
bx lr
.global svc_createEvent .global svc_createEvent
.type svc_createEvent, %function .type svc_createEvent, %function
svc_createEvent: svc_createEvent:
@ -44,6 +50,12 @@ svc_createEvent:
str r1, [r2] str r1, [r2]
bx lr bx lr
.global svc_clearEvent
.type svc_clearEvent, %function
svc_clearEvent:
svc 0x19
bx lr
.global svc_mapMemoryBlock .global svc_mapMemoryBlock
.type svc_mapMemoryBlock, %function .type svc_mapMemoryBlock, %function
svc_mapMemoryBlock: svc_mapMemoryBlock: