diff --git a/loader/src/bootconfig.rs b/loader/src/bootconfig.rs index 98bfe99d0..5cb6047eb 100644 --- a/loader/src/bootconfig.rs +++ b/loader/src/bootconfig.rs @@ -70,10 +70,14 @@ pub struct BootConfig { #[cfg(feature = "swap")] pub swap: Option<&'static SwapDescriptor>, - /// Offset of the current free page in swap + /// Offset of the current free page in swap, used in phase 1 #[cfg(feature = "swap")] pub swap_free_page: usize, + #[cfg(feature = "swap")] + /// Offset of the current page in swap, used in phase 2 + pub last_swap_page: usize, + /// root swap page table of the process #[cfg(feature = "swap")] pub swap_root: &'static mut [usize], @@ -102,6 +106,8 @@ impl Default for BootConfig { #[cfg(feature = "swap")] swap_free_page: 0, #[cfg(feature = "swap")] + last_swap_page: 0, + #[cfg(feature = "swap")] swap_root: Default::default(), } } diff --git a/loader/src/minielf.rs b/loader/src/minielf.rs index 32151708a..98e0dad09 100644 --- a/loader/src/minielf.rs +++ b/loader/src/minielf.rs @@ -102,8 +102,6 @@ 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. @@ -371,8 +369,8 @@ impl MiniElf { 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; + allocator.map_swap(allocator.last_swap_page * 0x1000, virt_page, pid); + allocator.last_swap_page += 1; } last_mapped_xip = virt_page;