diff --git a/loader/src/minielf.rs b/loader/src/minielf.rs index afc678c14..e2ed74dd6 100644 --- a/loader/src/minielf.rs +++ b/loader/src/minielf.rs @@ -102,6 +102,8 @@ impl MiniElf { let mut current_page_addr: usize = 0; let mut previous_addr: usize = 0; let mut last_mapped_xip = 0; + #[cfg(feature = "swap")] + let mut last_swap_page = 0; 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 // the page offsets line up for XIP sections. This assert confirms this necessary pre-condition. @@ -381,6 +383,11 @@ impl MiniElf { flag_defaults }; allocator.map_page(tt, map_phys_addr, virt_page, flags, pid as XousPid); + #[cfg(feature = "swap")] + if ini_type == IniType::IniS { + allocator.map_swap(last_swap_page * 0x1000, virt_page, pid); + last_swap_page += 1; + } last_mapped_xip = virt_page; section_map_phys_offset += PAGE_SIZE; @@ -426,7 +433,7 @@ impl MiniElf { IniType::IniS => { #[cfg(feature = "swap")] { - allocator.processes[pid as usize - 1].swap_root >> 12 + allocator.swap_root[pid as usize - 1] >> 12 } #[cfg(not(feature = "swap"))] {