Skip to content

Commit

Permalink
Update SceSysmem memory types
Browse files Browse the repository at this point in the history
  • Loading branch information
Princess-of-Sleeping authored and d3m3vilurr committed Apr 19, 2022
1 parent f37e991 commit c2b869c
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 35 deletions.
23 changes: 4 additions & 19 deletions include/psp2/kernel/sysmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,12 @@
#define _PSP2_KERNEL_SYSMEM_H_

#include <psp2/types.h>
#include <psp2common/kernel/sysmem.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef enum SceKernelMemBlockType {
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE = 0x0C208060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_RX = 0x0C20D050,
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW = 0x0C20D060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_GAME_RW = 0x0C50D060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW = 0x0C80D060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALOG_NC_RW = 0x0CA08060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALOG_RW = 0x0CA0D060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_NC_RW = 0x0CF08060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_RW = 0x0CF0D060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW = 0x0D808060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_NC_RW = 0x0E208060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RW = 0x0E20D060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW = 0x09408060
} SceKernelMemBlockType;

typedef enum SceKernelAllocMemBlockAttr {
SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_ALIGNMENT = 0x00000004U
} SceKernelAllocMemBlockAttr;
Expand Down Expand Up @@ -61,7 +46,7 @@ typedef struct SceKernelMemBlockInfo {
SceSize mappedSize;
int memoryType;
SceUInt32 access;
SceKernelMemBlockType type;
SceUInt32 type;
} SceKernelMemBlockInfo;

