mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
commit
5b60713c02
2 changed files with 18 additions and 1 deletions
|
|
@ -92,6 +92,7 @@ impl MiniElf {
|
||||||
let mut current_page_addr: usize = 0;
|
let mut current_page_addr: usize = 0;
|
||||||
let mut previous_addr: usize = 0;
|
let mut previous_addr: usize = 0;
|
||||||
let mut last_mapped_xip = 0;
|
let mut last_mapped_xip = 0;
|
||||||
|
let mut last_mapped_swap_virt = 0; // track the last virtual address mapped to swap, to catch gaps
|
||||||
let image_phys_base = allocator.base_addr as usize + self.load_offset as usize;
|
let image_phys_base = allocator.base_addr as usize + self.load_offset as usize;
|
||||||
// It is a requirement that the image generator lay out the artifacts on disk such that
|
// It is a requirement that the image generator lay out the artifacts on disk such that
|
||||||
// the page offsets line up for XIP sections. This assert confirms this necessary pre-condition.
|
// the page offsets line up for XIP sections. This assert confirms this necessary pre-condition.
|
||||||
|
|
@ -365,7 +366,21 @@ impl MiniElf {
|
||||||
allocator.map_page(tt, map_phys_addr, virt_page, flags, pid as XousPid);
|
allocator.map_page(tt, map_phys_addr, virt_page, flags, pid as XousPid);
|
||||||
#[cfg(feature = "swap")]
|
#[cfg(feature = "swap")]
|
||||||
if ini_type == IniType::IniS {
|
if ini_type == IniType::IniS {
|
||||||
|
// add a check for the case that the virt_page skipped an address since the last
|
||||||
|
// mapping: this can happen if there is a gap between sections that exceeds a page
|
||||||
|
// size.
|
||||||
|
if last_mapped_swap_virt != 0 && virt_page - last_mapped_swap_virt > PAGE_SIZE {
|
||||||
|
let skip_pages = (virt_page - last_mapped_swap_virt) / PAGE_SIZE - 1;
|
||||||
|
if VDBG {
|
||||||
|
println!(
|
||||||
|
" Skipping {} swap pages due to gap in incoming MiniELF!",
|
||||||
|
skip_pages
|
||||||
|
);
|
||||||
|
}
|
||||||
|
allocator.last_swap_page += skip_pages;
|
||||||
|
}
|
||||||
allocator.map_swap(allocator.last_swap_page * 0x1000, virt_page, pid);
|
allocator.map_swap(allocator.last_swap_page * 0x1000, virt_page, pid);
|
||||||
|
last_mapped_swap_virt = virt_page;
|
||||||
allocator.last_swap_page += 1;
|
allocator.last_swap_page += 1;
|
||||||
}
|
}
|
||||||
last_mapped_xip = virt_page;
|
last_mapped_xip = virt_page;
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,9 @@ pub fn phase_2(cfg: &mut BootConfig, env_variables: EnvVariables) {
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "debug-print", not(feature = "verilator-only")))]
|
#[cfg(all(feature = "debug-print", not(feature = "verilator-only")))]
|
||||||
// print the kernel's page table mappings as a sanity check on the loader
|
// print the kernel's page table mappings as a sanity check on the loader
|
||||||
debug::print_pagetable(cfg.processes[0].satp);
|
if VDBG {
|
||||||
|
debug::print_pagetable(cfg.processes[0].satp);
|
||||||
|
}
|
||||||
|
|
||||||
// Mark pages used by suspend/resume, otherwise they will be handed out to userspace.
|
// Mark pages used by suspend/resume, otherwise they will be handed out to userspace.
|
||||||
// However, when not doing suspend/resume, it's safe to hand this out because it's always zeroized
|
// However, when not doing suspend/resume, it's safe to hand this out because it's always zeroized
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue