From: fincs Date: Tue, 29 Sep 2015 21:21:45 +0000 (+0200) Subject: Merge branch 'master' into great-refactor X-Git-Tag: v1.0.0~104 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=4603b972fa024efba0403d40850ab63c10543157;p=corbenik%2Fctrulib.git Merge branch 'master' into great-refactor Conflicts: libctru/include/3ds/services/apt.h libctru/source/services/apt.c --- 4603b972fa024efba0403d40850ab63c10543157 diff --cc libctru/include/3ds/services/apt.h index 04de77a,9035b08..74fda48 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@@ -91,39 -91,40 +91,40 @@@ bool aptMainLoop(void); // Use like thi void aptHook(aptHookCookie* cookie, aptHookFn callback, void* param); void aptUnhook(aptHookCookie* cookie); -Result APT_GetLockHandle(Handle* handle, u16 flags, Handle* lockHandle); -Result APT_Initialize(Handle* handle, NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2); -Result APT_Finalize(Handle* handle, NS_APPID appId); -Result APT_HardwareResetAsync(Handle* handle); -Result APT_Enable(Handle* handle, u32 a); -Result APT_GetAppletManInfo(Handle* handle, u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid); -Result APT_GetAppletInfo(Handle* handle, NS_APPID appID, u64* pProgramID, u8* pMediaType, u8* pRegistered, u8* pLoadState, u32* pAttributes); -Result APT_GetAppletProgramInfo(Handle* handle, u32 id, u32 flags, u16 *titleversion); -Result APT_PrepareToJumpToHomeMenu(Handle* handle); -Result APT_JumpToHomeMenu(Handle* handle, u32 a, u32 b, u32 c); -Result APT_PrepareToJumpToApplication(Handle* handle, u32 a); -Result APT_JumpToApplication(Handle* handle, u32 a, u32 b, u32 c); -Result APT_IsRegistered(Handle* handle, NS_APPID appID, u8* out); -Result APT_InquireNotification(Handle* handle, u32 appID, u8* signalType); -Result APT_NotifyToWait(Handle* handle, NS_APPID appID); -Result APT_AppletUtility(Handle* handle, u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2); -Result APT_GlanceParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType); -Result APT_ReceiveParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType); -Result APT_SendParameter(Handle* handle, NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType); -Result APT_SendCaptureBufferInfo(Handle* handle, u32 bufferSize, u32* buffer); -Result APT_ReplySleepQuery(Handle* handle, NS_APPID appID, u32 a); -Result APT_ReplySleepNotificationComplete(Handle* handle, NS_APPID appID); -Result APT_PrepareToCloseApplication(Handle* handle, u8 a); -Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c); -Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent); -Result APT_GetAppCpuTimeLimit(Handle* handle, u32 *percent); -Result APT_CheckNew3DS_Application(Handle* handle, u8 *out);// Note: this function is unreliable, see: http://3dbrew.org/wiki/APT:PrepareToStartApplication -Result APT_CheckNew3DS_System(Handle* handle, u8 *out); -Result APT_CheckNew3DS(Handle* handle, u8 *out); -Result APT_PrepareToDoAppJump(Handle* handle, u8 flags, u64 programID, u8 mediatype); -Result APT_DoAppJump(Handle* handle, u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr); -Result APT_PrepareToStartLibraryApplet(Handle* handle, NS_APPID appID); -Result APT_StartLibraryApplet(Handle* handle, NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize); +Result APT_GetLockHandle(u16 flags, Handle* lockHandle); +Result APT_Initialize(NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2); +Result APT_Finalize(NS_APPID appId); +Result APT_HardwareResetAsync(void); +Result APT_Enable(u32 a); +Result APT_GetAppletManInfo(u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid); ++Result APT_GetAppletInfo(NS_APPID appID, u64* pProgramID, u8* pMediaType, u8* pRegistered, u8* pLoadState, u32* pAttributes); +Result APT_GetAppletProgramInfo(u32 id, u32 flags, u16 *titleversion); +Result APT_PrepareToJumpToHomeMenu(void); +Result APT_JumpToHomeMenu(u32 a, u32 b, u32 c); +Result APT_PrepareToJumpToApplication(u32 a); +Result APT_JumpToApplication(u32 a, u32 b, u32 c); +Result APT_IsRegistered(NS_APPID appID, u8* out); +Result APT_InquireNotification(u32 appID, u8* signalType); +Result APT_NotifyToWait(NS_APPID appID); +Result APT_AppletUtility(u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2); +Result APT_GlanceParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType); +Result APT_ReceiveParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType); +Result APT_SendParameter(NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType); +Result APT_SendCaptureBufferInfo(u32 bufferSize, u32* buffer); +Result APT_ReplySleepQuery(NS_APPID appID, u32 a); +Result APT_ReplySleepNotificationComplete(NS_APPID appID); +Result APT_PrepareToCloseApplication(u8 a); +Result APT_CloseApplication(u32 a, u32 b, u32 c); +Result APT_SetAppCpuTimeLimit(u32 percent); +Result APT_GetAppCpuTimeLimit(u32 *percent); +Result APT_CheckNew3DS_Application(u8 *out);// Note: this function is unreliable, see: http://3dbrew.org/wiki/APT:PrepareToStartApplication +Result APT_CheckNew3DS_System(u8 *out); +Result APT_CheckNew3DS(u8 *out); +Result APT_PrepareToDoAppJump(u8 flags, u64 programID, u8 mediatype); +Result APT_DoAppJump(u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr); +Result APT_PrepareToStartLibraryApplet(NS_APPID appID); +Result APT_StartLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize); Result APT_LaunchLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize);//This should be used for launching library applets, this uses the above APT_StartLibraryApplet/APT_PrepareToStartLibraryApplet funcs + apt*Session(). parambuf is used for APT params input, when the applet closes the output param block is copied here. This is not usable from the homebrew launcher. This is broken: when the applet does get launched at all, the applet process doesn't actually get terminated when the applet gets closed. -Result APT_PrepareToStartSystemApplet(Handle* handle, NS_APPID appID); -Result APT_StartSystemApplet(Handle* handle, NS_APPID appID, u32 bufSize, Handle applHandle, u8 *buf); +Result APT_PrepareToStartSystemApplet(NS_APPID appID); +Result APT_StartSystemApplet(NS_APPID appID, u32 bufSize, Handle applHandle, u8 *buf); diff --cc libctru/include/3ds/svc.h index defb25b,521a346..747a7e2 --- a/libctru/include/3ds/svc.h +++ b/libctru/include/3ds/svc.h @@@ -436,6 -426,31 +437,31 @@@ Result svcClearEvent(Handle handle) Result svcWaitSynchronization(Handle handle, s64 nanoseconds); Result svcWaitSynchronizationN(s32* out, Handle* handles, s32 handles_num, bool wait_all, s64 nanoseconds); + /** + * @brief Creates an address arbiter + * @sa svcArbitrateAddress + */ + Result svcCreateAddressArbiter(Handle *arbiter); + + /** + * @brief Arbitrate an address, can be used for synchronization + * @param arbiter Handle of the arbiter + * @param addr A pointer to a s32 value. + * @param type Type of action to be performed by the arbiter + * @param value Number of threads to signal if using @ref ARBITRATION_SIGNAL, or the value used for comparison. - * ++ * + * This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr. - * ++ * + * @code + * s32 val=0; + * // Does *nothing* since val >= 0 + * svcCreateAddressArbiter(arbiter,&val,ARBITRATION_WAIT_IF_LESS_THAN,0,0); + * // Thread will wait for a signal or wake up after 10000000 nanoseconds because val < 1. + * svcCreateAddressArbiter(arbiter,&val,ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT,1,10000000ULL); + * @endcode + */ + Result svcArbitrateAddress(Handle arbiter, u32 addr, ArbitrationType type, s32 value, s64 nanoseconds); + Result svcSendSyncRequest(Handle session); Result svcAcceptSession(Handle* session, Handle port); Result svcReplyAndReceive(s32* index, Handle* handles, s32 handleCount, Handle replyTarget); diff --cc libctru/source/services/apt.c index e828211,1d01d4d..e5260f8 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@@ -792,8 -798,28 +792,26 @@@ Result APT_GetAppletManInfo(u8 inval, u return cmdbuf[1]; } -Result APT_GetAppletInfo(Handle* handle, NS_APPID appID, u64* pProgramID, u8* pMediaType, u8* pRegistered, u8* pLoadState, u32* pAttributes) ++Result APT_GetAppletInfo(NS_APPID appID, u64* pProgramID, u8* pMediaType, u8* pRegistered, u8* pLoadState, u32* pAttributes) + { - if(!handle)handle=&aptuHandle; + u32* cmdbuf=getThreadCommandBuffer(); + cmdbuf[0]=0x00060040; //request header code + cmdbuf[1]=appID; + + Result ret=0; - if((ret=svcSendSyncRequest(*handle)))return ret; ++ if((ret=svcSendSyncRequest(aptuHandle)))return ret; + + if(pProgramID)*pProgramID=(u64)cmdbuf[2]|((u64)cmdbuf[3]<<32); + if(pMediaType)*pMediaType=cmdbuf[4]; + if(pRegistered)*pRegistered=cmdbuf[5]; + if(pLoadState)*pLoadState=cmdbuf[6]; + if(pAttributes)*pAttributes=cmdbuf[7]; + + return cmdbuf[1]; + } + -Result APT_GetAppletProgramInfo(Handle* handle, u32 id, u32 flags, u16 *titleversion) +Result APT_GetAppletProgramInfo(u32 id, u32 flags, u16 *titleversion) { - if(!handle)handle=&aptuHandle; u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=0x004D0080; //request header code cmdbuf[1]=id;