From c315aab1136bbdb046ac0b278afeaad82438d743 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Tue, 13 Apr 2021 01:32:40 +0100 Subject: [PATCH] copy iwram section to iwram --- crt0.s | 12 ++++++++++++ gba.ld | 18 ++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/crt0.s b/crt0.s index 124d95f3..73d5efeb 100644 --- a/crt0.s +++ b/crt0.s @@ -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 diff --git a/gba.ld b/gba.ld index c5b5f3ea..526e42d1 100644 --- a/gba.ld +++ b/gba.ld @@ -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/ : { *(*) } } \ No newline at end of file