2020-02-11 21:45:48 -06:00
|
|
|
/*
|
2021-03-15 22:03:35 -05:00
|
|
|
* Copyright 2016 - 2021 gary@drinkingtea.net
|
2020-02-11 21:45:48 -06:00
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
2019-11-03 23:23:43 -06:00
|
|
|
|
2020-05-29 19:36:00 -05:00
|
|
|
#include <ox/std/heapmgr.hpp>
|
|
|
|
|
2021-12-01 01:34:53 -06:00
|
|
|
#define MEM_EWRAM_BEGIN reinterpret_cast<char*>(0x02000000)
|
|
|
|
#define MEM_EWRAM_END reinterpret_cast<char*>(0x0203FFFF)
|
2020-05-29 19:36:00 -05:00
|
|
|
|
2021-12-01 01:34:53 -06:00
|
|
|
#define HEAP_BEGIN reinterpret_cast<char*>(MEM_EWRAM_BEGIN)
|
2020-07-12 18:35:18 -05:00
|
|
|
// set size to half of EWRAM
|
|
|
|
#define HEAP_SIZE ((MEM_EWRAM_END - MEM_EWRAM_BEGIN) / 2)
|
2021-12-01 01:34:53 -06:00
|
|
|
#define HEAP_END reinterpret_cast<char*>(MEM_EWRAM_BEGIN + HEAP_SIZE)
|
2020-05-29 19:36:00 -05:00
|
|
|
|
2019-11-03 23:23:43 -06:00
|
|
|
extern void (*__preinit_array_start[]) (void);
|
|
|
|
extern void (*__preinit_array_end[]) (void);
|
|
|
|
extern void (*__init_array_start[]) (void);
|
|
|
|
extern void (*__init_array_end[]) (void);
|
|
|
|
|
2020-07-12 18:35:18 -05:00
|
|
|
int main(int argc, const char **argv);
|
2020-02-11 21:45:48 -06:00
|
|
|
|
2020-01-12 20:45:20 -06:00
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
void __libc_init_array() {
|
2019-11-03 23:23:43 -06:00
|
|
|
auto preInits = __preinit_array_end - __preinit_array_start;
|
|
|
|
for (decltype(preInits) i = 0; i < preInits; i++) {
|
|
|
|
__preinit_array_start[i]();
|
|
|
|
}
|
|
|
|
auto inits = __init_array_end - __init_array_start;
|
|
|
|
for (decltype(inits) i = 0; i < inits; i++) {
|
2021-10-23 14:07:01 -05:00
|
|
|
__init_array_start[i]();
|
2019-11-03 23:23:43 -06:00
|
|
|
}
|
|
|
|
}
|
2020-01-12 20:45:20 -06:00
|
|
|
|
2020-01-12 21:18:21 -06:00
|
|
|
int c_start() {
|
2020-01-12 20:45:20 -06:00
|
|
|
const char *args[2] = {"", "rom.oxfs"};
|
2021-03-15 22:03:35 -05:00
|
|
|
ox::heapmgr::initHeap(HEAP_BEGIN, HEAP_END);
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wpedantic"
|
2020-01-12 21:18:21 -06:00
|
|
|
return main(2, args);
|
2021-03-15 22:03:35 -05:00
|
|
|
#pragma GCC diagnostic pop
|
2020-01-12 20:45:20 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|