mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-12 01:51:34 +11:00
Add test that data_end is in the correct place
This commit is contained in:
parent
f6f6f4d22e
commit
a31efe7156
|
@ -3,16 +3,6 @@ use core::ptr::NonNull;
|
||||||
|
|
||||||
use crate::interrupt::Mutex;
|
use crate::interrupt::Mutex;
|
||||||
|
|
||||||
fn get_data_end() -> usize {
|
|
||||||
extern "C" {
|
|
||||||
static __ewram_data_end: usize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: This seems completely wrong, but without the &, rust generates
|
|
||||||
// a double dereference :/. Maybe a bug in nightly?
|
|
||||||
(unsafe { &__ewram_data_end }) as *const _ as usize
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct BumpAllocator {
|
pub(crate) struct BumpAllocator {
|
||||||
current_ptr: Mutex<Option<NonNull<u8>>>,
|
current_ptr: Mutex<Option<NonNull<u8>>>,
|
||||||
}
|
}
|
||||||
|
@ -60,3 +50,28 @@ unsafe impl GlobalAlloc for BumpAllocator {
|
||||||
|
|
||||||
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
|
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_data_end() -> usize {
|
||||||
|
extern "C" {
|
||||||
|
static __ewram_data_end: usize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This seems completely wrong, but without the &, rust generates
|
||||||
|
// a double dereference :/. Maybe a bug in nightly?
|
||||||
|
(unsafe { &__ewram_data_end }) as *const _ as usize
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test_case]
|
||||||
|
fn should_return_data_end_somewhere_in_ewram(_gba: &mut crate::Gba) {
|
||||||
|
let data_end = get_data_end();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
0x0200_0000 <= data_end,
|
||||||
|
"data end should be bigger than 0x0200_0000, got {}",
|
||||||
|
data_end
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
0x0204_0000 > data_end,
|
||||||
|
"data end should be smaller than 0x0203_0000"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue