mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
handle vex-ii a/d flags and error gracefully on page re-allocates
1. Instead of panicing when a page is re-requested, return an error message to the caller. This allows us to have the UART pre-allocated by the loader and the kernel to request it prophylactically 2. add A/D flags for R/W pages in vexii-testing. This is a work-around until we have proper A/D tracking in the page lifecycle mechanism.
This commit is contained in:
parent
de8ddbf9c2
commit
52abe83b74
1 changed files with 23 additions and 1 deletions
|
|
@ -56,12 +56,33 @@ impl core::fmt::Debug for MemoryMapping {
|
|||
|
||||
fn translate_flags(req_flags: MemoryFlags) -> MMUFlags {
|
||||
let mut flags = MMUFlags::NONE;
|
||||
|
||||
// TODO for vex-ii:
|
||||
// Vexii implement A-flag. In this case, we should not just be setting every
|
||||
// readable page to "A", we should add a handler in the IRQ handler that sets "A"
|
||||
// when the page is actually read.
|
||||
#[cfg(not(feature = "vexii-test"))]
|
||||
if req_flags & xous_kernel::MemoryFlags::R == xous_kernel::MemoryFlags::R {
|
||||
flags |= MMUFlags::R;
|
||||
}
|
||||
#[cfg(feature = "vexii-test")]
|
||||
if req_flags & xous_kernel::MemoryFlags::R == xous_kernel::MemoryFlags::R {
|
||||
flags |= MMUFlags::R | MMUFlags::A;
|
||||
}
|
||||
|
||||
// TODO for vex-ii:
|
||||
// Vexii implement D-flag. In this case, we should not just be setting every
|
||||
// writeable page to "D", we should add a handler in the IRQ handler that sets "D"
|
||||
// when the page is actually writte.
|
||||
#[cfg(not(feature = "vexii-test"))]
|
||||
if req_flags & xous_kernel::MemoryFlags::W == xous_kernel::MemoryFlags::W {
|
||||
flags |= MMUFlags::W;
|
||||
}
|
||||
#[cfg(feature = "vexii-test")]
|
||||
if req_flags & xous_kernel::MemoryFlags::W == xous_kernel::MemoryFlags::W {
|
||||
flags |= MMUFlags::W | MMUFlags::D;
|
||||
}
|
||||
|
||||
if req_flags & xous_kernel::MemoryFlags::X == xous_kernel::MemoryFlags::X {
|
||||
flags |= MMUFlags::X;
|
||||
}
|
||||
|
|
@ -650,7 +671,8 @@ pub fn map_page_inner(
|
|||
|
||||
// Ensure the entry hasn't already been mapped.
|
||||
if unsafe { l0_pt.add(vpn0).read_volatile() } & 1 != 0 {
|
||||
panic!("Page {:08x} already allocated!", virt);
|
||||
klog!("Page {:08x} already allocated!", virt);
|
||||
return Err(xous_kernel::Error::MemoryInUse);
|
||||
}
|
||||
unsafe {
|
||||
l0_pt.add(vpn0).write_volatile(
|
||||
|
|
|
|||
Loading…
Reference in a new issue