implement a demonstration of successful map decoding of the spi flash request

this just puts dummy data in, next set of commits will do "live"
ROM access.
This commit is contained in:
bunnie 2025-05-15 11:58:03 +08:00
parent 2c90103fd8
commit e34dbb4e6f

View file

@ -498,11 +498,28 @@ fn swap_handler(
let pid = a2 as u8; let pid = a2 as u8;
let vaddr_in_pid = a3; let vaddr_in_pid = a3;
let vaddr_in_swap = a4; let vaddr_in_swap = a4;
if (vaddr_in_pid & xous::arch::MMAP_VIRT_BASE) == xous::arch::MMAP_VIRT_BASE {
// data is in the SPINOR, which is by definition located at exactly the offset
// indicated by the offset from MMAP_VIRT_BASE
// safety: this is only safe because the pointer we're passed from the kernel is guaranteed to
// be a valid u8-page in memory
let buf = unsafe { core::slice::from_raw_parts_mut(vaddr_in_swap as *mut u32, PAGE_SIZE) };
// return some dummy data
let indicator = vaddr_in_pid as usize & 0xF_F000;
for (i, d) in buf[0..32].iter_mut().enumerate() {
*d = i as u32 | (0xf00f_0000 + indicator as u32);
}
} else {
// walk the PT to find the swap data, and remove it from the swap PT // walk the PT to find the swap data, and remove it from the swap PT
let paddr_in_swap = match ss.pt_walk(pid as u8, vaddr_in_pid, true) { let paddr_in_swap = match ss.pt_walk(pid as u8, vaddr_in_pid, true) {
Some(paddr) => paddr, Some(paddr) => paddr,
None => { None => {
writeln!(DebugUart {}, "Couldn't resolve swapped data. Was the page actually swapped?") writeln!(
DebugUart {},
"Couldn't resolve swapped data. Was the page actually swapped?"
)
.ok(); .ok();
panic!("Couldn't resolve swapped data. Was the page actually swapped?") panic!("Couldn't resolve swapped data. Was the page actually swapped?")
} }
@ -520,8 +537,8 @@ fn swap_handler(
) )
.ok(); .ok();
// safety: this is only safe because the pointer we're passed from the kernel is guaranteed to be // safety: this is only safe because the pointer we're passed from the kernel is guaranteed to
// a valid u8-page in memory // be a valid u8-page in memory
let buf = unsafe { core::slice::from_raw_parts_mut(vaddr_in_swap as *mut u8, PAGE_SIZE) }; let buf = unsafe { core::slice::from_raw_parts_mut(vaddr_in_swap as *mut u8, PAGE_SIZE) };
// this is in a retry loop because the SPIM interface can timeout during high bus congestion // this is in a retry loop because the SPIM interface can timeout during high bus congestion
// periods. // periods.
@ -558,6 +575,7 @@ fn swap_handler(
} }
// at this point, the `buf` has our desired data, we're done, modulo updating the count. // at this point, the `buf` has our desired data, we're done, modulo updating the count.
} }
}
// HardOom handling will evict any and all pages that it can -- it does no filtering. // HardOom handling will evict any and all pages that it can -- it does no filtering.
Some(KernelOp::HardOom) => { Some(KernelOp::HardOom) => {
// parse the arguments (none, currently) // parse the arguments (none, currently)