SceSysmem Types

From Vita Development Wiki
Revision as of 17:46, 3 November 2023 by Bythos14 (talk | contribs) (→‎Types: Adjust the MemBlockInfoEx structs)
Jump to navigation Jump to search

Types

typedef struct SceKernelVARange SceKernelVARange;
typedef struct SceKernelBootArgs SceKernelBootArgs;
typedef struct SceSysrootProcessHandler SceSysrootProcessHandler;
typedef struct SceSysrootModulemgrHandlers SceSysrootModulemgrHandlers;
typedef struct SceSysrootForKernel_D29BCA77_struct SceSysrootForKernel_D29BCA77_struct;
typedef struct SceSysrootForKernel_733C243E_struct SceSysrootForKernel_733C243E_struct;

typedef struct SceKernelMMUContext { // size is 0xC on FWs 0.931-3.60
  SceUInt32 TTBR1;
  SceUInt32 DACR;
  SceUInt32 CONTEXTIDR;
} SceKernelMMUContext;

typedef SceUInt32 SceCachedSecureModule;
#define SCE_CACHED_SECURE_MODULE_GCAUTHMGR 0            // os0:sm/gcauthmgr_sm.self
#define SCE_CACHED_SECURE_MODULE_RMAUTH 1               // os0:sm/rmauth_sm.self
#define SCE_CACHED_SECURE_MODULE_ENDEC_W_PORTABILITY 2  // os0:sm/encdec_w_portability_sm.self

typedef struct SceCachedSecureModuleInfo { // size is 0xC
	SceSize size;     // Size of this structure
	void *pSelfData;  // Virtual address of the SM
	SceSize selfSize; // Size of the SM
} SceCachedSecureModuleInfo;

typedef struct SceSysrootDbgpHandler { // size is 0x5C on FW 3.600.011
    SceSize size; // Size of this structure
    void (* unk_0x04)(int a1, int a2, int a3, int a4);
    void (* unk_0x08)(int a1, int a2, int a3, int a4);
    void (* unk_0x0C)(int a1);
    void (* unk_0x10)(int a1, int a2, int a3, int a4);
    void (* unk_0x14)(int a1, int a2, int a3, int a4);
    void (* unk_0x18)(SceUID pid, SceUID modid, int flags, uint64_t time);
    void (* unk_0x1C)(int a1, int a2, int a3);
    void (* unk_0x20)(int a1, int a2, int a3);
    void (* unk_0x24)(int a1, int a2, int a3);
    void (* unk_0x28)(SceUID pid, SceUID modid, uint64_t time);
    void (* unk_0x2C)(SceUID pid, SceUID modid, uint64_t time);
    int  (* unk_0x30)(SceUID pid);
    int  (* unk_0x34)(int a1, int a2, int a3);
    int  (* unk_0x38)(int a1, int a2, void *a3);
    int  (* unk_0x3C)(int a1, int a2, int a3);
    int  (* sceKernelGetPrxDebugFlag)(SceUID pid, int *pFlag); // This is a guessed name.
    int  (* unk_0x44)(SceUID pid, SceUID modid, int flags, uint64_t time);
    int  (* unk_0x48)(int a1, int a2, int a3);
    void (* unk_0x4C)(void);
    void (* unk_0x50)(void);
    int  (* unk_0x54)(int a1, int a2, int a3, int a4, int a5);
    int  (* unk_0x58)(int a1, int a2, int a3);
} SceSysrootDbgpHandler;

#define SCE_SYSROOT_INIT_CALLBACK_MAX_FUNC (9)
#define SCE_SYSROOT_INIT_CALLBACK_MAX_SLOT (8)

typedef struct SceUIDSysrootObject { // size is 0x41C on FW 3.60-3.65
	void *object;
	SceClass *sce_class;
	SceSize size; // Size of this structure
	SceUInt32 magic1;
	int cpu_intr;
	SceSize boot_alloc_memory_size; // 0x400
	void *boot_alloc_memory; // used by boot time malloc
	int unk_0x1C; // 0x4
	void *unk_0x20; // size is 0x80-bytes
	SceUInt32 boot_flags; // 0x10 for coldboot, 0x1 for secure state
	SceUInt32 status;
	SceCorelockContext corelock_context;

	// start ModulePrivate
	int unk_0x34;   // ex:0
	int unk_0x38;   // ex:0
	void *unk_0x3C; // size is 4 byte
	void *unk_0x40; // Related to SceHeap. Size is 0xDC byte.
	SceExcpmgrData *ExcpmgrData; // Same as value returned by sceKernelGetExcpDataForKernel
	void *unk_0x48; // ?SceKernelIntrMgr data VA?
	void *unk_0x4C;
	void *unk_0x50;
	int unk_0x54;   // ex:0
	void *unk_0x58;
	int unk_0x5C;   // ex:0
	int unk_0x60;   // ex:0
	int unk_0x64;   // ex:0
	int unk_0x68;   // Used by Tzs SceSblSmsched
	// end ModulePrivate

	SceKblParam *kbl_param;
	SceKernelBootArgs *boot_args;
	SceUInt32 soc_revision;
	SceUInt32 pervasive_unk_dword; // read from physical address 0xE3100004 (ScePervasiveMisc + 0x4). ex: 0
	SceUInt32 kermit_revision;
	SceUInt32 model_info;
	SceUInt32 model_capability;

	void *longtime5base;

	int cpu_intr_for_init_callback;
	SceUInt32 init_callback_registable_base_number;
	struct {
		int (* callback)(int a1, void *args);
		void *args;
	} init_callback_slot[SCE_SYSROOT_INIT_CALLBACK_MAX_FUNC][SCE_SYSROOT_INIT_CALLBACK_MAX_SLOT];

	int (* sceKernelSysrootThreadMgrStartAfterProcess)(void);
	int (* sceKernelSysrootIofilemgrStart)(void);
	void *unk_0x2DC;
	void *unk_0x2E0;
	char *sysroot_names[9];
	SceUID this_object_uid;
	void *unk_0x30C; // size is 0x2C-bytes, maybe guid entry heap object
	void *unk_0x310;
	void *unk_0x314;
	void *VBAR;
	void *MVBAR;
	void *unk_0x320;
	void **unk_func_0x324; // SceSblACMgr
#if SCE_SDK_VERSION >= 0x3630000
	int (* sceKernelSysrootAppMgrFunction1)(int a1, int a2, int a3, int a4, int a5, int a6); // SceAppMgr + 0x2795, SceAppMgrForDriver_324DD34E
	SceUID (* sceKernelSysrootGetShellPid)(void);
	// offset: 0x330
#endif
	SceUID (* sceKernelSysrootGetThreadId)(void);
	int (* sceKernelSysrootThreadFunction3)(void);                   // Temp name, SceKernelThreadMgr + 0xC79, SceThreadmgrForDriver_91382762
	SceUID (* sceKernelSysrootGetProcessId)(void);
	int (* sceKernelSysrootThreadFunction4)(void);                   // Temp name, SceKernelThreadMgr + 0x8D1
	int (* sceKernelSysrootThreadFunction5)(void);                   // Temp name, SceKernelThreadMgr + 0x8ED
#if SCE_SDK_VERSION >= 0x3630000
	// offset: 0x344
	SceSysrootModulemgrHandlers *modulemgr_handlers;
#endif
	int (* sceKernelSysrootThreadFunction6)(void);                   // Temp name, SceKernelThreadMgr + 0x90D
	void (* sceKernelSysrootThreadFunction7)(void);                  // Temp name, SceKernelThreadMgr + 0xE69
	int (* sceKernelSysrootThreadFunction8)(void);                   // Temp name, SceKernelThreadMgr + 0x8BD, SceThreadmgrForDriver_332E127C
	int (* sceKernelSysrootThreadFunction9)(int a1, int a2, int a3); // Temp name, SceKernelThreadMgr + 0x2541
	int (* sceKernelSysrootThreadFunction10)(int a1);                // Temp name, SceKernelThreadMgr + 0xC99, SceThreadmgrForDriver_AB977C72
#if SCE_SDK_VERSION < 0x3630000
	// offset: 0x350
	SceSysrootModulemgrHandlers *modulemgr_handlers;
#endif
	int unk_0x354; // ex:0xFFFFFFFF
	SceSysrootForKernel_D29BCA77_struct *processmgr_callbacks_1;
	SceSysrootForDriver_733C243E_struct *processmgr_callbacks_2;
#if SCE_SDK_VERSION < 0x3630000
	void *unk_func_0x360; // SceDeci4pSDfMgr
	int (* sceKernelSysrootGetBusError)(void *dst, SceSize len);
	int (* sceKernelSysrootAppMgrFunction1)(int a1, int a2, int a3, int a4, int a5, int a6); // SceAppMgr + 0x2795, SceAppMgrForDriver_324DD34E
	SceUID (* sceKernelSysrootGetShellPid)(void);
#endif
#if SCE_SDK_VERSION >= 0x3630000
	// offset: 0x368
	int (* sceKernelSysrootGetLicenseStatusForDriver)(void); // SceSblPostSsMgr + 0x9001, sceSblLicMgrGetLicenseStatusForDriver
	int (* unk_func_0x384)(void); // SceSblPostSsMgr + 0xB005, SceSblPostSsMgrForDriver_22599675, get flag
	int (* unk_func_0x388)(void); // SceSblPostSsMgr + 0xB011, SceSblPostSsMgrForDriver_9B49C249, get flag
	void *unk_func_0x360; // SceDeci4pSDfMgr
	int (* sceKernelSysrootGetBusError)(void *dst, SceSize len);
	// offset: 0x37C
#endif
	void *unk_func_0x370; // SceCoredump + 0x7109, SceCoredumpForDriver_A7D214A7
	void *unk_func_0x374; // SceCoredump + 0x74F9, SceCoredumpForDriver_340856F7
	void *unk_func_0x378; // SceCoredump + 0x132ED, SceCoredumpForDriver_EF20949F
	int unk_0x37C; // ex:0
#if SCE_SDK_VERSION < 0x3630000
	// offset: 0x380
	int (* sceKernelSysrootGetLicenseStatusForDriver)(void); // SceSblPostSsMgr + 0x9001, sceSblLicMgrGetLicenseStatusForDriver
	int (* unk_func_0x384)(void); // SceSblPostSsMgr + 0xB005, SceSblPostSsMgrForDriver_22599675, get flag
	int (* unk_func_0x388)(void); // SceSblPostSsMgr + 0xB011, SceSblPostSsMgrForDriver_9B49C249, get flag
#endif
	void *unk_func_0x38C;         // SceSblPostSsMgr + 0xB4ED, SceSblPostSsMgrForDriver_D8A2D465
	int (* sceKernelSysrootGetTrilithiumBufferForDriver)(void); // SceSblPostSsMgr + 0xB111, sceSblUtMgrGetTrilithiumBufferForDriver
	int (* sceKernelSysrootHasNpTestFlag)(void);
	void *unk_func_0x398; // SceSblUpdateMgr + 0x8B01
	int (* sceKernelSysrootLedSetMode)(int led, int mode, void *led_configuration);
	SceKernelVARange *cached_sm_info_ranges; // See SceCachedSecureModuleInfo
	int (* sceKernelSysrootGetFunctionNameByNIDForKernel)(SceNID funcnid, const char **name); // sceNidsymtblGetFunctionNameByNIDForDriver
	void *SceSysrootForKernel_47724459_func; // SceDeci4pSDfMgr or SceDeci4pDfMgr, set by SceSysrootForDriver_C5EAF5F7
	void *unk_0x3AC; // SceDeci4pSDfMgr
	void *unk_struct_0x3B0; // SceDeci4pDfMgr
	void *unk_0x3B4; // SceDeci4pTsmp
	void *unk_0x3B8; // SceDeci4pTsmp
	void *unk_0x3BC; // SceDeci4pTsmp
	void *unk_0x3C0; // SceDeci4pTsmp
	SceSysrootProcessHandler *process_handler; // maybe for SceDeci4p
	SceSysrootDbgpHandler    *dbgp_handler;    // maybe for SceDeci4p
	void *unk_func_0x3CC; // SceNetPs + 0x3E51, SceNetPsForDriver_83A12CCC
	void *unk_func_0x3D0; // SceNetPs + 0x3F4D, SceNetPsForDriver_C000CA8F
	void *unk_func_0x3D4; // SceDeci4pTmcp
	void *unk_func_0x3D8; // SceDeci4pSDbgp
	void *unk_func_0x3DC; // SceNetPs + 0x3E51, SceNetPsForDriver_83A12CCC
	void *unk_func_0x3E0; // SceNetPs + 0x3F4D, SceNetPsForDriver_C000CA8F
	int (* sceKernelSysrootAppMgrFunction3)(int a1, int a2); // SceAppMgr + 0x9F49
	int (* sceKernelSysrootAppMgrFunction4)(int a1, int a2); // SceAppMgr + 0x9EED
	int (* sceKernelSysrootAppMgrFunction5)(int a1);	 // SceAppMgr + 0x9D31
	void *unk_func_0x3F0; // ScePfsMgr + 0x1, ScePfsMgrForKernel_4C148288
	void *unk_struct_0x3F4; // SceBt
	void *unk_struct_0x3F8; // SceHid
	void *unk_struct_0x3FC; // SceDeci4pSDbgp
	void *unk_data_0x400; // SceDeci4pSDbgp
	void *unk_func_0x404; // SceDeci4pSDfCtl
	void *unk_func_0x408; // SceDeci4pSDfCtl
	void *unk_func_0x40C; // ScePamgr
	void *unk_func_0x410; // ScePamgr
	void *unk_func_0x414; // ScePamgr
	SceUInt32 magic2;
} SceUIDSysrootObject;

typedef SceUIDSysrootObject SceSysroot;

typedef struct SceSysrootForKernel_D29BCA77_struct_0940 { // size is 0x48 on FWs 0.940-0.945
	SceSize size; // Size of this structure
	void *get_dword_from_offset_0x184;
	void *get_dword_from_offset_0x188;
	void *get_dword_from_offset_0x18C;
	void *sceKernelAllocCurrentProcessHeap;
	void *sceKernelFreeCurrentProcessHeap;
	void *sceKernelAllocRemoteProcessHeap;
	void *sceKernelFreeRemoteProcessHeap;
	void *sceKernelGetProcessLibdb;
	void *sceKernelSetProcessLibdb;
	void *ProcessmgrModuleStart2;
	void *sceKernelRegisterKPLS;
	void *sceKernelGetRemoteKPLS;
	void *sceKernelGetCurrentKPLS;
	void *sceKernelInhibitProcEvent;
        void *sceKernelPermitProcEvent;
	void *sceKernelInsertProcessThreadList;
	void *sceKernelDeleteProcessThreadList;
} SceSysrootForKernel_D29BCA77_struct_0940;

typedef struct SceSysrootForKernel_D29BCA77_struct_0990 { // size is 0x44 on FWs 0.990-0.995
	SceSize size; // Size of this structure
	void *get_dword_from_offset_0x184;
	void *get_dword_from_offset_0x188;
	void *get_dword_from_offset_0x18C;
	void *sceKernelAllocCurrentProcessHeap;
	void *sceKernelFreeCurrentProcessHeap;
	void *sceKernelAllocRemoteProcessHeap;
	void *sceKernelFreeRemoteProcessHeap;
	void *sceKernelGetProcessLibdb;
	void *sceKernelSetProcessLibdb;
	void *ProcessmgrModuleStart2;
	void *sceKernelRegisterKPLS;
	void *sceKernelGetRemoteKPLS;
	void *sceKernelGetCurrentKPLS;
	void *sceKernelInhibitProcEvent;
	void *sceKernelPermitProcEvent;
	void *sceKernelGetProcessHeapID;
} SceSysrootForKernel_D29BCA77_struct_0990;

// Size of SceSysrootForKernel_D29BCA77_struct for FWs 0.996.070-0.996.090 is 0x58
// Size of SceSysrootForKernel_D29BCA77_struct for FWs 1.000.071-1.500.151 (maybe higher) is 0x5C
typedef struct SceSysrootForKernel_D29BCA77_struct_3600 { // size is 0x44 on FWs 3.60-3.65, 
	SceSize size; // Size of this structure
        //a1 might be process object (needs to be checked)
	SceInt32 (*get_dword_from_offset_0x1E4)(void* a1);
	SceInt32 (*get_dword_from_offset_0x1E8)(void* a1);
	SceInt32 (*get_dword_from_offset_0x1EC)(void* a1);
        //Allocations are made from current process' "Unique" heap
        //Fails if TPIDRPRW is NULL
	void *(*sceKernelAllocCurrentProcessHeap)(SceSize size, SceKernelHeapMemoryOpt* pOpt);
	SceInt32 (*sceKernelFreeCurrentProcessHeap)(void* addr);

	//Allocations are made from specified process' "Unique" heap
        //KERNEL_PID (0x10005), DummyProcessGame (0x10013) and DummyProcessSystem (0x10015) are accepted as PIDs
        void *(*sceKernelAllocRemoteProcessHeap)(ScePID pid, SceSize size, SceKernelHeapMemoryOpt* pOpt);
	SceInt32 (*sceKernelFreeRemoteProcessHeap)(ScePID pid, void* ptr);

	SceInt32 (*ProcessmgrModuleStart2)();

        //Equivalent to sceKernelWaitSema(processObject->EventLock_sema, 1, NULL);
	SceInt32 (*sceKernelInhibitProcEvent)(ScePID pid);
	//Equivalent to sceKernelSignalSema(processObject->EventLock_sema, 1);
        SceInt32 *(sceKernelPermitProcEvent)(ScePID pid);

        //info_type = 0 -> returns processObject->unk0x424
        //info_type = 1 -> returns processObject->MaxFHCount
        //other values -> return 0
        SceInt32 (*query_some_process_info)(ScePID pid, SceUInt32 info_type);

	SceInt32 (*sceKernelRegisterKPLS)(char* name, SceSize size);
        //Fails if TPIDRPRW is NULL
        void *(*sceKernelGetCurrentKPLS)(SceUInt32 key);
	SceInt32 (*sceKernelGetRemoteKPLS)(ScePID pid, SceUInt32 key, ScePVoid* pKPLS, SceBool create);

	SceInt32 (*sceKernelProcessDebugSuspend)(ScePID pid, int status);
        //Retreived from process object's SceLoadProcessParam
        SceInt32 (*sceKernelGetCompiledSdkVersionByPid)(ScePID pid, SceUInt32* pSdkVersion);
} SceSysrootForKernel_D29BCA77_struct;

typedef struct SceSysrootForKernel_733C243E_struct_old { // size is 0x28 on FW 0.990
	SceSize size; // Size of this structure
	SceUID (* sceKernelGetCurrentProcessId)(void);
	int (* sceKernelGetEntryHeap)(SceUID pid, int *pHeap);
	int (* SceProcessmgrForKernel_C77C2085)(SceUID pid);
	int (* sceKernelPIDtoAddressSpaceCB)(SceUID pid, void **pASCb);
	int (* FUN_81000000)(int* dst, int *src);
	int (* sceKernelGetProcessType)(SceUID pid);
	int (* sceKernelGetProcessSelfAuthInfo)(SceUID pid, SceSelfAuthInfo *self_auth_info);
	int (* sceKernelSetProcessSelfAuthInfo)(SceUID pid, SceSelfAuthInfo *self_auth_info);
	int (* sceKernelGetProcessAccessLevel)(SceUID pid);
} SceSysrootForKernel_733C243E_struct_old;

typedef struct SceSysrootForKernel_733C243E_struct { // size is 0x20 on FWs 3.60-3.65
	SceSize size; // Size of this structure
	SceInt32 (* funcGetProcessEntryHeapObject)(SceUID pid, void **entry_heap_obj);
	SceUID (* get_process_address_space_UID)(SceUID pid);
	SceInt32 (* funcGetProcessAddressSpaceCB)(SceUID pid, void **address_space_obj);
	SceInt32 (* sceKernelGetProcessSelfAuthInfo)(SceUID pid, SceSelfAuthInfo *self_auth_info);
	SceInt32 (* sceKernelGetProcessTitleId)(SceUID pid, char *title_id, SceSize len); // Copies processObject->list_entry->process_name to title_id - maybe this should be GetProcessName?
	SceInt32 (* sceKernelIncProcessResource)(SceUInt32 type); // Type must be < 0x3
	SceInt32 (* sceKernelDecProcessResource)(SceUInt32 type); //^
} SceSysrootForKernel_733C243E_struct;

typedef struct SceSysrootProcessHandler { // size is 0x28 on FW 3.60
	SceSize size;                                                       // Size of this structure
	void (* unk_4)(SceUID pid, SceUID modid, int flags, SceUInt64 time); //!< process start shared modules
	void (* exit)(SceUID pid, int flags, SceUInt64 time);
	void (* kill)(SceUID pid);                                          //!< by SceShell
	void (* unk_10)(SceUID pid, SceUID modid, SceUInt64 time);
	void (* unk_14)(SceUID pid, SceUID modid, SceUInt64 time);
	void (* unk_18)(SceUID pid, SceUID modid, int a3, void* maybe_process_info, SceUInt64 time);
	int (* on_process_created)(int maybe_pid, int maybe_modid, int a3);                 //!< called when process is created
	void (* unk_20)(SceUID pid, SceUID modid, SceUInt64 time);
	void (* unk_24)(SceUID pid, SceUID modid, int flags, SceUInt64 time);
} SceSysrootProcessHandler;

typedef struct SceSysrootModulemgrHandlers { // size is 0x18 on FW 3.60
	SceSize size; // Size of this structure
	int (* sceKernelGetProcessSyscallInfo)(SceUID pid, const void *module_addr, void *pInfo); // SceKernelModulemgr + 0x20D0 on FW 3.60
	int (* handler_2)(SceUID pid, const void *module_addr); // SceKernelModulemgr + 0x1F44 on FW 3.60
	void *sceKernelGetModuleInfoMinByAddr;
	void *sceKernelBacktraceInternal;
	void *sceKernelPrintBacktrace;
} SceSysrootModulemgrHandlers;

// ScePamgrCallbacks
typedef struct SceSysrootForDriver_C94C76FA_struct { // size is 0x10 on FW 3.60
	SceSize size; // Size of this structure
	int (__cdecl *unk_func_4)();
	int (__cdecl *unk_func_8)();
	int (__cdecl *unk_func_C)();
} SceSysrootForDriver_C94C76FA_struct;

typedef struct SceKernelFreeMemorySizeInfo {
	SceSize size;
	SceSize sizeMain;
	SceSize sizeCdram;
	SceSize sizePhycont;
} SceKernelFreeMemorySizeInfo;

//Constructor/destructor of a class item
//For classes inheriting another class, the constructors are called from the parent to the child
//while the destructors are called in reverse order (same as C++ cstr/dstr)
typedef int (*SceClassCallback)(void *item);

//What is this?
typedef struct SceClass_0990 { // size is 0x10 on FW 0.990
	SceSize size; // Size of this structure
	struct SceClass *next;
	struct SceClass *root; // to confirm
	struct SceClass *prev; // to confirm
} SceClass_0990;

// How is this structure wrong? So where is the valid SceClass for FW 3.60? See below
typedef struct SceClass_wrong { // size is 0x2C on FW 3.60
	struct SceClass *next;				// 0x00
	struct SceClass *root;				// 0x04
	struct SceClass *prev;				// 0x08
	const char *name;				// 0x0C
	struct SceClass *uid_class;			// 0x10
	unsigned int attr;				// 0x14
	unsigned short item_size;			// 0x18
	unsigned short unk_1A;				// 0x1A
	SceClassCallback constructor;			// 0x1C
	SceClassCallback destructor;			// 0x20
	const unsigned int magic;			// 0x24 - 0xABCE9DA5
	SceClassCallback allocMethod;			// 0x28
} SceClass_wrong;

typedef struct SceClass { //size is 0x28 on FW 0.990, 0x2C on FW 3.60
    struct SceClass *next;             //0x00 - pUserdata of SceKernelObject, pointer to next class in DLink list
    struct SceClass *pClass;           //0x04 - pClass of SceKernelObject, always points to SceUIDClass class
    struct SceClass *prev;             //0x08 - Pointer to previous class in DLink list
    const char* name;                  //0x0C - Pointer to class' name
    struct SceClass *parent;           //0x10 - Pointer to parent class
    SceUInt32 attr;                    //0x14 - Usage unknown (bottom 8 bits = some counter?)
    SceUInt16 itemSize;                //0x18 - Size of items of this class
    SceUInt16 itemAllocationSize;      //0x1A - Size of allocations used for items of this class (rounded up itemSize)
#if (/* firmware 3.60 */)
    SceUInt32 unk0x1C;                 //0x1C
#endif
    SceClassCallback constructor;      //0x1C / 0x20 - called after item is allocated
    SceClassCallback destructor;       //0x20 / 0x24 - called before item is freed
    SceUInt32 magic;                   //0x24 / 0x28 - magic value 0xABCD9DA5
    //NOTE: additional data can be stored here for use by the class
} SceClass;

// Aka SceObjectBase in vitasdk
typedef struct SceKernelObject {
	void *pObject;
	SceClass *pClass;
	uintptr_t data[];
} SceKernelObject;

