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
|
||||
|
||||
@ 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
|
||||
ldr r0, =main
|
||||
bx r0
|
||||
|
|
14
gba.ld
14
gba.ld
|
@ -43,6 +43,17 @@ SECTIONS {
|
|||
__iwram_data_end = ABSOLUTE(.);
|
||||
} > 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.*);
|
||||
|
@ -52,6 +63,9 @@ SECTIONS {
|
|||
__iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start;
|
||||
__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/ : { *(*) }
|
||||
}
|
44
src/lib.rs
44
src/lib.rs
|
@ -122,20 +122,38 @@ pub extern "C" fn main() -> ! {
|
|||
loop {}
|
||||
}
|
||||
|
||||
#[test_case]
|
||||
fn trivial_test(_gba: &mut Gba) {
|
||||
assert_eq!(1, 1);
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::Gba;
|
||||
|
||||
#[test_case]
|
||||
fn wait_30_frames(gba: &mut Gba) {
|
||||
let vblank = gba.display.vblank.get();
|
||||
let mut counter = 0;
|
||||
loop {
|
||||
if counter > 30 {
|
||||
break;
|
||||
#[test_case]
|
||||
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 mut counter = 0;
|
||||
loop {
|
||||
if counter > 30 {
|
||||
break;
|
||||
}
|
||||
vblank.wait_for_VBlank();
|
||||
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")
|
||||
}
|
||||
vblank.wait_for_VBlank();
|
||||
counter += 1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue