From 524fd9143a9de82d9a6ef62403ee9a92015021e3 Mon Sep 17 00:00:00 2001 From: James Benton Date: Tue, 29 May 2018 13:55:10 +0100 Subject: [PATCH] coreinit: Add virtual memory mapping functions. --- cafe/coreinit/exports.def | 12 ++++++- include/coreinit/memory.h | 3 -- include/coreinit/memorymap.h | 65 ++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 include/coreinit/memorymap.h diff --git a/cafe/coreinit/exports.def b/cafe/coreinit/exports.def index e040e27..df52acc 100644 --- a/cafe/coreinit/exports.def +++ b/cafe/coreinit/exports.def @@ -264,10 +264,20 @@ MEMGetNthListObject // coreinit/memory.h OSBlockMove OSBlockSet -OSEffectiveToPhysical OSAllocFromSystem OSFreeToSystem +// coreinit/memorymap.h +OSEffectiveToPhysical +OSAllocVirtAddr +OSFreeVirtAddr +OSQueryVirtAddr +OSMapMemory +OSUnmapMemory +OSGetMapVirtAddrRange +OSGetAvailPhysAddrRange +OSGetDataPhysAddrRange + // coreinit/messagequeue.h OSInitMessageQueue OSInitMessageQueueEx diff --git a/include/coreinit/memory.h b/include/coreinit/memory.h index 3efc92c..76c1f4f 100644 --- a/include/coreinit/memory.h +++ b/include/coreinit/memory.h @@ -23,9 +23,6 @@ OSBlockSet(void *dst, uint8_t val, uint32_t size); -uint32_t -OSEffectiveToPhysical(void *vaddr); - void* OSAllocFromSystem(uint32_t size, int align); diff --git a/include/coreinit/memorymap.h b/include/coreinit/memorymap.h new file mode 100644 index 0000000..fb38fb4 --- /dev/null +++ b/include/coreinit/memorymap.h @@ -0,0 +1,65 @@ +#pragma once +#include + +/** + * \defgroup coreinit_memorymap Memory Map + * \ingroup coreinit + * + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum OSMemoryMapMode +{ + OS_MAP_MEMORY_INVALID = 0, + OS_MAP_MEMORY_READ_ONLY = 1, + OS_MAP_MEMORY_READ_WRITE = 2, + OS_MAP_MEMORY_FREE = 3, + OS_MAP_MEMORY_ALLOCATED = 4, +} OSMemoryMapMode; + +#define OS_PAGE_SIZE (128 * 1024) + +uint32_t +OSEffectiveToPhysical(uint32_t virtualAddress); + +uint32_t +OSAllocVirtAddr(uint32_t virtualAddress, + uint32_t size, + uint32_t align); + +BOOL +OSFreeVirtAddr(uint32_t virtualAddress, + uint32_t size); + +OSMemoryMapMode +OSQueryVirtAddr(uint32_t virtualAddress); + +BOOL +OSMapMemory(uint32_t virtualAddress, + uint32_t physicalAddress, + uint32_t size, + OSMemoryMapMode mode); + +BOOL +OSUnmapMemory(uint32_t virtualAddress, + uint32_t size); + +void +OSGetMapVirtAddrRange(uint32_t *outVirtualAddress, + uint32_t *outSize); + +void +OSGetAvailPhysAddrRange(uint32_t *outPhysicalAddress, + uint32_t *outSize); + +void +OSGetDataPhysAddrRange(uint32_t *outPhysicalAddress, + uint32_t *outSize); + +#ifdef __cplusplus +} +#endif