From 1afc4b899ed3365bb8f89cbd9301cd539157d95a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Date: Mon, 24 Apr 2017 05:41:14 +0200 Subject: [PATCH] os_functions: Add OS{AllocFrom,FreeTo}System OSAllocFromSystem allocates a physically contiguous area of memory, and returns a pointer to it as a virtual address in the calling process's address space. OSFreeToSystem is the corresponding free function. --- os_functions.c | 4 ++++ os_functions.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/os_functions.c b/os_functions.c index a0a4928..08514a1 100644 --- a/os_functions.c +++ b/os_functions.c @@ -99,6 +99,8 @@ EXPORT_DECL(void *, MEMAllocFromExpHeapEx, s32 heap, u32 size, s32 align); EXPORT_DECL(s32 , MEMCreateExpHeapEx, void* address, u32 size, unsigned short flags); EXPORT_DECL(void *, MEMDestroyExpHeap, s32 heap); EXPORT_DECL(void, MEMFreeToExpHeap, s32 heap, void* ptr); +EXPORT_DECL(void *, OSAllocFromSystem, int size, int alignment); +EXPORT_DECL(void, OSFreeToSystem, void *addr); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! MCP functions @@ -268,6 +270,8 @@ void InitOSFunctionPointers(void) OS_FIND_EXPORT(coreinit_handle, MEMCreateExpHeapEx); OS_FIND_EXPORT(coreinit_handle, MEMDestroyExpHeap); OS_FIND_EXPORT(coreinit_handle, MEMFreeToExpHeap); + OS_FIND_EXPORT(coreinit_handle, OSAllocFromSystem); + OS_FIND_EXPORT(coreinit_handle, OSFreeToSystem); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Other function addresses diff --git a/os_functions.h b/os_functions.h index 6aad386..474db4d 100644 --- a/os_functions.h +++ b/os_functions.h @@ -138,6 +138,8 @@ extern void *(* MEMAllocFromExpHeapEx)(s32 heap, u32 size, s32 align); extern s32 (* MEMCreateExpHeapEx)(void* address, u32 size, unsigned short flags); extern void *(* MEMDestroyExpHeap)(s32 heap); extern void (* MEMFreeToExpHeap)(s32 heap, void* ptr); +extern void* (* OSAllocFromSystem)(int size, int alignment); +extern void (* OSFreeToSystem)(void *addr); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! MCP functions