copy iwram section to iwram

This commit is contained in:
Corwin Kuiper 2021-04-13 01:32:40 +01:00 committed by Corwin
parent 3905c3e13a
commit c315aab113
2 changed files with 26 additions and 4 deletions

12
crt0.s
View file

@ -12,6 +12,18 @@ __start:
ldr r1, =0x03007FFC
str r0, [r1]
@ copies iwram section in rom to iwram in ram
ldr r0, =__iwram_rom_start @ load memory address storing start of data for iwram in rom
ldr r1, =__iwram_data_start @ load memory address storing location of iwram in ram
ldr r2, =__iwram_rom_length_halfwords @ load number of 16 bit values to copy
swi 0x000B0000 @ call interrupt CpuSet.
@ r0: source
@ r1: destination
@ r2: length + size information
@
@ see: https://mgba-emu.github.io/gbatek/#swi-0bh-gbands7nds9dsi7dsi9---cpuset
@ load main and branch
ldr r0, =main
bx r0

18
gba.ld
View file

@ -30,18 +30,28 @@ SECTIONS {
. = ALIGN(4);
} > rom
__data_start = .;
.data : {
__iwram_rom_start = .;
.iwram : {
__iwram_data_start = ABSOLUTE(.);
*(.data .data.*);
. = ALIGN(4);
} > iwram
__data_end = .;
*(.text_iwram .text_iwram.*);
. = ALIGN(4);
__iwram_data_end = ABSOLUTE(.);
} > iwram AT>rom
.bss : {
*(.bss .bss.*);
. = ALIGN(4);
} > iwram
__iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start;
__iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2;
/* discard anything not already mentioned */
/DISCARD/ : { *(*) }
}