[nostalgia/core/gba][ox/std] Move heap manager from NostalgiaCore to OxStd

This commit is contained in:
2020-05-29 19:36:00 -05:00
parent 0eb33f823c
commit 98a0c42040
11 changed files with 108 additions and 74 deletions

View File

@ -6,17 +6,33 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <ox/std/bit.hpp>
#include <ox/std/heapmgr.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
// this warning is too dumb to realize that it can actually confirm the hard
// coded address aligns with the requirement of HeapSegment, so it must be
// suppressed
#pragma GCC diagnostic ignored "-Wcast-align"
#define MEM_WRAM_BEGIN reinterpret_cast<uint8_t*>(0x02000000)
#define MEM_WRAM_END reinterpret_cast<uint8_t*>(0x0203FFFF)
#define HEAP_BEGIN reinterpret_cast<ox::heapmgr::HeapSegment*>(MEM_WRAM_BEGIN)
// set size to half of WRAM
#define HEAP_SIZE ((MEM_WRAM_END - MEM_WRAM_BEGIN) / 2)
#define HEAP_END reinterpret_cast<ox::heapmgr::HeapSegment*>(MEM_WRAM_BEGIN + HEAP_SIZE)
extern void (*__preinit_array_start[]) (void);
extern void (*__preinit_array_end[]) (void);
extern void (*__init_array_start[]) (void);
extern void (*__init_array_end[]) (void);
namespace nostalgia::core {
namespace ox::heapmgr {
void initHeap();
void initHeap(char *heapBegin, char *heapEnd);
}
@ -38,7 +54,7 @@ int main(int argc, const char **argv);
int c_start() {
const char *args[2] = {"", "rom.oxfs"};
nostalgia::core::initHeap();
ox::heapmgr::initHeap(ox::bit_cast<char*>(HEAP_BEGIN), ox::bit_cast<char*>(HEAP_END));
return main(2, args);
}