mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-22 23:26:33 +11:00
support for using ewram
This commit is contained in:
parent
063fe9796b
commit
20c8541e36
3 changed files with 52 additions and 14 deletions
6
crt0.s
6
crt0.s
|
@ -24,6 +24,12 @@ __start:
|
||||||
@
|
@
|
||||||
@ see: https://mgba-emu.github.io/gbatek/#swi-0bh-gbands7nds9dsi7dsi9---cpuset
|
@ see: https://mgba-emu.github.io/gbatek/#swi-0bh-gbands7nds9dsi7dsi9---cpuset
|
||||||
|
|
||||||
|
@ copies ewram section in rom to ewram in ram
|
||||||
|
ldr r0, =__ewram_rom_start
|
||||||
|
ldr r1, =__ewram_data_start
|
||||||
|
ldr r2, =__ewram_rom_length_halfwords
|
||||||
|
swi 0x000B0000
|
||||||
|
|
||||||
@ load main and branch
|
@ load main and branch
|
||||||
ldr r0, =main
|
ldr r0, =main
|
||||||
bx r0
|
bx r0
|
||||||
|
|
14
gba.ld
14
gba.ld
|
@ -43,6 +43,17 @@ SECTIONS {
|
||||||
__iwram_data_end = ABSOLUTE(.);
|
__iwram_data_end = ABSOLUTE(.);
|
||||||
} > iwram AT>rom
|
} > iwram AT>rom
|
||||||
|
|
||||||
|
. = __iwram_rom_start + (__iwram_data_end - __iwram_data_start);
|
||||||
|
|
||||||
|
__ewram_rom_start = .;
|
||||||
|
.ewram : {
|
||||||
|
__ewram_data_start = ABSOLUTE(.);
|
||||||
|
|
||||||
|
*(.ewram .ewram.*);
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
__ewram_data_end = ABSOLUTE(.);
|
||||||
|
} > ewram AT>rom
|
||||||
|
|
||||||
.bss : {
|
.bss : {
|
||||||
*(.bss .bss.*);
|
*(.bss .bss.*);
|
||||||
|
@ -52,6 +63,9 @@ SECTIONS {
|
||||||
__iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start;
|
__iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start;
|
||||||
__iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2;
|
__iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2;
|
||||||
|
|
||||||
|
__ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start;
|
||||||
|
__ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2;
|
||||||
|
|
||||||
/* discard anything not already mentioned */
|
/* discard anything not already mentioned */
|
||||||
/DISCARD/ : { *(*) }
|
/DISCARD/ : { *(*) }
|
||||||
}
|
}
|
30
src/lib.rs
30
src/lib.rs
|
@ -122,13 +122,17 @@ pub extern "C" fn main() -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test_case]
|
#[cfg(test)]
|
||||||
fn trivial_test(_gba: &mut Gba) {
|
mod test {
|
||||||
assert_eq!(1, 1);
|
use super::Gba;
|
||||||
}
|
|
||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
fn wait_30_frames(gba: &mut Gba) {
|
fn trivial_test(_gba: &mut Gba) {
|
||||||
|
assert_eq!(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test_case]
|
||||||
|
fn wait_30_frames(gba: &mut Gba) {
|
||||||
let vblank = gba.display.vblank.get();
|
let vblank = gba.display.vblank.get();
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
loop {
|
loop {
|
||||||
|
@ -138,4 +142,18 @@ fn wait_30_frames(gba: &mut Gba) {
|
||||||
vblank.wait_for_VBlank();
|
vblank.wait_for_VBlank();
|
||||||
counter += 1
|
counter += 1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link_section = ".ewram"]
|
||||||
|
static mut EWRAM_TEST: u32 = 5;
|
||||||
|
#[test_case]
|
||||||
|
fn ewram_static_test(_gba: &mut Gba) {
|
||||||
|
unsafe {
|
||||||
|
let content = (&EWRAM_TEST as *const u32).read_volatile();
|
||||||
|
assert_eq!(content, 5, "expected data in ewram to be 5");
|
||||||
|
(&mut EWRAM_TEST as *mut u32).write_volatile(content + 1);
|
||||||
|
let content = (&EWRAM_TEST as *const u32).read_volatile();
|
||||||
|
assert_eq!(content, 6, "expected data to have increased by one")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue