6#ifndef _PSP2KERN_KERNEL_SYSMEM_H_
7#define _PSP2KERN_KERNEL_SYSMEM_H_
337#define ksceKernelFindMemBlockByAddrForPid(pid, addr, size) ksceKernelFindProcMemBlockByAddr(pid, addr, size)
339#define ksceKernelMapBlockUserVisible(uid) ksceKernelMapMemBlock(uid)
340#define ksceKernelRemapBlock(uid, type) ksceKernelRemapMemBlock(uid, type)
342#define ksceKernelMapUserBlock(name, permission, flags, user_buf, size, kernel_page, kernel_size, kernel_offset) ksceKernelUserMapWithFlags(name, permission, flags, user_buf, size, kernel_page, kernel_size, kernel_offset)
343#define ksceKernelMapUserBlockDefaultType(name, permission, user_buf, size, kernel_page, kernel_size, kernel_offset) ksceKernelUserMap(name, permission, user_buf, size, kernel_page, kernel_size, kernel_offset)
344#define ksceKernelMapUserBlockDefaultTypeForPid(pid, name, permission, user_buf, size, kernel_page, kernel_size, kernel_offset) ksceKernelProcUserMap(pid, name, permission, user_buf, size, kernel_page, kernel_size, kernel_offset)
345#define ksceKernelMemBlockRelease(uid) ksceKernelUserUnmap(uid)
347#define ksceKernelMemRangeRetain(addr, size) ksceKernelLockRange(addr, size)
348#define ksceKernelMemRangeRetainForPid(pid, addr, size) ksceKernelLockRangeProc(pid, addr, size)
349#define ksceKernelMemRangeRetainWithPerm(perm, addr, size) ksceKernelLockRangeWithMode(perm, addr, size)
351#define ksceKernelMemRangeRelease(addr, size) ksceKernelUnlockRange(addr, size)
352#define ksceKernelMemRangeReleaseForPid(pid, addr, size) ksceKernelUnlockRangeProc(pid, addr, size)
353#define ksceKernelMemRangeReleaseWithPerm(perm, addr, size) ksceKernelUnlockRangeWithMode(perm, addr, size)
#define VITASDK_BUILD_ASSERT_EQ(__size__, __name__)
Definition build_utils.h:13
int flags
Event flags.
Definition debug.h:3
SceUID pid
Definition debug.h:1
SceSize size
Definition lsdb.h:11
SceInt32 type
Must be 100 when passed to sceLsdbReplaceTheme on FW 3.60.
Definition lsdb.h:2
SceUInt32 SceKernelMemBlockType
Definition sysmem.h:16
SceUID kscePUIDOpenByNameWithClass(ScePID pid, const char *name, SceClass *object_class)
Opens a named object of the required class in a process-local UID namespace.
SceSize size
Must be set to sizeof(SceKernelAllocMemBlockInfo).
Definition sysmem.h:378
SceKernelMemBlockType type
Memblock type.
Definition sysmem.h:390
int ksceGUIDGetClass(SceUID guid, SceClass **object_class)
Gets the class of a global UID object.
int ksceKernelLockRangeProc(ScePID pid, void *addr, SceSize size)
Locks a memory range for a process (pid)
int ksceKernelIncRefCountMemBlock(SceUID uid)
Increments a memblock's internal range/reference counter.
int ksceKernelFreeMemBlock(SceUID uid)
Frees new memory block.
int ksceKernelIsEqualAccessibleRangeProcBySW(ScePID pid, SceUInt32 permission, const void *va, SceSize len)
Checks whether a range has exactly the requested software permissions.
SceUInt32 field_4C
Definition sysmem.h:58
SceUIDPhyMemPartObject * phy_mem_part
Physical-memory partition object.
Definition sysmem.h:400
SceUInt32 access
Bitwise OR of SceKernelMemoryAccessType values.
Definition sysmem.h:382
void * ksceKernelAllocUncacheHeapMemory(SceSize size)
SceUID ksceKernelAllocPartitionMemBlock(SceUID part, const char *name, SceKernelMemBlockType type, SceSize size, const SceKernelAllocMemBlockOptKernel *pOpt)
int ksceKernelIsAccessibleRangeProc(ScePID pid, SceUInt32 permission, const void *va, SceSize len)
permission is a bitwise OR of SceKernelMemoryRefPerm values.
SceUInt32 attr
Bitwise OR of SceKernelAllocMemBlockAttr values.
Definition sysmem.h:41
int ksceKernelGetMemBlockType(SceUID uid, unsigned int *type)
Gets the memory block type of a memory block.
int ksceKernelUnlockRangeProc(ScePID pid, void *addr, SceSize size)
Unlocks a memory range for a process (pid)
SceKernelMemoryType memory_type
Memory type derived from the selected memblock type.
Definition sysmem.h:381
SceUInt32 field_34
Definition sysmem.h:52
SceUID ksceKernelProcUserMap(SceUID pid, const char *name, int permission, const void *user_buf, SceSize size, void **kernel_page, SceSize *kernel_size, SceUInt32 *kernel_offset)
The mapping user address space to kernel with process.
SceUID pid
Definition sysmem.h:48
SceSize size
Must be set to sizeof(SceKernelHeapMemoryOpt).
Definition sysmem.h:369
SceUID kscePUIDOpenByName(ScePID pid, const char *name)
Opens a named object in a process-local UID namespace.
void * mapped_base
Virtual mapping base.
Definition sysmem.h:393
int ksceKernelIsAccessibleRange(SceUInt32 permission, const void *va, SceSize len)
permission is a bitwise OR of SceKernelMemoryRefPerm values.
SceUID partition_guid
Physical-memory partition UID, or -1 when unavailable.
Definition sysmem.h:399
SceUID ksceKernelFindProcMemBlockByAddr(SceUID pid, const void *addr, SceSize size)
Find the SceUID of a memory block in a process.
SceUInt32 paddr
Definition sysmem.h:43
SceSize alignment
Definition sysmem.h:44
SceKernelAllocMemBlockKernelOpt SceKernelAllocMemBlockOptKernel
Definition sysmem.h:64
SceSize alloc_map_size
Size of the mapping actually allocated.
Definition sysmem.h:395
const char * name
Read-only memblock name.
Definition sysmem.h:392
SceSize mapped_size
Requested mapping size.
Definition sysmem.h:394
SceUInt32 field_4
Definition sysmem.h:40
SceUID kscePUIDtoGUIDWithClass(ScePID pid, SceUID puid, SceClass *object_class)
Resolves a process-local UID to its global UID, requiring object_class.
int ksceGUIDSetName(SceUID guid, const char *name)
Replaces the name of a global UID object.
int ksceKernelMemBlockType2Memtype(SceKernelMemBlockType type)
Gets the internal memory-type class associated with a memblock type.
int ksceGUIDReferObjectWithLevel(SceUID guid, SceUInt32 visibility_level, SceKernelObject **object)
Takes a reference to a global UID at visibility level 0 through 7.
SceUID ksceGUIDOpenByName(const char *name)
Opens a named global UID object.
SceSize size
Size of this structure.
Definition sysmem.h:39
SceSize extra_high
High-end mapping padding.
Definition sysmem.h:397
int ksceKernelUnmapMemBlock(SceUID uid)
Unmap a memblock.
SceKernelPaddrList * paddr_list
Definition sysmem.h:49
int ksceKernelVARangeToPARangeBySW(const SceKernelVARange *v_range, SceKernelPARange *pa_range)
int ksceKernelGetMemBlockVBase(SceUID uid, void **base)
Gets the virtual base reserved for a memblock.
SceUID ksceKernelAllocMemBlock(const char *name, SceKernelMemBlockType type, SceSize size, SceKernelAllocMemBlockKernelOpt *opt)
Allocates a new memory block.
SceUID ksceGUIDCreate(SceClass *object_class, const char *name, SceUID reference_guid, SceKernelObject **object)
Creates a global UID object, optionally relative to reference_guid.
int ksceKernelVARangeToPARangeByHW(const SceKernelVARange *v_range, SceKernelPARange *pa_range)
const char * ksceGUIDName(SceUID guid)
Returns the read-only name of a live global UID.
int ksceKernelCountFillValue64FromUser(const SceUInt64 *ptr, SceUInt64 value, SceSize byte_size)
Counts the bytes at the start of a user-memory range in the calling process that match a repeated 64-...
int ksceKernelProcModeVAtoPA(ScePID pid, SceUInt32 permission, const void *va, void **pa)
Translates an address in another process after applying an MMU access mode.
int ksceKernelMemBlockTypeGetPrivileges(SceKernelMemBlockType type)
Gets the memory permissions associated with a memblock type.
SceSize extraHigh
Definition sysmem.h:46
void * mapped_base
Mapped base address.
Definition sysmem.h:379
SceUInt32 field_54
Definition sysmem.h:60
SceUID guid
Global memblock UID, or zero when it is hidden at the requested visibility level.
Definition sysmem.h:391
SceUInt32 field_3C
Definition sysmem.h:54
int ksceKernelGetMemBlockMemtypeByAddr(const void *addr)
Gets the internal memory type for an address.
SceUInt32 paging_type
Internal paging type; observed values include 4 and 8.
Definition sysmem.h:398
int kscePUIDGetObject(ScePID pid, SceUID puid, SceKernelObject **object)
Gets the class-specific object data for a process-local UID without taking a reference.
SceUInt32 mirror_blockid
Definition sysmem.h:47
int ksceGUIDGetObject(SceUID guid, SceKernelObject **object)
Gets the class-specific object data for a global UID without taking a reference.
SceUID ksceKernelFindMemBlockByAddr(const void *addr, SceSize size)
Find the SceUID of a memory block.
int ksceKernelLockRangeWithMode(SceKernelMemoryRefPerm perm, void *addr, SceSize size)
Locks a memory range, checking for a given permission.
SceUInt32 field_44
Definition sysmem.h:56
SceUInt32 field_50
Definition sysmem.h:59
SceKernelHeapMemoryMappingAction
Definition sysmem.h:355
int ksceKernelGetPhysicalMemoryType(const void *vaddr)
Classifies the physical region containing a virtual address.
int ksceKernelUnlockRangeWithMode(SceKernelMemoryRefPerm perm, void *addr, SceSize size)
Unlocks a memory range checking for a given permission.
SceKernelMemBlockInfoCore core_info
Definition sysmem.h:406
SceUID kscePUIDOpenByGUIDWithFlags(ScePID pid, SceUID guid, SceUInt32 flags)
Opens a global UID in a process-local UID namespace.
int ksceKernelCountFillValueFromUser(const SceUInt32 *ptr, SceUInt32 value, SceSize byte_size)
Counts the bytes at the start of a user-memory range in the calling process that match a repeated 32-...
void * ksceKernelAllocUncacheHeapMemoryWithOption(SceSize size, SceKernelHeapMemoryOpt *opt)
SceUID ksceKernelAllocMemBlockWithInfo(const char *name, SceKernelMemBlockType type, SceSize vsize, const SceKernelAllocMemBlockOptKernel *opt, SceKernelAllocMemBlockInfo *info)
Allocates a memory block and returns its mapping information.
SceUInt32 mapping_action
One of SceKernelHeapMemoryMappingAction.
Definition sysmem.h:370
int ksceKernelRemapMemBlock(SceUID uid, SceKernelMemBlockType type)
Changes the block type.
int ksceKernelCountFillValueFromUserProc(ScePID pid, const SceUInt32 *ptr, SceUInt32 value, SceSize byte_size)
Counts the bytes at the start of another process's user-memory range that match a repeated 32-bit val...
int kscePUIDGetClass(ScePID pid, SceUID puid, SceClass **object_class)
Gets the class of an object in a process-local UID namespace.
int ksceKernelFreeUncacheHeapMemory(void *ptr)
int kscePUIDSetName(ScePID pid, SceUID puid, const char *name)
Replaces the name of a process-local UID entry.
void * mapped_base
Base of the mapped or unmapped backing range.
Definition sysmem.h:372
int ksceKernelUnlockRange(void *addr, SceSize size)
Unlocks a memory range.
SceUID ksceKernelUserMapWithFlags(const char *name, int permission, int flags, const void *user_buf, SceSize size, void **kernel_page, SceSize *kernel_size, unsigned int *kernel_offset)
The mapping user address space to kernel with flags.
int ksceKernelVAtoPABySW(const void *va, void **pa)
SceSize physical_range_count_written
Number of entries written to the arrays below, at most 16.
Definition sysmem.h:408
int ksceKernelUserUnmap(SceUID uid)
Frees a memblock mapped with ksceKernelUserMap.
int ksceGUIDGetName(SceUID guid, const char **name)
Gets the read-only name owned by a live global UID.
SceSize size
Must be set to sizeof(SceKernelMemBlockInfoEx).
Definition sysmem.h:405
struct SceUIDPhyMemPartObject SceUIDPhyMemPartObject
Opaque class-specific data for a physical-memory-partition UID object.
Definition sysmem.h:387
int kscePUIDGetName(ScePID pid, SceUID puid, const char **name)
Gets the read-only name owned by a process-local UID entry.
SceUID ksceKernelUserMap(const char *name, int permission, const void *user_buf, SceSize size, void **kernel_page, SceSize *kernel_size, SceUInt32 *kernel_offset)
The mapping user address space to kernel.
int ksceKernelGetMemBlockMappedBase(SceUID uid, void **base)
Gets the currently mapped base of a memblock.
int ksceKernelMemBlockGetInfoEx(SceUID uid, SceKernelMemBlockInfoEx *info)
Gets extended memblock information at visibility level 7.
int ksceKernelMapMemBlockWithFlag(SceUID uid, int flag)
Map a memblock.
SceSize physical_range_count
Total number of physical ranges.
Definition sysmem.h:407
void * physical_addresses[16]
Physical base of each reported range.
Definition sysmem.h:409
SceKernelMemoryRefPerm
Definition sysmem.h:27
int ksceKernelGetMemBlockBase(SceUID uid, void **base)
Gets the base address of a memory block.
int ksceKernelDecRefCountMemBlock(SceUID uid)
Decrements a memblock's internal range/reference counter.
int ksceKernelGetMemBlockPARange(SceUID uid, SceKernelPARange *pa_range)
Gets the single physical range backing a memblock.
SceSize mapped_size
Size of the mapped or unmapped backing range.
Definition sysmem.h:373
struct SceKernelObject SceKernelObject
Opaque class-specific data returned by the GUID and PUID object APIs.
Definition sysmem.h:415
int ksceKernelMapMemBlock(SceUID uid)
Map a memblock.
SceUInt32 field_2C
Definition sysmem.h:50
SceUInt32 field_48
Definition sysmem.h:57
SceUInt32 field_38
Definition sysmem.h:53
SceUInt32 field_30
Definition sysmem.h:51
SceSize mapped_size
Mapped size.
Definition sysmem.h:380
void * ksceKernelAllocHeapMemoryWithOpt(SceUID heap_id, SceSize size, SceKernelHeapMemoryOpt *opt)
Allocates from the heap identified by heap_id.
SceSize extra_low
Low-end mapping padding.
Definition sysmem.h:396
SceSize extraLow
Definition sysmem.h:45
int ksceGUIDReferObjectWithSubclass(SceUID guid, SceClass *object_class, SceKernelObject **object)
Takes a reference to a global UID object when its class derives from object_class.
SceKernelMemoryType
Definition sysmem.h:19
int ksceKernelGetMemBlockPAVector(SceUID uid, SceKernelPAVector *pa_vector)
Gets the physical-range vector backing a memblock.
int ksceKernelFreeSimpleMemBlock(void *a1)
SceUInt32 field_C
Definition sysmem.h:42
SceSize alignment
Requested allocation alignment, or zero for the heap default.
Definition sysmem.h:371
int ksceKernelVARangeToPAVectorBySW(const SceKernelVARange *v_range, SceKernelPAVector *pa_vector)
int ksceKernelVARangeToPAVectorByHW(const SceKernelVARange *v_range, SceKernelPAVector *pa_vector)
int ksceKernelGetMemBlockAllocMapSize(SceUID memid, SceSize *alloc_map_size)
Get the AllocMapSize of a MemBlock.
int ksceKernelLockRange(void *addr, SceSize size)
Locks a memory range.
SceUInt32 field_40
Definition sysmem.h:55
SceUID ksceGUIDKernelCreate(SceClass *object_class, const char *name, SceKernelObject **object)
Creates a kernel-owned global UID object with the default attributes.
int ksceKernelGetMemBlockInfo(SceUID uid, SceUInt32 visibility_level, SceKernelMemBlockInfoEx *info)
Gets extended memblock information at visibility level 0 through 7.
int ksceKernelCountFillValue64FromUserProc(ScePID pid, const SceUInt64 *ptr, SceUInt64 value, SceSize byte_size)
Counts the bytes at the start of another process's user-memory range that match a repeated 64-bit val...
SceSize physical_sizes[16]
Size of each reported range.
Definition sysmem.h:410
@ SCE_KERNEL_HEAP_MEMORY_MAPPING_ACTION_MAP
Definition sysmem.h:357
@ SCE_KERNEL_HEAP_MEMORY_MAPPING_ACTION_UNMAP
Definition sysmem.h:358
@ SCE_KERNEL_HEAP_MEMORY_MAPPING_ACTION_NONE
Definition sysmem.h:356
@ SCE_KERNEL_MEMORY_REF_PERM_USER_R
Definition sysmem.h:29
@ SCE_KERNEL_MEMORY_REF_PERM_KERN_R
Definition sysmem.h:32
@ SCE_KERNEL_MEMORY_REF_PERM_KERN_X
Definition sysmem.h:34
@ SCE_KERNEL_MEMORY_REF_PERM_ANY
Definition sysmem.h:28
@ SCE_KERNEL_MEMORY_REF_PERM_KERN_W
Definition sysmem.h:33
@ SCE_KERNEL_MEMORY_REF_PERM_USER_W
Definition sysmem.h:30
@ SCE_KERNEL_MEMORY_REF_PERM_USER_X
Definition sysmem.h:31
Definition uid_class.h:18
Options and mapping results for heap allocation.
Definition sysmem.h:368
int ScePID
Process ID.
Definition types.h:91
unsigned int SceSize
Definition types.h:56
int SceUID
UIDs are used to describe many different kernel objects.
Definition types.h:90
uint64_t SceUInt64
Definition types.h:51
uint32_t SceUInt32
Definition types.h:45