Set default stack to 32K, allow user adjustment
This commit is contained in:
parent
02b9cd468c
commit
2ed782f5f3
@ -7,6 +7,7 @@ u32 __linear_heap;
|
|||||||
u32 __heapBase;
|
u32 __heapBase;
|
||||||
extern u32 __heap_size, __linear_heap_size;
|
extern u32 __heap_size, __linear_heap_size;
|
||||||
|
|
||||||
|
u32 __attribute__((weak)) __stacksize__ = 32 * 1024;
|
||||||
|
|
||||||
void __attribute__((weak)) __system_allocateHeaps() {
|
void __attribute__((weak)) __system_allocateHeaps() {
|
||||||
u32 tmp=0;
|
u32 tmp=0;
|
||||||
@ -18,7 +19,7 @@ void __attribute__((weak)) __system_allocateHeaps() {
|
|||||||
// Allocate the linear heap
|
// Allocate the linear heap
|
||||||
svcControlMemory(&__linear_heap, 0x0, 0x0, __linear_heap_size, MEMOP_ALLOC_LINEAR, 0x3);
|
svcControlMemory(&__linear_heap, 0x0, 0x0, __linear_heap_size, MEMOP_ALLOC_LINEAR, 0x3);
|
||||||
// Set up newlib heap
|
// Set up newlib heap
|
||||||
fake_heap_start = (char*)__heapBase;
|
fake_heap_start = (char*)__heapBase + __stacksize__;
|
||||||
fake_heap_end = fake_heap_start + __heap_size;
|
fake_heap_end = fake_heap_start + __heap_size - __stacksize__;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ void __appExit();
|
|||||||
|
|
||||||
void __libc_fini_array(void);
|
void __libc_fini_array(void);
|
||||||
|
|
||||||
void __attribute__((weak)) __attribute__((noreturn)) __ctru_exit(int rc)
|
void __attribute__((weak)) __attribute__((noreturn)) __libctru_exit(int rc)
|
||||||
{
|
{
|
||||||
u32 tmp=0;
|
u32 tmp=0;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ void __libc_init_array(void);
|
|||||||
|
|
||||||
void __ctru_exit(int rc);
|
void __ctru_exit(int rc);
|
||||||
|
|
||||||
void __attribute__((weak)) initSystem(void (*retAddr)(void))
|
void __attribute__((weak)) __ctru_initSystem(void (*retAddr)(void))
|
||||||
{
|
{
|
||||||
|
|
||||||
// Register newlib exit() syscall
|
// Register newlib exit() syscall
|
||||||
|
30
libctru/source/system/init_exit_Wrappers.s
Normal file
30
libctru/source/system/init_exit_Wrappers.s
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
.text
|
||||||
|
.arm
|
||||||
|
.cpu mpcore
|
||||||
|
|
||||||
|
.global initSystem
|
||||||
|
.type initSystem STT_FUNC
|
||||||
|
@---------------------------------------------------------------------------------
|
||||||
|
initSystem:
|
||||||
|
@---------------------------------------------------------------------------------
|
||||||
|
adr r0, saved_lr
|
||||||
|
str lr, [r0]
|
||||||
|
str sp, [r0,#4]
|
||||||
|
bl __ctru_initSystem
|
||||||
|
ldr r0,=fake_heap_start
|
||||||
|
ldr sp, [r0]
|
||||||
|
ldr pc, saved_lr
|
||||||
|
|
||||||
|
saved_lr:
|
||||||
|
.word 0
|
||||||
|
saved_stack:
|
||||||
|
.word 0
|
||||||
|
|
||||||
|
|
||||||
|
.global __ctru_exit
|
||||||
|
.type __ctru_exit STT_FUNC
|
||||||
|
@---------------------------------------------------------------------------------
|
||||||
|
__ctru_exit:
|
||||||
|
@---------------------------------------------------------------------------------
|
||||||
|
ldr sp, saved_stack
|
||||||
|
b __libctru_exit
|
Loading…
Reference in New Issue
Block a user