// Here is a wrong structure for SceKernelObject, but this could be a SceUIDXxxClass structure
typedef struct SceKernelObject_wrong { // size is at least 0x24
	void *pObject;			// 0x0
	SceClass pClass;		// 0x4
	uint32_t type;			// 0x8
	uint16_t lcount;		// 0xC
	uint16_t ucount;		// 0xE
	uint16_t ccount;		// 0x10
	uint32_t unk_12;		// 0x12 - 0x54c3
	uint16_t unk_16;		// 0x16
	uint32_t uid;			// 0x18
	char unk_1C[4];			// 0x1C
	const char *name;		// 0x20
	uint32_t indexRaw;		// 0x24
} SceKernelObject_wrong;

/** @name Memory types that can be specified with sceKernelAllocMemBlock
 */
/*@{*/

/**
 * @brief User readable / writable LPDDR2 memory
 *
 * This type secures a readable / writable memory block in user space.
 */
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RW			0x0c20d060U

#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA			SCE_KERNEL_MEMBLOCK_TYPE_USER_RW

/**
 * @brief User readable / writable LPDDR2 non-cache memory
 *
 * A type to secure a memory block on LPDDR2 that is readable
 * and writable in user space and does not use cache.
 */
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_NC_RW			0x0c208060U

/**
 * @brief An alias for SCE_KERNEL_MEMBLOCK_TYPE_USER_NC_RW.
 */
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE		SCE_KERNEL_MEMBLOCK_TYPE_USER_NC_RW

/**
 * @brief An alias for SCE_KERNEL_MEMBLOCK_TYPE_USER_NC_RW.
 */
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE		SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE

/**
 * @brief User readable and writable LPDDR2 physical continuous memory
 *
 * A type that can read and write in user space and secure
 * memory blocks from the physical continuous memory area.
 */
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW		0x0c80d060U

/**
 * @brief User-readable and non-cacheable physical continuous memory
 *
 * A type for on-cacheable read / write in user space and to secure
 * memory blocks from the physical continuous memory area.
 */
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW	0x0d808060U

/**
 * @brief User-readable and non-cacheable CDRAM memory
 *
 * A type that can be read and written in user space and secures
 * memory blocks on CDRAM.
 */
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW			0x09408060U

/**
 * @brief An alias for SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW.
 */
#define SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RWDATA		SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW

/*@}*/

/**
 * @brief A type representing a memory type
 *
 * A type that represents the type of memory block secured by sceKernelAllocMemBlock.
 */
typedef int		SceKernelMemoryType;

/**
 * @brief Memory block information structure
 *
 * A structure for obtaining information about memory blocks. Size is 0x14 bytes on FW 0.990.
 */
typedef struct SceKernelMemBlockInfo0990 {
	SceSize				size;			/**< Size of the structure itself */
	void				*mappedBase;		/**< Map base address */
	SceSize				mappedSize;		/**< Mapped size */
	SceKernelMemoryType		memoryType;		/**< Memory type */
	SceUInt32			access;			/**< Access right */
} SceKernelMemBlockInfo0990;

/**
 * @brief Memory block information structure
 *
 * A structure for obtaining information about memory blocks. Size is 0x18 bytes on FWs 0.996+.
 */
typedef struct SceKernelMemBlockInfo {
	SceSize				size;			/**< Size of the structure itself */
	void				*mappedBase;		/**< Map base address */
	SceSize				mappedSize;		/**< Mapped size */
	SceKernelMemoryType		memoryType;		/**< Memory type */
	SceUInt32			access;			/**< Access right */
	SceKernelMemBlockType		type;			/**< Memory block type */
} SceKernelMemBlockInfo;

typedef struct SceKernelMemBlockInfoCore {
	SceKernelMemBlockType type;
	SceUID guid;
	const char *name;
	void *mappedBase;
	SceSize mappedSize;
	SceSize allocMapSize;
	int extraLow;
	int extraHigh;
	int unk20; // Some sort of internal memblock paging type. 0x4 - MemBlockVirPageList, 0x8 - MemBlockPartial
	SceUID partitionGuid;
	SceUIDPhyMemPartObject *pPhyMemPart;
} SceKernelMemBlockInfoCore;

typedef struct SceKernelMemBlockInfoEx { // size is 0xAC on FW 0.990, 0xB8 on FW 3.60
	SceSize size; // Size of this structure
	SceKernelMemBlockInfoCore coreInfo;
	SceSize nPhyAddrs;
	SceSize nPhySizes;
	void *phyAddrs[0x10];
	SceSize phySizes[0x10];
} SceKernelMemBlockInfoEx;

typedef struct SceKernelMemBlockInfoSimple { // size is 0x24 on FW 0.990
	SceSize size; // Size of this structure
	SceKernelMemBlockInfoCore coreInfo;
} SceKernelMemBlockInfoSimple;

/*----- memory access permission -----*/

/**
 * @brief readable memory
 */
#define SCE_KERNEL_MEMORY_ACCESS_R		0x04U

/**
 * @brief writable memory
 */
#define SCE_KERNEL_MEMORY_ACCESS_W		0x02U

/**
 * @brief executable memory (kernel only)
 */
#define SCE_KERNEL_MEMORY_ACCESS_X		0x01U

/*----- memory type -----*/

/**
 * @brief uncache normal memory
 */
#define SCE_KERNEL_MEMORY_TYPE_NORMAL_NC	0x80

/**
 * @brief cache normal memory
 */
#define SCE_KERNEL_MEMORY_TYPE_NORMAL		0xD0

/**
 * Optional parameter of sceKernelAllocMemBlock for FWs <=0.940.
 */
 typedef struct SceKernelAllocMemBlockOpt0940 { // size is 0x14 on FW 0.940-0.990
	SceSize		size;				/**< Size of this structure */
	SceUInt32	attr;				/**< Attributes field */
	SceSize		alignment;			/**< Specify alignment.
							SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_ALIGNMENT must be set for the attr member. */
	SceUID		uidBaseBlock;			/**< Base memory block UID */
	const char	*strBaseBlockName;		/**< Base memory block UID name */
} SceKernelAllocMemBlockOpt0940;

/**
 * Option parameter of sceKernelAllocMemBlock
 */
 typedef struct SceKernelAllocMemBlockOpt { // size is 0x14/0x38/0x3C/0x40 on FW 3.60
	/**
	 * Size of this structure
	 */
	SceSize		size;

	/**
	 * Attributes field
	 */
	SceUInt32	attr;

	/**
	 * Specify alignment.
	 * SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_ALIGNMENT must be set for the attr member.
	 */
	SceSize		alignment;

	/**
	 * reserved
	 */
	 SceUInt32	uidBaseBlock;

	/**
	 * reserved2
	 */
	const char	*strBaseBlockName;

#if 0
	/**
	 * mapped base address [out]
	 */
	void		*mappedBase;

	/**
	 * mapped size [out]
	 */
	SceSize		mappedSize;

	/**
	 * memory type [out]
	 */
	SceKernelMemoryType	memoryType;

	SceUInt32	access;
#endif
} SceKernelAllocMemBlockOpt;

/**
 * Option parameter of kernel sceKernelAllocMemBlock on old FWs (as seen on FWs 0.900-0.990)
 */
typedef struct SceKernelAllocMemBlockOptKernel_old { // size is 0x28 on 0.900, 0x2C on 0.910, 0x30 on 0.931-0.990, 0x34 on ?.??
	SceSize size;			// Size of this structure
	SceUInt32 unk_4;
	SceUInt32 attr;
	void *vbase;
	void *pbase;			// Physical address to use as base
	SceSize alignment;
	SceUInt32 extraLow;
	SceUInt32 extraHigh;
	void *base;
	SceUID pid;
	SceKernelPAVector *pPAV;
	SceSize roundupUnitSize;
	SceUInt32 unk_30;
} SceKernelAllocMemBlockOptKernel_old;

/**
 * Option parameter of kernel sceKernelAllocMemBlock on recent FWs (as seen on FW 3.60)
 */
typedef struct SceKernelAllocMemBlockOptKernel { // size is 0x58 on FW 3.60
	SceSize size;			// Size of this structure
	SceUInt32 unk_4;                // Never used?
	SceUInt32 attr;
	void *vbase;                    // Virtual address memblock should be mapped at
	void *pbase;			// Physical address to use as base
	SceSize alignment;
	SceSize extraLow;               // Size of extra area starting from memblock vbase
	SceSize extraHigh;              // Size of extra area starting "after" memblock - extra area is ?not mapped?
	SceUID baseMemBlock;            // UID of memblock this one is based on
	SceUID pid;
	SceKernelPAVector *pPAV;
	SceSize roundupUnitSize;        // Used to roundup memblock vsize
	SceUInt8 domain;
	SceUInt32 unk_34; // Related to SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20
	SceUInt32 unk_38; // Related to SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20
	SceUInt32 unk_3C; // Related to SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20
	SceUInt32 unk_40; // Related to SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20
	SceUInt32 unk_44; // Related to SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20
	SceUInt32 unk_48; // Related to SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20
	SceUInt32 unk_4C; // Related to SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20
	SceUInt32 unk_50; // Related to SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20
	SceUInt32 unk_54; // Related to SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20
} SceKernelAllocMemBlockOptKernel;

