diff options
author | Reiko Asakura | 2020-05-23 12:33:10 -0400 |
---|---|---|
committer | Reiko Asakura | 2020-05-23 12:33:10 -0400 |
commit | 00cdecc530060219e09650cabc066d78d6d92c11 (patch) | |
tree | cf81b602753837394f6b8586ffc27dcf37caaa0c | |
parent | Add prototype "sceAppMgrGetBudgetInfo" (diff) | |
download | vds-libraries-00cdecc530060219e09650cabc066d78d6d92c11.tar.gz |
kernel fast mutex: add and fix all related
1. Renamed sceKernelDeleteFastMutex to sceKernelFinalizeFastMutex. This
matches the name found in 0.940 prototype firmware and the NID has not
changed since then.
2. Unlike lightweight mutex, the work area is not required to be 8 byte
aligned, but I have done so anyway.
3. The work area's size is 0x40, but only 0x28 is used. However it is
not safe to use a smaller work area because sceKernelFinalizeFastMutex
memsets 0x40 bytes to 0.
4. The last field of the work area, 4 bytes long at offset 0x24,
contains the dummy value 0xA35DB473 when the fast mutex is initialised.
Functions in SceKernelThreadmgr related to fast mutex will check this
value and this allows us to find all functions related to fast mutex.
Diffstat (limited to '')
-rw-r--r-- | include/kernel/kernel/threadmgr.h | 63 | ||||
-rw-r--r-- | nids/360/SceKernelThreadMgr.yml | 5 |
2 files changed, 57 insertions, 11 deletions
diff --git a/include/kernel/kernel/threadmgr.h b/include/kernel/kernel/threadmgr.h index 14d0cfd..d1a260d 100644 --- a/include/kernel/kernel/threadmgr.h +++ b/include/kernel/kernel/threadmgr.h @@ -452,18 +452,61 @@ int sceKernelCancelMutex(SceUID mutexid, int newCount, int *numWaitThreads); */ int sceKernelGetMutexInfo(SceUID mutexid, SceKernelMutexInfo *info); -typedef struct SceKernelLwMutexWork { - SceInt64 data[4]; -} SceKernelLwMutexWork; - -typedef struct SceKernelLwMutexOptParam { +/* Fast mutex */ + +typedef struct SceKernelFastMutexWork { + SceInt64 data[8]; +} SceKernelFastMutexWork; + +typedef enum SceKernelFastMutexAttr { + SCE_KERNEL_FAST_MUTEX_ATTR_RECURSIVE = 0x00000002, + SCE_KERNEL_FAST_MUTEX_ATTR_CEILING = 0x00000004, + SCE_KERNEL_FAST_MUTEX_ATTR_UNK_3 = 0x00000008, + SCE_KERNEL_FAST_MUTEX_ATTR_TH_FIFO = 0x00000000, + SCE_KERNEL_FAST_MUTEX_ATTR_TH_PRIO = 0x00002000, + SCE_KERNEL_FAST_MUTEX_ATTR_UNK_15 = 0x00008000, + // All other flags are invalid +} SceKernelFastMutexAttr; + +typedef struct SceKernelFastMutexOptParam { SceSize size; -} SceKernelLwMutexOptParam; + SceInt32 ceilingPriority; +} SceKernelFastMutexOptParam; + +SceInt32 sceKernelInitializeFastMutex( + SceKernelFastMutexWork *pWork, + const char *pName, + SceKernelFastMutexAttr attr, + const SceKernelFastMutexOptParam *pOptParam); + +SceInt32 sceKernelLockFastMutex(SceKernelFastMutexWork *pWork); -int sceKernelInitializeFastMutex(void *mutex, const char *name, int unk0, int unk1); -int sceKernelLockFastMutex(void *mutex); -int sceKernelUnlockFastMutex(void *mutex); -int sceKernelDeleteFastMutex(void *mutex); +SceInt32 sceKernelTryLockFastMutex(SceKernelFastMutexWork *pWork); + +SceInt32 sceKernelUnlockFastMutex(SceKernelFastMutexWork *pWork); + +SceInt32 sceKernelFinalizeFastMutex(SceKernelFastMutexWork *pWork); + +typedef struct SceKernelFastMutexInfo { +// 0x00 + SceSize size; + SceUID uid; + char name[SCE_UID_NAMELEN + 1]; + SceKernelFastMutexAttr attr; + SceKernelFastMutexWork *pWork; +// 0x30 + SceInt32 currentCount; + SceUID currentOwnerId; + SceInt32 ceilingPriority; + SceInt32 unk3C; +// 0x40 + SceUInt32 numWaitThreads; +// 0x44 +} SceKernelFastMutexInfo; + +SceInt32 sceKernelGetFastMutexInfo(SceKernelFastMutexWork *pWork, SceKernelFastMutexInfo *pInfo); + +SceInt32 sceKernelGetFastMutexInfoById(SceUID uid, SceKernelFastMutexInfo *pInfo); /* Event flags. */ diff --git a/nids/360/SceKernelThreadMgr.yml b/nids/360/SceKernelThreadMgr.yml index f5d4381..e33c75a 100644 --- a/nids/360/SceKernelThreadMgr.yml +++ b/nids/360/SceKernelThreadMgr.yml @@ -209,7 +209,6 @@ modules: sceKernelDeleteCallback: 0x3A7E17F6 sceKernelDeleteCond: 0xAEE0D27C sceKernelDeleteEventFlag: 0x71ECB352 - sceKernelDeleteFastMutex: 0x11FE84A1 sceKernelDeleteMsgPipe: 0xB3453F88 sceKernelDeleteMutex: 0x0A912340 sceKernelDeleteSema: 0x16A35E58 @@ -217,7 +216,10 @@ modules: sceKernelEnqueueWorkQueue: 0xE50E1185 sceKernelExitDeleteThread: 0x1D17DECF sceKernelExitThread: 0x0C8A38E1 + sceKernelFinalizeFastMutex: 0x11FE84A1 sceKernelGetCallbackCount: 0x0892D8DF + sceKernelGetFastMutexInfo: 0xD7AF2E58 + sceKernelGetFastMutexInfoById: 0xAF302193 sceKernelGetMutexInfo: 0x69B78A12 sceKernelGetProcessId: 0x9DCB4B7A sceKernelGetProcessIdFromTLS: 0xFA54D49A @@ -261,6 +263,7 @@ modules: sceKernelStartThread: 0x21F5419B sceKernelStartTimer: 0x84C4CE4D sceKernelStopTimer: 0x474F214B + sceKernelTryLockFastMutex: 0x741F4707 sceKernelTryLockMutex: 0x270993A6 sceKernelTryLockReadRWLock: 0xFC2B5A50 sceKernelTryLockWriteRWLock: 0xA96F2E5A |