Explicitly setup heap, fixes brahma.

Since brahma has its stack (unless it is changed) in ARM9 memory, the
default logic for setting up the heap breaks, since it assumes the heap
is in lower memory than the stack. This commit uses a hook used by
newlib to setup the heap at any random location in memory. This commit
just allocates a 32MB heap, although it could certainly be larger.
This commit is contained in:
Gabriel Marcano 2016-06-08 19:48:42 -04:00
parent a471b28cd5
commit 4c0559bc1a

View File

@ -3,6 +3,7 @@
.extern main
.align 4
.arm
.extern fake_heap_end @ used for heap setup by newlib used by devKitARM
#define SIZE_32KB 0b01110
#define SIZE_128KB 0b10000
@ -93,6 +94,14 @@ _fix_sdmc_mount:
str r1, [r0]
mov pc, lr
_setup_heap:
mov r0, #0x2000000 @ Setup a 32MiB heap
ldr r1, =__end__ @ grab the location of the end of the binary
add r0, r0, r1
ldr r1, =fake_heap_end @ heap goes from end of program to this variable
str r0, [r1]
mov pc, lr
_init:
push {r0-r12, lr}
@ -100,6 +109,8 @@ _init:
bl _fix_sdmc_mount
bl _setup_heap
bl main
mrc p15, 0, r4, c1, c0, 0