/**
 * Attributes to enable some SceKernelAllocMemBlockOpt members.
 */
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_VBASE        0x00000001
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_PBASE        0x00000002
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_ALIGNMENT    0x00000004
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_EXTRA_LOW    0x00000008
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_EXTRA_HIGH   0x00000010
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x20         0x00000020
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_BASE         0x00000040
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_PID          0x00000080
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_BASENAME     0x00000200 // Only available for sceKernelAllocMemBlockForUser - kernel callers must use HAS_BASE instead
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_PPAV         0x00001000 // Official name may be HAS_PVECTOR
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_ROUNDUP      0x00002000
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_0x4000       0x00004000 // Some options when registering SceKernelBlock with guid
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_DOMAIN       0x00010000
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_NOPHYPAGE        0x00020000
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_DONT_MAP         0x00040000 // Do not map the memory block in the virtual address space (unofficial name)
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_PHYCONT	        0x00200000 // Memory area is physically continuous.
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_UNK              0x00400000
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_SHARE_VBASE      0x00800000 // Memblock shares vbase with base block - requires HAS_BASE
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_SHARE_PHYPAGE    0x01000000 // Memblock shares physical pages with base block - requires HAS_BASE
#define SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_ALLOW_PARTIAL_OP 0x04000000 // Allow partial operation. ?What does that mean?

/**
 * UID is created by sceKernelOpen***()
 */
#define SCE_UID_ATTR_OPEN_FLAG			0x00080000U

typedef struct SceKernelHeapInfo { // size is 0xCC on FW 0.990
	SceSize size;			// Size of this structure
	char unk_4[0xC8];
} SceKernelHeapInfo;

typedef struct SceKernelHeapObject { // size is 0x40 on FW 0.990
	SceSize size;				// Size of this structure
	uint32_t unk_4;				// 0x4
	uint32_t unk_8;				// 0x8
	uint32_t unk_C;				// 0xC
	uint32_t unk_10;			// 0x10
	uint32_t unk_14;			// 0x14
	uint32_t unk_18;			// 0x18
	uint32_t unk_1C;			// 0x1C
	uint32_t unk_20;			// 0x20
	uint32_t unk_24;			// 0x24
	uint32_t unk_28;			// 0x28
	uint32_t unk_2C;			// 0x2C
	uint32_t unk_30;			// 0x30
	uint32_t magic;				// 0x34 - 0xD2BBDEC3
	uint32_t unk_38;			// 0x38
	uint32_t unk_3C;			// 0x3C
	uint32_t unk_40;			// 0x40
} SceKernelHeapObject;

typedef struct SceKernelFixedHeap { // size is 0x40 on FW 0.990
	SceSize size;				// Size of this structure
	SceClass pClass;			// 0x4
	uint32_t unk_8;				// 0x8
	uint32_t unk_C;				// 0xC
	uint32_t unk_10;			// 0x10
	uint32_t unk_14;			// 0x14
	uint32_t pageSize;			// 0x18 - min 0x1000 on FW 0.990
	uint16_t itemSize;			// 0x1C
	uint16_t unk_1E;			// 0x1E
	uint32_t unk_20;			// 0x20
	uint32_t unk_24;			// 0x24
	uint32_t magic;				// 0x28 - 0xFD9B28A6
	uint16_t sizeInWords;			// 0x2C
	uint16_t index;				// 0x2E
	SceKernelHeapObject *heapObject;	// 0x30
	uint32_t unk_34;			// 0x34
	uint32_t unk_38;			// 0x38
	uint16_t unk_3C;			// 0x3C
} SceKernelFixedHeap;

typedef struct SceKernelFixedHeapInfo_0990 { // size is 0x14 on FW 0.990
	SceSize size;			// Size of this structure
	uint32_t unk_4;			// = (uint32_t)*(uint16_t *)(pObject + 0x1C)
	uint32_t unk_8;			// = *(uint32_t *)(pObject + 0x18) + (uint32_t)*(uint16_t *)(pObject + 0x2E)
	uint32_t unk_C;			// = (uint32_t)*(uint16_t *)(pObject + 0x1E)
	uint32_t unk_10;		// = (uint32_t)*(uint16_t *)(pObject + 0x20)
} SceKernelFixedHeapInfo_0990;

typedef struct SceKernelFixedHeapInfo {
    SceSize size;  //size of this structure (0x90 on FW 3.65)
    SceSize objectSize;
    SceSize totalHeapSize;
    SceSize totalItemCount;
    SceSize totalFreeCount;
    SceUInt32 nUsedMax;
    SceUInt32 unk_18;
    //These two fields may be a single Highwater counter
    SceUInt16 nItemInPage;
    SceUInt16 nMaxItemInPage;
    SceUInt32 nListCount;
    struct {
        SceUInt16 unk_00;
        SceUInt16 nCount;
        SceUInt32 unk_04;
        SceUInt32 unk_08;
        SceUInt32 unk_0C;
    } cpuCache[4];
    SceUInt32 unk_64;
    SceUInt32 unk_68;
    SceUInt32 unk_6C;
    SceUInt32 unk_70;
    SceUInt32 nItem;
    SceUInt32 unk_78;
    SceUInt32 nPage;
    SceUInt32 unk_80;
    SceUInt32 unk_84;
    SceUInt32 unk_88;
    SceUInt32 unk_8C;
} SceKernelFixedHeapInfo;

typedef struct SceKernelHeapMemoryOpt { // size is 0x14 on FW 0.990-3.60
	SceSize size;			// Size of this structure
	uint32_t unk_4;			// ex: 0
	SceSize alignment;		// ex: 0x10, 0x40
	uint32_t unk_C;			// ex: 0, 0x20
	uint32_t unk_10;		// ex: 0
} SceKernelHeapMemoryOpt;

typedef struct SceKernelHeapCreateOpt { // size is 0x14 on FW 0.931-0.990, 0x1C on FW 3.60
  SceSize size;
	union { //<! Union for compatibility
		SceUInt32 attr;
		SceUInt32 uselock; //<! Do not use uselock as it will be deprecated. ex: 1, 0x100
	};
  SceUInt32 field_8; // ex: 0x8000
  SceUInt32 field_C;
  SceUInt32 block_type; // wrongly called memtype in vitasdk
  SceUInt32 field_14;
  SceUInt32 field_18;
} SceKernelHeapCreateOpt;

typedef struct SceKernelMMUL1Info { // size is 0xC in 0.990 - holds information about a single L1PT entry
    SceUIntVAddr vbase; // Start of the virtual address range mapped by L1PT entry
    SceUIntPAddr pbase; // Start of the physical address held in L1PT - paddr mapped for Section, paddr of L2PT for Page Table entry
    SceUInt32 entryType; // 0 = Invalid (fault on access), 1 = Section/Supersection, 2 = Page Table
} SceKernelMMUL1Info;

typedef struct SceAddressSpace { // size is at least 0xEC
	char unk[0x14];
	SceKernelMMUContext *context;
	char unk[0xC4];
	void *funcAlloc;
	char unk2[0x8];
	uint32_t magic;			// always 0x4D95AEEC
} SceAddressSpace;

typedef struct SceKernelAddressSpaceCallback {
	SceUInt32 index;
	void *(* funcMalloc)(SceUInt32 index, SceSize length);
	void (* funcFree)(SceUInt32 index, void *ptr);
	// maybe more
} SceKernelAddressSpaceCallback;

typedef struct SceKernelCreateAddressSpaceOpt { // size is 0x10 bytes on FW 0.940-3.60
	SceSize size; // Size of this structure
	int flag;
	SceKernelAddressSpaceCallback *data_0x08; // info dst buff ptr, need AddrSpace.flag = 2;
	void *TTBR1; // info dst buff ptr, need AddrSpace.flag |= 4;
} SceKernelCreateAddressSpaceOpt;

