Skip to content

Commit 582206d

Browse files
committed
Write to lower 1GB of free regions in lower_memory_free test
1 parent 0c8a15b commit 582206d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/test_kernels/lower_memory_free/src/bin/lower_memory_free.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use bootloader_api::{
77
use test_kernel_lower_memory_free::{exit_qemu, QemuExitCode};
88

99
const LOWER_MEMORY_END_PAGE: u64 = 0x0010_0000;
10+
const WRITE_TEST_UNTIL: u64 = 0x4000_0000;
1011

1112
pub const BOOTLOADER_CONFIG: BootloaderConfig = {
1213
let mut config = BootloaderConfig::new_default();
@@ -34,16 +35,17 @@ fn kernel_main(boot_info: &'static mut BootInfo) -> ! {
3435
.unwrap();
3536
if region.kind == MemoryRegionKind::Usable && region.start < LOWER_MEMORY_END_PAGE {
3637
let end = core::cmp::min(region.end, LOWER_MEMORY_END_PAGE);
37-
38+
let pages = (end - region.start) / 4096;
39+
count += pages;
40+
}
41+
if region.kind == MemoryRegionKind::Usable && region.start < WRITE_TEST_UNTIL {
42+
let end = core::cmp::min(region.end, WRITE_TEST_UNTIL);
3843
// ensure region is actually writable
3944
let addr = phys_mem_offset + region.start;
4045
let size = end - region.start;
4146
unsafe {
4247
core::ptr::write_bytes(addr as *mut u8, 0xff, size as usize);
4348
}
44-
45-
let pages = (end - region.start) / 4096;
46-
count += pages;
4749
}
4850
}
4951

0 commit comments

Comments
 (0)