1 //SPDX-License-Identifier: GPL-2.0-or-later
3 * https://github.com/devkitPro/wut/blob/0b196e8abcedeb0238105f3ffab7cb0093638b86/include/coreinit/memorymap.h
12 * \defgroup coreinit_memorymap Memory Map
22 typedef enum OSMemoryMapMode
24 OS_MAP_MEMORY_INVALID = 0,
25 OS_MAP_MEMORY_READ_ONLY = 1,
26 OS_MAP_MEMORY_READ_WRITE = 2,
27 OS_MAP_MEMORY_FREE = 3,
28 OS_MAP_MEMORY_ALLOCATED = 4,
31 #define OS_PAGE_SIZE (128 * 1024)
34 OSEffectiveToPhysical(uint32_t virtualAddress);
37 OSIsAddressValid(uint32_t virtualAddress);
40 __OSValidateAddressSpaceRange(int /* unused */,
41 uint32_t virtualAddress,
45 * Allocates virtual address range for later mapping.
47 * \param virtualAddress
48 * Requested start address for the range. If there is no preference, NULL can be
52 * Size of address range to allocate.
55 * Alignment of address range to allocate.
58 * The starting address of the newly allocated range, or NULL on failure.
65 OSAllocVirtAddr(uint32_t virtualAddress,
70 * Frees a previously allocated virtual address range back to the system.
72 * \param virtualAddress
73 * The start of the virtual address range to free.
76 * The size of the virtual address range to free.
82 OSFreeVirtAddr(uint32_t virtualAddress,
86 * Determines the status of the given virtual memory address - mapped read-write
87 * or read-only, free, allocated or invalid.
89 * \param virtualAddress
90 * The virtual address to query.
93 * The status of the memory address - see #OSMemoryMapMode.
96 OSQueryVirtAddr(uint32_t virtualAddress);
99 * Maps a physical address to a virtual address, with a given size and set of
102 * \param virtualAddress
103 * The target virtual address for the mapping.
105 * \param physicalAddress
106 * Physical address of the memory to back the mapping.
109 * Size, in bytes, of the desired mapping. Likely has an alignment requirement.
112 * Permissions to map the memory with - see #OSMemoryMapMode.
115 * \c true on success.
118 * - OSAllocVirtAddr()
122 OSMapMemory(uint32_t virtualAddress,
123 uint32_t physicalAddress,
125 OSMemoryMapMode mode);
128 * Unmaps previously mapped memory.
130 * \param virtualAddress
131 * Starting address of the area to unmap.
134 * Size of the memory area to unmap.
137 * \c true on success.
140 OSUnmapMemory(uint32_t virtualAddress,
144 * Gets the range of virtual addresses available for mapping.
146 * \param outVirtualAddress
147 * Pointer to write the starting address of the memory area to.
150 * Pointer to write the size of the memory area to.
156 OSGetMapVirtAddrRange(uint32_t *outVirtualAddress,
160 * Gets the range of available physical memory (not reserved for app code or
163 * \param outPhysicalAddress
164 * Pointer to write the starting physical address of the memory area to.
167 * Pointer to write the size of the memory area to.
170 * Is memory returned by this function actually safe to map and use? couldn't
171 * get a straight answer from decaf-emu's kernel_memory.cpp...
175 OSGetAvailPhysAddrRange(uint32_t *outPhysicalAddress,
179 * Gets the range of physical memory used for the application's data.
181 * \param outPhysicalAddress
182 * Pointer to write the starting physical address of the memory area to.
185 * Pointer to write the size of the memory area to.
188 * does this include the main heap?
192 OSGetDataPhysAddrRange(uint32_t *outPhysicalAddress,