typedef struct SceKernelAddressSpaceInfo { // size is 0x654-bytes
	SceSize size;
	SceUID asid;
	SceUInt8 CONTEXTID;
	SceUInt8 paddinf[3];
	SceUInt32 nList;
	struct {
		SceSize size;
		SceUIDPartitionObject *pPart;
		SceUIntPtr vbase;
		SceSize vsize;
		SceUInt32 unk_0x10; // nBlock?
		SceSize vsizeRemain;
		const char *name;
		SceUInt32 unk_0x1C;
		SceUInt32 unk_0x20;
		SceUInt32 unk_0x24;
		SceUInt32 unk_0x28;
		SceUInt32 unk_0x2C;
	} list[0x20];
	SceUInt32 nPhyMemPart;
	SceUIDPhyMemPartObject *pPhyMemPart[0x10];
} SceKernelAddressSpaceInfo;

typedef struct SceKernelVARange {
	uint32_t addr;
	SceSize size;
} SceKernelVARange;

typedef struct SceKernelPARange {
	uint32_t addr;
	SceSize size;
} SceKernelPARange;

typedef struct SceKernelPAVector { // size is 0x14 on FW 0.990
	SceSize size;			// Size of this structure
	uint32_t pRanges_size;		// Ex: 8
	uint32_t nDataInVector;		// Must be <= 8
	uint32_t count;
	SceKernelPARange *pRanges;
} SceKernelPAVector;

#define SCE_KERNEL_PROCESS_ID_SELF 0 // Current running process ID is always 0.

typedef struct SceKernelPhyMemPart { // size is at least 0x9C on FWs 0.931-3.60
	uint32_t field_0x0;
	uint32_t field_0x4;
	uint32_t some_counter; // always positive
	uint32_t field_0xc;
	char *name;
	int type; // 0x10000 for Lpddr2Main, 0x30000 for Cdram
	int mutex;
	SceUIntPAddr pbase;
	SceSize totalSize;
	int field_0x24;
	void *pRoot;
	uint32_t field_0x2c;
	uint32_t field_0x30;
	uint32_t field_0x34;
	uint32_t field_0x38;
	int status;
	int pindex40; //1
	int field_0x44;
	int pindex48; //2
	int field_0x4c;
	int pindex50; //3
	int field_0x54;
	int pindex58; //4
	int field_0x5c;
	int pindex60; //5
	int field_0x64;
	int pindex68; //6
	int field_0x6c;
	int pindex70; //7
	int field_0x74;
	int pindex78; //8
	int field_0x7c;
	int pindex80; //9
	SceSize psize2;
	int min;
	int pindex8C; //10
	int field_0x90;
	SceUInt32 nClient;
	SceSize freeSize;
} SceKernelPhyMemPart;

typedef struct ScePhyMemPartInfoCore { // size is 0x10 on FWs 0.990-3.60
	SceUIntPAddr pbase; // same as SceKernelPhyMemPart field 0x1C
	SceSize totalSize;
	SceSize freeSize;
	SceUInt32 unk_C; // maybe some counter
} ScePhyMemPartInfoCore;

typedef struct SceKernelPhyMemLow { // size is 0x1C on 0.990
        SceUInt32 mutex;        // For use with sceKernelCpuLockSuspendIntrStoreLR
        SceUIntPAddr pbase;     // Base address of range managed by this instance
        SceSize psize;          // Size of range managed by this instance
        SceSize granularity;    // Minimum size that can be allocated from this instance (i.e. every allocation must be aligned to this)
        SceUInt32 unk10;        // Maybe backing memory type? Seen values: 0x20 (CDRAM)
        SceSize bitmapSize;     // Size of the bitmap array (in elements)
        SceUInt32* bitmap;      // Bitmap used to store which elements managed by this instance are in use - each bit represents a granularity-sized element. Status of element n can be found by looking at (bitmap[n / 32] >> (n % 32)): 0 means free, 1 means occupied  
} SceKernelPhyMemLow;

typedef struct ScePhyMemLowInfo { // size is 0x1C on 0.990
        SceSize size; // Size of this structure
        SceUIntPAddr pbase;
        SceSize psize;
        SceSize granularity;
        SceUInt32 unk10;       // unk14 from PhyMemLow
        SceSize bmArraySize;   // Size of the array pointed to by bitmap, IN ELEMENTS. Nothing is written here. Pass 0 if bitmap is NULL.
        SceUInt32* bitmap;     // Optional - array that receives a copy of the PhyMemLow bitmap
} ScePhyMemLowInfo;

//for 0.990
#define SCE_KERNEL_PHYMEMLOW_TYPE_LPDDR2MAIN 0x10001
#define SCE_KERNEL_PHYMEMLOW_TYPE_UNK 0x10002
#define SCE_KERNEL_PHYMEMLOW_TYPE_CDRAM 0x20001

typedef struct SceKernelVSlot { // size is at least 0x40 on FW 3.65
    char unk_0x0[0x18];
    void* base_addr_or_offset;
    char unk_0x1C[8];
    void* some_struct;
    char unk_0x28[0xC];
    SceSize alloc_phy_size;
    SceSize alloc_size;
    int unk;
} SceKernelVSlot;

typedef SceVoid(*SceKernelSysrootVeneziaRpcDebugFunc)(SceUInt32 debugCode, SceUInt32 argNum, ...);

typedef SceVoid(*SceKernelSysrootVipRpcDebugFunc)(SceUInt32 debugCode, SceUInt32 argNum, ...);

// This is a guessed type name
typedef SceUInt32 SceKernelLockMode;
#define SCE_KERNEL_LOCK_MODE_0x10 0x10
#define SCE_KERNEL_LOCK_MODE_0x20 0x20

typedef struct SceKernelModulePrivate9 { // size is 0xAC-bytes on FW 3.60
	SceClass SceUIDModuleClass;
	SceClass SceUIDLibraryClass;
	SceClass SceUIDLibStubClass;
	SceKernelProcessLibdb libdb;
	SceUID ScePsp2BootConfig_modid;
} SceKernelModulePrivate9;

#define SCE_UID_ENTRY_MAX_LCOUNT (0xF0)

Debug Types

typedef struct kernel_message_ctx { // size is 0x18 on FW 3.60
  SceUInt32 fileHash; // First 4 bytes of SHA1(__FILE__) - e.g. 0x123EC4E8 = "processmgr.c"
  SceUInt32 lineHash; // First 4 bytes of SHA1("%s:%d" % (__FILE__, __LINE__)) - e.g. 0x7D3F4B00 = "boot.c:1868"
  SceUInt32 funcHash; // First 4 bytes of SHA1(__FUNC__) - e.g. 0x197C5ED2 = "LedModuleStart"
  const char *pFile;  // Pointer to file name - can be NULL.
  int line; //Line in file - ignored if pFile is NULL.
  const char *pFunc; // Pointer to function name - ignored if pFile is NULL.
} kernel_message_ctx;

/**
 * An enumeration to represent the various logging levels which can be output by sceDbgLoggingHandler().
 */
typedef enum SceDbgLogLevel {
	SCE_DBG_LOG_LEVEL_ALWAYS = 0,
	SCE_DBG_LOG_LEVEL_TRACE,     /* An extremely verbose logging level, mostly useful for internal developers. */
	SCE_DBG_LOG_LEVEL_DEBUG,     /* A diagnostic logging level. */
	SCE_DBG_LOG_LEVEL_INFO,      /* An informational logging level. */
	SCE_DBG_LOG_LEVEL_WARNING,   /* A logging level that gives warnings of situations detrimental to proper execution. */
	SCE_DBG_LOG_LEVEL_ERROR,     /* A logging level that will report erroneous conditions in execution. */
	SCE_DBG_NUM_LOG_LEVELS       /* The number of logging levels available. */
} SceDbgLogLevel;

/*
Target Manager (Communication Processor) Logging levels.
These levels can be set using psp2ctrl set-logging-level <level>.
LOG_LEVEL_NONE (0)
LOG_LEVEL_ERROR (1)
LOG_LEVEL_WARNING (2)
LOG_LEVEL_SERVICE (3)
LOG_LEVEL_INFO (4)
LOG_LEVEL_INTERNAL (5)
LOG_LEVEL_MAX (6)
*/

typedef struct SceSyscallInfo { // size is 0x3C on FW 3.60
	SceSize size; // Size of this structure
	SceUInt32 moduleFingerprint;
	SceUInt32 maybeModuleAttr;
	char moduleName[0x20];
	char *libName;
	SceUInt32 maybeLibAttr;
	SceUInt32 libVer;
	SceUInt32 libNid;
} SceSyscallInfo;

