diff options
author | Sergi Granell | 2018-02-14 16:56:52 +0100 |
---|---|---|
committer | devnoname120 | 2018-02-14 16:56:52 +0100 |
commit | dac51908af21740863e84fed6feb163eda11e257 (patch) | |
tree | f8146cd8100135ca394ce7752624363dbc4ce70f /include | |
parent | Fix wrong type name (diff) | |
download | vds-libraries-dac51908af21740863e84fed6feb163eda11e257.tar.gz |
Add Cpu and Sysmem NIDs (#293)
* Add Cpu and Sysmem NIDs
Diffstat (limited to 'include')
-rw-r--r-- | include/kernel/kernel/cpu.h | 18 | ||||
-rw-r--r-- | include/kernel/kernel/sysmem.h | 111 |
2 files changed, 128 insertions, 1 deletions
diff --git a/include/kernel/kernel/cpu.h b/include/kernel/kernel/cpu.h index b3b2603..09d144d 100644 --- a/include/kernel/kernel/cpu.h +++ b/include/kernel/kernel/cpu.h @@ -227,6 +227,24 @@ int sceKernelCpuSuspendIntr(int *addr); */ int sceKernelCpuResumeIntr(int *addr, int prev_state); +/** + * @brief Disable interrupts (IRQs) and spin-lock + * + * @param[in] addr Mutex associated to the lock-unlock pair + * + * @return The current state of the interrupt controller, to be passed to ::sceKernelCpuSpinLockIrqRestore + */ +int sceKernelCpuSpinLockIrqSave(int *addr); + +/** + * @brief Spin-unlock and restore interrupt state + * + * @param[in] addr Mutex associated to the lock-unlock pair + * @param[in] flags Previous interrupt state to be restored (returned by ::sceKernelCpuSpinLockIrqSave) + * + * @return Zero on success + */ +int sceKernelCpuSpinLockIrqRestore(int *addr, int flags); #ifdef __cplusplus } diff --git a/include/kernel/kernel/sysmem.h b/include/kernel/kernel/sysmem.h index 31f20fa..72d6c06 100644 --- a/include/kernel/kernel/sysmem.h +++ b/include/kernel/kernel/sysmem.h @@ -30,6 +30,16 @@ typedef enum SceKernelAllocMemBlockAttr { SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_ALLOW_PARTIAL_OP = 0x04000000U } SceKernelAllocMemBlockAttr; +typedef enum SceKernelMemoryRefPerm { + SCE_KERNEL_MEMORY_REF_PERM_ANY = 0, + SCE_KERNEL_MEMORY_REF_PERM_USER_R = 0x01, + SCE_KERNEL_MEMORY_REF_PERM_USER_W = 0x02, + SCE_KERNEL_MEMORY_REF_PERM_USER_X = 0x04, + SCE_KERNEL_MEMORY_REF_PERM_KERN_R = 0x10, + SCE_KERNEL_MEMORY_REF_PERM_KERN_W = 0x20, + SCE_KERNEL_MEMORY_REF_PERM_KERN_X = 0x40, +} SceKernelMemoryRefPerm; + typedef struct SceKernelAddrPair { uint32_t addr; //!< Address uint32_t length; //!< Length @@ -95,7 +105,7 @@ typedef enum SceKernelModel { } SceKernelModel; typedef int (*SceClassCallback)(void *item); - + typedef struct SceClass { struct SceClass *next; struct SceClass *root; @@ -283,6 +293,105 @@ int sceKernelGetPaddr(void *addr, uintptr_t *paddr); */ int sceKernelGetPaddrList(const SceKernelAddrPair *input, SceKernelPaddrList *list); +/** + * Releases a memblock referenced by the UID. + * + * This decreases the internal reference count. + * + * @param[in] uid The uid of the memblock + * + * @return 0 on success, < 0 on error. + */ +int sceKernelMemBlockRelease(SceUID uid); + +/** + * Retains a memory range + * + * This increases the internal reference count of the memblocks belonging to the range. + * + * Note: It uses ::SCE_KERNEL_MEMORY_REF_PERM_ANY as the reference permission. + * + * @param[in] addr The start address + * @param[in] size The memory range size + * + * @return 0 on success, < 0 on error. + */ +int sceKernelMemRangeRetain(void *addr, unsigned int size); + +/** + * Retains a memory range for a process (pid) + * + * This increases the internal reference count of the memblocks belonging to the range. + * + * Note: It uses ::SCE_KERNEL_MEMORY_REF_PERM_ANY as the reference permission. + * + * @param[in] pid The pid of the process + * @param[in] addr The start address + * @param[in] size The memory range size + * + * @return 0 on success, < 0 on error. + */ +int sceKernelMemRangeRetainForPid(SceUID pid, void *addr, unsigned int size); + +/** + * Retains a memory range checking for a given permission + * + * This increases the internal reference count of the memblocks belonging to the range. + * If the memory blocks belonging to the range don't have the required memory access permission, + * it returns an error. + * + * @param[in] perm The required permission of the memory blocks belonging to the range + * @param[in] addr The start address + * @param[in] size The memory range size + * + * @return 0 on success, < 0 on error. + */ +int sceKernelMemRangeRetainWithPerm(SceKernelMemoryRefPerm perm, void *addr, unsigned int size); + +/** + * Releases a memory range + * + * This decreases the internal reference count of the memblocks belonging to the range. + * + * Note: It uses ::SCE_KERNEL_MEMORY_REF_PERM_ANY as the reference permission. + * + * @param[in] addr The start address + * @param[in] size The memory range size + * + * @return 0 on success, < 0 on error. + */ +int sceKernelMemRangeRelease(void *addr, unsigned int size); + +/** + * Releases a memory range for a process (pid) + * + * This decreases the internal reference count of the memblocks belonging to the range. + * + * Note: It uses ::SCE_KERNEL_MEMORY_REF_PERM_ANY as the reference permission. + * + * @param[in] pid The pid of the process + * @param[in] addr The start address + * @param[in] size The memory range size + * + * @return 0 on success, < 0 on error. + */ +int sceKernelMemRangeReleaseForPid(SceUID pid, void *addr, unsigned int size); + +/** + * Releases a memory range checking for a given permission + * + * This decreases the internal reference count of the memblocks belonging to the range. + * If the memory blocks belonging to the range don't have the required memory access permission, + * it returns an error. + * + * @param[in] perm The required permission of the memory blocks belonging to the range + * @param[in] addr The start address + * @param[in] size The memory range size + * + * @return 0 on success, < 0 on error. + */ +int sceKernelMemRangeReleaseWithPerm(SceKernelMemoryRefPerm perm, void *addr, unsigned int size); + int sceSysrootIsManufacturingMode(void); int sceDebugPrintf(const char *fmt, ...); |