summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/kernel/kernel/cpu.h18
-rw-r--r--include/kernel/kernel/sysmem.h111
-rw-r--r--nids/360/SceSysmem.yml9
3 files changed, 137 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, ...);
diff --git a/nids/360/SceSysmem.yml b/nids/360/SceSysmem.yml
index 406d2ee..f79b80c 100644
--- a/nids/360/SceSysmem.yml
+++ b/nids/360/SceSysmem.yml
@@ -14,6 +14,8 @@ modules:
sceKernelCpuEnableInterrupts: 0xF5BAD43B
sceKernelCpuGetCpuId: 0x5E4D5DE1
sceKernelCpuResumeIntr: 0x7BB9D5DF
+ sceKernelCpuSpinLockIrqRestore: 0x740A0750
+ sceKernelCpuSpinLockIrqSave: 0xEC53D007
sceKernelCpuSuspendIntr: 0xD32ACE9E
SceCpuForKernel:
nid: 0x54BF2BAB
@@ -188,6 +190,13 @@ modules:
sceKernelKernelUidForUserUid: 0x45D22597
sceKernelMapBlockUserVisible: 0x58D21746
sceKernelMapUserBlock: 0x7D4F8B5F
+ sceKernelMemBlockRelease: 0x00575B00
+ sceKernelMemRangeRelease: 0x75C70DE0
+ sceKernelMemRangeReleaseForPid: 0xA8525B06
+ sceKernelMemRangeReleaseWithPerm: 0x22CBE925
+ sceKernelMemRangeRetain: 0x59A4402F
+ sceKernelMemRangeRetainForPid: 0x659586BF
+ sceKernelMemRangeRetainWithPerm: 0xBC0A1D60
sceKernelMemcpyKernelToUser: 0x6D88EF8A
sceKernelMemcpyKernelToUserForPid: 0x6B825479
sceKernelMemcpyKernelToUserForPidUnchecked: 0xFED82F2D