typedef struct SceSyscallFrame { // size is at least 0x5C on FW 3.60
	SceUInt32 r0; // 0x00
	SceUInt32 r1; // 0x04
	SceUInt32 r2; // 0x08
	SceUInt32 r3; // 0x0C
	SceUInt32 r4; // 0x10
	SceUInt32 r5; // 0x14
	SceUInt32 r6; // 0x18
	SceUInt32 r7; // 0x1C
	SceUInt32 r8; // 0x20
	SceUInt32 r9; // 0x24
	SceUInt32 r10; // 0x28
	SceUInt32 r11; // 0x2C
	SceUInt32 r12; // 0x30
	SceUInt32 unk_34; // 0x34
	void *entry; // 0x38
	SceUInt32 unk_3C; // 0x3C
	SceUInt32 resultType; // 0x40, 0-3
	int unk_44[3]; // 0x44
	SceUInt32 SP; // 0x50
	SceUInt32 LR; // 0x54
	SceUInt32 PC; // 0x58
} SceSyscallFrame;

// process
typedef struct SceKernelDebugEventLog1 { // size is 0x1C
	int data_0x40;
	SceUID pid;
	int budget_type;
	int data_0x4C;    // 0xA
	char titleid[0xC];
} __attribute__((packed)) SceKernelDebugEventLog1;

// Related to network
typedef struct SceKernelDebugEventLog2 { // size is 0x4
	int data_0x40;    // 0 or 0x80412118?
} __attribute__((packed)) SceKernelDebugEventLog2;

// Related to network
typedef struct SceKernelDebugEventLog3 { // size is 0x54
	int data_0x40;    // 0?
	char ip1[0x10];
	char ip2[0x10];
	char ip3[0x10];
	char ip4[0x10];
	char ip5[0x10];
} __attribute__((packed)) SceKernelDebugEventLog3;

typedef struct SceKernelDebugEventLog {
	SceSize size;
	int data_0x04;    // 0xA, titleid size?
	char titleid[0xC];
	int flags;
	SceUID ppid;
	SceUID data_0x1C; // thid?
	int rsvd[4];
	SceUInt64 time;
	int data_0x38;
	SceSize item_size;
	union {
		SceKernelDebugEventLog1 type1;
		SceKernelDebugEventLog2 type2;
		SceKernelDebugEventLog3 type3;
	};
} __attribute__((packed)) SceKernelDebugEventLog;

GetPhyMemPartIndex

uint GetPhyMemPartIndex(uint param_1) {
  uint cpuId;
  
  if (param_1 == 0xea0d050) goto LAB_81009494;
  if (param_1 < 0xea0d051) {
    if (param_1 == 0x620d004) {
      return 6;
    }
    if (param_1 < 0x620d005) {
      if (param_1 != 0x3b0d060) {
        if (param_1 < 0x3b0d061) {
          if (param_1 != 0x3a0d060) {
            if (param_1 < 0x3a0d061) {
              if (param_1 == 0x3a0d040) goto LAB_81009494;
              if (param_1 == 0x3a0d050) {
                return 10;
              }
            }
            else {
              if (param_1 == 0x3b0d040) goto LAB_81009494;
              if (param_1 == 0x3b0d050) {
                return 0xb;
              }
            }
            goto LAB_81009402;
          }
        }
        else {
          if (param_1 != 0x3f0d060) {
            if (param_1 < 0x3f0d061) {
              if ((param_1 == 0x3f0d040) || (param_1 == 0x3f0d050)) goto LAB_81009494;
            }
            else {
              if (param_1 == 0x6208004) {
                return 6;
              }
              if (param_1 == 0x6208006) {
                return 6;
              }
            }
            goto LAB_81009402;
          }
        }
      }
LAB_81009494:
      return (param_1 << 8) >> 0x1c;
    }
    if (param_1 == 0xc208060) {
      return 0xb;
    }
    if (param_1 < 0xc208061) {
      if (param_1 == 0x9408060) {
        return 0xc;
      }
      if (param_1 < 0x9408061) {
        if (param_1 == 0x620d006) {
          return 6;
        }
        if (param_1 == 0x9404060) {
          return 0xc;
        }
      }
      else {
        if (param_1 == 0xb100860) {
          return 1;
        }
        if (param_1 == 0xc200860) {
          return 0xb;
        }
      }
    }
    else {
      if (param_1 == 0xea08040) goto LAB_81009494;
      if (param_1 < 0xea08041) {
        if (param_1 == 0xc20d050) {
          return 0xb;
        }
        if (param_1 == 0xc20d060) {
          return 0xb;
        }
      }
      else {
        if (param_1 == 0xea08060) goto LAB_81009494;
        if (param_1 == 0xea0d040) {
          return 10;
        }
      }
    }
  }
  else {
    if (param_1 == 0x20108004) {
      return 1;
    }
    if (param_1 < 0x20108005) {
      if (param_1 == 0x1020d006) {
        return 6;
      }
      if (param_1 < 0x1020d007) {
        if (param_1 == 0x10208004) {
          return 6;
        }
        if (param_1 < 0x10208005) {
          if (param_1 == 0xea0d060) goto LAB_81009494;
          if (param_1 == 0x10200806) {
            return 6;
          }
        }
        else {
          if (param_1 == 0x10208006) {
            return 6;
          }
          if (param_1 == 0x1020d004) {
            return 6;
          }
        }
      }
      else {
        if (param_1 == 0x20100206) {
          return 1;
        }
        if (param_1 < 0x20100207) {
          if (param_1 == 0x1050d006) {
            return 5;
          }
          if (param_1 == 0x20100204) {
            return 1;
          }
        }
        else {
          if (param_1 == 0x20100804) {
            return 1;
          }
          if (param_1 == 0x20100806) {
            return 1;
          }
        }
      }
    }
    else {
      if (param_1 == 0x60208006) {
        return 6;
      }
      if (param_1 < 0x60208007) {
        if (param_1 == 0x40404006) {
          return 0xc;
        }
        if (param_1 < 0x40404007) {
          if (param_1 == 0x20108006) {
            return 1;
          }
          if (param_1 == 0x2010d006) {
            return 1;
          }
        }
        else {
          if (param_1 == 0x40408006) {
            return 0xc;
          }
          if (param_1 == 0x60208004) {
            return 6;
          }
        }
      }
      else {
        if (param_1 == 0x6050d006) goto LAB_81009494;
        if (param_1 < 0x6050d007) {
          if (param_1 == 0x6020d004) {
            return 6;
          }
          if (param_1 == 0x6020d006) {
            return 6;
          }
        }
        else {
          if (0x70f0d003 < param_1) {
            if (param_1 < 0x70f0d007) goto LAB_81009494;
            if (param_1 == 0xa0408006) {
              return 0xc;
            }
          }
        }
      }
    }
  }
LAB_81009402:
  cpuId = sceKernelCpuIdForDriver();
  sceKernelPrintfLevelForDriver
            (1,
             "%d:address_space.c:%s:Warning:Using SCE_KERNEL_PHYMEMPART_LPDDR2MAIN_KERNEL_INDEX for0x%08x\n"
             , cpuId, "GetPhyMemPartIndex", param_1);
  return 6;
}

Memory Block Type

The type parameter indicates what kind of memory to allocate. Here is a mapping of type flags to ARM MMU flags. Higher bits are used for other options including where to allocate from. Not all flag values are valid, there is a table of valid types in the kernel. You cannot, for example, allocate RWX memory.

All memtype list for 3.60

// For usermode
#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 kernel
#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)

#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)

Note

The only commonly available memtypes are those that are publicly available.

sceKernelAllocMemblockInternal uses a list to translate it into an internal memtype.

So we can't create memtype with any bits and use that's.

memtype bit value

Mask Value Description
0xF000000 N/A Partition index.
0xF00000 N/A Src ScePhyMemPart.
0x10000 0x10000 Global. nG bit NOT set
0xFF00 0x800 B bit set. Sharable device memory.
0xFF00 0x2000 TEX[2] and TEX[0] bit set. Outer cache Write-back, Write-Allocate. Inner cache non-cachable.
0xFF00 0x4000 TEX[2] and B bit set. Outer cache non-cachable. Inner cache Write-back, Write-Allocate
0xFF00 0x8000 TEX[0] bit set. S bit unset. Outer and inner non-cachable. Not sharable.
0xFF00 0xD000 TEX[0] bit set. C,B bits set. Outer and inner Write-back, Write-Allocate.
0xFF 0x4 AP[2:0] = 5, XN=1. Privileged RO, User NA.
0xFF 0x5 AP[2:0] = 5. Privileged RX, User NA.
0xFF 0x6 AP[2:0] = 1, XN=1. Privileged RW, User NA.
0xFF 0x7 AP[2:0] = 1. Privileged RWX, User NA. (Never used, 3.60 0x80024B01)
0xFF 0x50 AP[2:0] = 7. Privileged RX, User RX.
0xFF 0x60 AP[2:0] = 3, XN=1. Privileged RW, User RW.
0xFF 0x40 AP[2:0] = 7, XN=1. Privileged RO, User RO.


This is based internal memtypes.

Mask Value Name
0x0F000000 0x00000000 root
0x0F000000 0x01000000 SceKernelRootUncacheGpuGame
0x0F000000 0x02000000 SceKernelTmpFsGame
0x0F000000 0x03000000 SceKernelTmpFsGame
0x0F000000 0x04000000 SceKernelTool
0x0F000000 0x05000000 SceKernelRootUncache?
0x0F000000 0x06000000 Unknown
0x0F000000 0x07000000 SCE_KERNEL_ERROR_ILLEGAL_PARTITION_INDEX
0x0F000000 0x08000000 SceKernelUserTool
0x0F000000 0x09000000 SceKernelUserCdram
0x0F000000 0x0A000000 SceKernelUserShared
0x0F000000 0x0B000000 SceKernelUserIO
0x0F000000 0x0C000000 SceKernelUserMain
0x0F000000 0x0D000000 SceKernelUserUncache
0x0F000000 0x0E000000 SceKernelUserCDialog
0x0F000000 0x0F000000 SceKernelUserCDialogNC

Available memory types

See also : Memory budget


Mask value   Description
0x000000FF | memory access.
             0x0000000F for kernel
             0x000000F0 for user
               0 1 1 0
               - R W X
0x00000F00 | unknown
             0x00000100 for unknown
             0x00000200 for SO
             0x00000400 for unknown
             0x00000800 for DEVICE
0x0000F000 | cache
             0x00002000 for No internal cache only
             0x00004000 for No external cache only
             0x00008000 for NORMAL_NC (uncache)
             0x0000D000 for NORMAL (cache)
0x00F00000 | memory partition select
             0x00100000 for IO
             0x00200000 for NORMAL (kernel:KD, user:GAME)
             0x00300000 for maybe unused
             0x00400000 for CDRAM
             0x00500000 for GAME
             0x00800000 for PHYCONT
             0x00900000 for SHARED (usermode only)
             0x00A00000 for CDIALOG
             0x00C00000 for ???
             0x00F00000 for TOOL
0xFF000000 | memory VA select
             0x05000000 for user CDRAM2
             0x06000000 for user KTMP
             0x09000000 for user CDRAM
             0x0C000000 for user normal?
             0x0D000000 for user MAIN PHYCONT
             0x0E000000 for user CDIALOG
             0x10000000 for kernel ROOT
             0x20000000 for kernel IO
             0x30000000 for kernel PHYCONT
             0x40000000 for kernel CDRAM
             0x50000000 for kernel CDRAM2
             0x60000000 for kernel TMP
             0xA0000000 for kernel GPU

SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM2_RW                 0x05408060

SCE_KERNEL_MEMBLOCK_TYPE_USER_KTMP*****                 0x0620D006

SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW_UNCACHE_EXTERNAL 0x09404060
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RO_UNCACHE          0x09408040
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW_UNCACHE          0x09408060
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW                  0x09408060
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RWDATA              0x09408060

SCE_KERNEL_MEMBLOCK_TYPE_USER_DEVICE_RW                 0x0C200860
SCE_KERNEL_MEMBLOCK_TYPE_USER_NC_RW                     0x0C208060
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE                0x0C208060
SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE            0x0C208060
SCE_KERNEL_MEMBLOCK_TYPE_USER_RO                        0x0C20D040
SCE_KERNEL_MEMBLOCK_TYPE_USER_TEXT                      0x0C20D050
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW                        0x0C20D060
SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA                    0x0C20D060
SCE_KERNEL_MEMBLOCK_TYPE_USER_GAME_RW                   0x0C50D060
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW           0x0C80D060
SCE_KERNEL_MEMBLOCK_TYPE_USER_UNKNOWN_RW_UNCACHE        0x0CA08060
SCE_KERNEL_MEMBLOCK_TYPE_USER_UNKNOWN_RW                0x0CA0D060
SCE_KERNEL_MEMBLOCK_TYPE_USER_UNKNOWN2_RW               0x0CF0D060

SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW        0x0D808060

SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RO_UNCACHE        0x0E208040
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RX_UNCACHE        0x0E208050
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RW_UNCACHE        0x0E208060
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RO                0x0E20D040
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RW                0x0E20D060


kernel memory types:

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_DEVICE_RW          0x10200806

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_SO_RW              0x10200206

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_R_UNCACHE          0x10208004

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RW_UNCACHE         0x10208006

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_R                  0x1020D004

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RX                 0x1020D005

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RW                 0x1020D006

/* alloc from ScePhyMemPartGame */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RW_GAME            0x1050D006

/* alloc from ScePhyMemPartPhyCont */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RW_PHYCONT         0x1080D006

/* alloc from ScePhyMemPartGameCDialog */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RW_CDIALOG         0x10A0D006

/* Seems alloc from remaining area */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RW_10C0D006        0x10C0D006

#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_SO_RO           0x20100204
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_SO_RW           0x20100206
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_RO              0x20100804
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_RW              0x20100806
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_NC_RO           0x20108004
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_NC_RW           0x20108006

#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_PHYCONT_RW_UNCACHE 0x30808006

#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_CDRAM_RW_UNK       0x40404006
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_CDRAM_RW           0x40408006
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_CDRAM2_RW          0x50408006

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_NC_R           0x60208004

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_NC_RW          0x60208006

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_R              0x6020D004

/* alloc from ScePhyMemPartKD */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_RW             0x6020D006

/* alloc from ScePhyMemPartGame */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_GAME_RW        0x6050D006

code memory types:
SCE_KERNEL_MEMBLOCK_CODE_MEMORY_TYPE_L2WBWA: 0x2000
SCE_KERNEL_MEMBLOCK_CODE_MEMORY_TYPE_L1WBWA: 0x4000
SCE_KERNEL_MEMBLOCK_CODE_MEMORY_TYPE_NORMAL_NC: 0x8000

from 0.990
/* need check */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_CDRAM_L1WBWA_RW

#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_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_BOOT_IMAGE         0x1020D007

#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_GAME_RW       0x1050D006

#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_SO_R            0x20100204
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_DEVICE_R        0x20100804
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_DEVICE_RW       0x20100806
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_NC_R            0x20108004

#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_PHYCONT_R     0x3080D004
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_PHYCONT_RW    0x3080D006

#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_UMAIN_RW

#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_TOOL_NC_RW         0x10F08004
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_NC_R          0x10F08006
#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_TMP_NC_R           0x60208004
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_NC_RW          0x60208006
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_R              0x6020D006
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_GAME_RW        0x6050D006

/* need check */
#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_KMP_TOOL_RW        0x60F0D006

#define SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_GPU_CDRAM_RW       0xA0408006

Types to reverse

from 0.990:

CDIALOG:
SCE_KERNEL_MEMBLOCK_TYPE_CDIALOG_NC_R

FREE:
SCE_KERNEL_MEMBLOCK_TYPE_FREE

KERNEL:
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_CDRAM_L1WBWA_RW

SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_DEVICE_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_DEVICE_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_NC_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_IO_SO_R

SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_KMP_TOOL_RW

SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_CDIALOG_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_CDIALOG_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_DEVICE_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_GAME_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_NC_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_NC_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_PHYCONT_NC_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_PHYCONT_NC_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_PHYCONT_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_PHYCONT_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_RX
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_SO_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_ROOT_UMAIN_RW

SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_GAME_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_NC_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_NC_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TMP_R

SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_NC_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_NC_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_R
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_RW
SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_TOOL_RX

USER:
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_NC_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RX

SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_NC_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_NC_RW

SCE_KERNEL_MEMBLOCK_TYPE_USER_IO_DEVICE_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_IO_SO_RW

SCE_KERNEL_MEMBLOCK_TYPE_USER_KTMP_NC_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_KTMP_NC_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_KTMP_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_KTMP_RW

SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_DEVICE_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_GAME_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_NC_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_RX
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_NC_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_RX

SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_CDIALOG_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_CDIALOG_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_CDIALOG_RX
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_MAIN_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_MAIN_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_MAIN_RX
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_SHARED_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_SHARED_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_SHARED_RX
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_TOOL_R
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_TOOL_RW
SCE_KERNEL_MEMBLOCK_TYPE_USER_SHARED_TOOL_RX