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 /include | |
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 'include')
-rw-r--r-- | include/kernel/kernel/threadmgr.h | 63 |
1 files changed, 53 insertions, 10 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. */ |