typedef enum SceKernelMemoryAccessType {
Expand All @@ -79,13 +64,13 @@ typedef enum SceKernelMemoryType {
* Allocates a new memory block
*
* @param[in] name - Name for the memory block
* @param[in] type - Type of the memory to allocate
* @param[in] type - Type of the memory to allocate. Use `SCE_KERNEL_MEMBLOCK_TYPE_USER_*`.
* @param[in] size - Size of the memory to allocate
* @param[in] opt - Memory block options?
*
* @return SceUID of the memory block on success, < 0 on error.
*/
SceUID sceKernelAllocMemBlock(const char *name, SceKernelMemBlockType type, SceSize size, SceKernelAllocMemBlockOpt *opt);
SceUID sceKernelAllocMemBlock(const char *name, SceUInt32 type, SceSize size, SceKernelAllocMemBlockOpt *opt);

/**
* Frees new memory block
Expand Down
57 changes: 57 additions & 0 deletions include/psp2common/kernel/sysmem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* \kernelgroup{SceSysmem}
* \usage{psp2common/kernel/sysmem.h}
*/

#ifndef _PSP2_COMMON_TYPES_KERNEL_SYSMEM_H_
#define _PSP2_COMMON_TYPES_KERNEL_SYSMEM_H_

#include <psp2common/types.h>

#ifdef __cplusplus
extern "C" {
#endif


/*
* User/Kernel shared memtypes
*/

#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_L1WBWA_RW (0x09404060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_R (0x09408040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW (0x09408060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_UNK_0C200860_RW (0x0C200860)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_R (0x0C20D040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_RW (0x0C20D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_NC_RW (0x0C208060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_GAME_RW (0x0C50D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW (0x0C80D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW (0x0D808060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALIG_RW (0x0CA0D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALIG_NC_RW (0x0CA08060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_RW (0x0CF0D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_NC_RW (0x0CF08060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_R (0x0E20D040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RW (0x0E20D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_NC_R (0x0E208040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_NC_RW (0x0E208060)


/*
* For Backwards compatibility
*/

#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE (0x0C208060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RW (0x0C20D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALOG_NC_RW (0x0CA08060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALOG_RW (0x0CA0D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_NC_RW (0x0CF08060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_RW (0x0CF0D060)



#ifdef __cplusplus
}
#endif

#endif /* _PSP2_COMMON_TYPES_KERNEL_SYSMEM_H_ */
20 changes: 4 additions & 16 deletions include/psp2kern/kernel/sysmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,12 @@
#include <psp2kern/kernel/sysmem/mmu.h>
#include <psp2kern/kernel/debug.h>
#include <psp2kern/kernel/sysroot.h>
#include <psp2common/kernel/sysmem.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef enum SceKernelMemBlockType {
SCE_KERNEL_MEMBLOCK_TYPE_SHARED_RX = 0x0390D050,
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW = 0x09408060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE = 0x0C208060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_RX = 0x0C20D050,
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW = 0x0C20D060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW = 0x0C80D060,
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW = 0x0D808060,
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RX = 0x1020D005,
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RW = 0x1020D006,
SCE_KERNEL_MEMBLOCK_TYPE_RW_UNK0 = 0x6020D006
} SceKernelMemBlockType;

typedef enum SceKernelAllocMemBlockAttr {
SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_PADDR = 0x00000002U,
SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_ALIGNMENT = 0x00000004U,
Expand Down Expand Up @@ -88,13 +76,13 @@ typedef enum SceKernelModel {
* Allocates a new memory block
*
* @param[in] name - Name for the memory block
* @param[in] type - Type of the memory to allocate
* @param[in] type - Type of the memory to allocate. Use `SCE_KERNEL_MEMBLOCK_TYPE_USER_*` or `SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_*`.
* @param[in] size - Size of the memory to allocate
* @param[in] opt - Memory block options?
*
* @return SceUID of the memory block on success, < 0 on error.
*/
SceUID ksceKernelAllocMemBlock(const char *name, SceKernelMemBlockType type, SceSize size, SceKernelAllocMemBlockKernelOpt *opt);
SceUID ksceKernelAllocMemBlock(const char *name, SceUInt32 type, SceSize size, SceKernelAllocMemBlockKernelOpt *opt);

/**
* Frees new memory block
Expand Down Expand Up @@ -154,7 +142,7 @@ SceUID ksceKernelFindMemBlockByAddrForPid(SceUID pid, const void *addr, SceSize
*
* @return 0 on success, < 0 on error.
*/
int ksceKernelRemapBlock(SceUID uid, SceKernelMemBlockType type);
int ksceKernelRemapBlock(SceUID uid, SceUInt32 type);

int ksceKernelMapBlockUserVisible(SceUID uid);

Expand Down
120 changes: 120 additions & 0 deletions include/psp2kern/kernel/sysmem/memtype.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/**
* \kernelgroup{SceSysmem}
* \usage{psp2kern/kernel/sysmem/memtype.h}
*/

#ifndef _PSP2_KERNEL_SYSMEM_MEMTYPE_H_
#define _PSP2_KERNEL_SYSMEM_MEMTYPE_H_

#include <psp2kern/types.h>
#include <psp2common/kernel/sysmem.h>

#ifdef __cplusplus
extern "C" {
#endif


/*
* The user memtypes that only the Kernel can allocate
*/

#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_MAIN_R (0x0320D040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_MAIN_RX (0x0320D050)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_MAIN_RW (0x0320D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_SHARED_R (0x0390D040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_SHARED_RX (0x0390D050)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_SHARED_RW (0x0390D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_CDIALOG_R (0x03A0D040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_CDIALOG_RX (0x03A0D050)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_CDIALOG_RW (0x03A0D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_TOOL_R (0x03F0D040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_TOOL_RX (0x03F0D050)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_TOOL_RW (0x03F0D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_R (0x08F0D040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_RX (0x08F0D050)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_RW (0x08F0D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_UNK_RW (0x08F0D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_RX (0x0C20D050)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_R (0x0C80D040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_R (0x0D808040)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_RX (0x0CF0D050)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RX (0x0E20D050)

#define SCE_KERNEL_MEMBLOCK_TYPE_USER_UNK_0720D006_RW (0x0720D006) /* SCE_KERNEL_ERROR_ILLEGAL_PARTITION_INDEX */
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_UNK_0B100240_R (0x0B100240)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_UNK_0B100260_RW (0x0B100260)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_UNK_0B100840_R (0x0B100840)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_UNK_0B100860_RW (0x0B100860)



/*
* The kernel memtypes that only the Kernel can allocate
*/

#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_SO_RW (0x10200206)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_DEVICE_RW (0x10200806)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_L1WBWA_RW (0x10204006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_NC_R (0x10208004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_NC_RW (0x10208006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_R (0x1020D004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_RX (0x1020D005)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_RW (0x1020D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_PHYCONT_R (0x1080D004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_PHYCONT_RW (0x1080D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_PHYCONT_NC_R (0x30808004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_PHYCONT_NC_RW (0x30808006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_GAME_RW (0x1050D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_CDIALOG_R (0x10A0D004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_CDIALOG_RW (0x10A0D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_UMAIN_NC_RW (0x10C08006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_UMAIN_RW (0x10C0D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_R (0x10F0D004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_RX (0x10F0D005)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_RW (0x10F0D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_NC_R (0x10F08004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_NC_RW (0x10F08006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_FS_GAME_R (0x1220D004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_FS_GAME_RW (0x1220D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_FS_GAME_NC_R (0x13208004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_FS_GAME_NC_RW (0x13208006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_SO_R (0x20100204)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_SO_RW (0x20100206)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_R (0x20100804)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_RW (0x20100806)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_NC_R (0x20108004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_NC_RW (0x20108006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_CDRAM_L1WBWA_RW (0x40404006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_CDRAM_RW (0x40408006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_NC_R (0x60208004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_NC_RW (0x60208006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_R (0x6020D004)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_RW (0x6020D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_GAME_RW (0x6050D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_KMP_GAME_RW (0xC050D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_KMP_TOOL_RW (0xC0F0D006)

#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_UNK_11208006_NC_RW (0x11208006) // from ScePhyMemPartKD to SceKernelRootUncacheGpuGame
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_UNK_60208014_NC_R (0x60208014)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_UNK_60208016_NC_RW (0x60208016)


/*
* For Backwards compatibility
*/

#define SCE_KERNEL_MEMBLOCK_TYPE_SHARED_RX (0x0390D050)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW (0x09408060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RX (0x0C20D050)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW (0x0C80D060)
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW (0x0D808060)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RX (0x1020D005)
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RW (0x1020D006)
#define SCE_KERNEL_MEMBLOCK_TYPE_RW_UNK0 (0x6020D006)


#ifdef __cplusplus
}
#endif

#endif

0 comments on commit c2b869c

Please sign in to comment.