mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
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:
parent
2c90103fd8
commit
e34dbb4e6f
1 changed files with 68 additions and 50 deletions
|
|
@ -498,11 +498,28 @@ fn swap_handler(
|
|||
let pid = a2 as u8;
|
||||
let vaddr_in_pid = a3;
|
||||
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
|
||||
let paddr_in_swap = match ss.pt_walk(pid as u8, vaddr_in_pid, true) {
|
||||
Some(paddr) => paddr,
|
||||
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();
|
||||
panic!("Couldn't resolve swapped data. Was the page actually swapped?")
|
||||
}
|
||||
|
|
@ -520,8 +537,8 @@ fn swap_handler(
|
|||
)
|
||||
.ok();
|
||||
|
||||
// safety: this is only safe because the pointer we're passed from the kernel is guaranteed to be
|
||||
// a valid u8-page in memory
|
||||
// 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 u8, PAGE_SIZE) };
|
||||
// this is in a retry loop because the SPIM interface can timeout during high bus congestion
|
||||
// periods.
|
||||
|
|
@ -558,6 +575,7 @@ fn swap_handler(
|
|||
}
|
||||
// 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.
|
||||
Some(KernelOp::HardOom) => {
|
||||
// parse the arguments (none, currently)
|
||||
|
|
|
|||
Loading…
Reference in a new issue