forked from notaz/picodrive
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libretro, add libmappedmemory option for drc
this platform requires *freeing* of the drc memory, so add a hook for that, inside an ifdef so we don't have to touch every platform
- Loading branch information
Showing
6 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "libmemorymapping.h" | ||
|
||
#include <coreinit/dynload.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
// Aroma libmappedmemory - Maschell promises he won't break ABI here | ||
static void* (**MEMAllocFromMappedMemoryEx)(uint32_t size, int32_t alignment); | ||
static void* (**MEMFreeToMappedMemory)(void *ptr); | ||
static OSDynLoad_Module libmappedmemory; | ||
|
||
static bool wiiu_init_libmappedmemory() { | ||
OSDynLoad_Error err; | ||
|
||
// already ran? | ||
if (MEMAllocFromMappedMemoryEx) | ||
return true; | ||
|
||
err = OSDynLoad_Acquire("homebrew_memorymapping", &libmappedmemory); | ||
if (err != OS_DYNLOAD_OK) | ||
return false; | ||
|
||
err = OSDynLoad_FindExport(libmappedmemory, OS_DYNLOAD_EXPORT_DATA, "MEMAllocFromMappedMemoryEx", (void**)&MEMAllocFromMappedMemoryEx); | ||
if (err != OS_DYNLOAD_OK) | ||
return false; | ||
|
||
err = OSDynLoad_FindExport(libmappedmemory, OS_DYNLOAD_EXPORT_DATA, "MEMFreeToMappedMemory", (void**)&MEMFreeToMappedMemory); | ||
if (err != OS_DYNLOAD_OK) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
void *wiiu_alloc_mappedmemory(uint32_t size, int32_t alignment) { | ||
if (!wiiu_init_libmappedmemory()) return NULL; | ||
|
||
return (*MEMAllocFromMappedMemoryEx)(size, alignment); | ||
} | ||
|
||
void wiiu_free_mappedmemory(void *mem) { | ||
if (!wiiu_init_libmappedmemory()) return; | ||
|
||
(*MEMFreeToMappedMemory)(mem); | ||
} | ||
|
||
void wiiu_deinit_mappedmemory(void) { | ||
OSDynLoad_Release(libmappedmemory); | ||
MEMAllocFromMappedMemoryEx = NULL; | ||
MEMFreeToMappedMemory = NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef LIBMEMORYMAPPING_H | ||
#define LIBMEMORYMAPPING_H | ||
|
||
#include <stdint.h> | ||
|
||
void *wiiu_alloc_mappedmemory(uint32_t size, int32_t alignment); | ||
void wiiu_free_mappedmemory(void *mem); | ||
void wiiu_deinit_mappedmemory(void); | ||
|
||
#endif // LIBMEMORYMAPPING_H |