From 87e32687f1f9490027437bb5099c1d2819d37e70 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 4 May 2024 01:50:13 +0800 Subject: [PATCH] allow xous-susres to function with swap enabled the reason we're doing this is because the pre-emption timer lives in this crate too. We don't (can't!) suspend/resume with swap (yet!) but the pre-emption timer got stuck in susres so it can be directly turned off without message passing/context switching during the suspend and resume ops. --- services/xous-susres/Cargo.toml | 1 + services/xous-susres/src/main.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/services/xous-susres/Cargo.toml b/services/xous-susres/Cargo.toml index 4b60a81da..f0343feed 100644 --- a/services/xous-susres/Cargo.toml +++ b/services/xous-susres/Cargo.toml @@ -30,6 +30,7 @@ utralib = { version = "0.1.24", optional = true, default-features = false } precursor = ["utralib/precursor"] hosted = ["utralib/hosted"] renode = ["utralib/renode"] +swap = [] sus_reboot = [ ] # when selected, suspend triggers an immediate reboot instead of suspend. For testing only. debugprint = [] diff --git a/services/xous-susres/src/main.rs b/services/xous-susres/src/main.rs index 9a1016187..068d6c41f 100644 --- a/services/xous-susres/src/main.rs +++ b/services/xous-susres/src/main.rs @@ -144,6 +144,7 @@ mod implementation { .expect("couldn't map SusRes CSR range"); // note that mapping a page zeroes it out. Plus, this should have been zero'd by the bootloader. + #[cfg(not(feature = "swap"))] let marker = xous::syscall::map_memory( xous::MemoryAddress::new(0x4100_0000 - 0x3000), /* this is a special, hard-coded location; * 0x2000 is the size of the bootloader's @@ -153,6 +154,14 @@ mod implementation { xous::MemoryFlags::R | xous::MemoryFlags::W, ) .expect("couldn't map clean suspend page"); + #[cfg(feature = "swap")] + let marker = xous::syscall::map_memory( + None, // map a dummy page -- we need this process for the preemption timer + None, + 4096, + xous::MemoryFlags::R | xous::MemoryFlags::W, + ) + .expect("couldn't map clean suspend page"); let seed_csr = xous::syscall::map_memory( xous::MemoryAddress::new(utra::seed::HW_SEED_BASE),