mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add functions for marking pages as dirty in the RPT
this is what ultimately allows us to decide whether or not a page can be flushed from memory safely
This commit is contained in:
parent
432c2a528e
commit
75073aab99
1 changed files with 34 additions and 0 deletions
|
|
@ -389,6 +389,40 @@ impl MemoryManager {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(baremetal)]
|
||||
#[cfg(feature = "swap")]
|
||||
pub fn mark_rpt_dirty(&mut self, paddr: usize) -> Result<(), xous_kernel::Error> {
|
||||
unsafe {
|
||||
let offset = (paddr - self.ram_start) / PAGE_SIZE;
|
||||
if MEMORY_ALLOCATIONS[offset].is_none() {
|
||||
Err(xous_kernel::Error::BadAddress)
|
||||
} else {
|
||||
MEMORY_ALLOCATIONS[offset].set_dirty();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(baremetal)]
|
||||
#[cfg(feature = "swap")]
|
||||
pub fn mark_rpt_clean(&mut self, paddr: usize) -> Result<(), xous_kernel::Error> {
|
||||
unsafe {
|
||||
let offset = (paddr - self.ram_start) / PAGE_SIZE;
|
||||
if MEMORY_ALLOCATIONS[offset].is_none() {
|
||||
Err(xous_kernel::Error::BadAddress)
|
||||
} else {
|
||||
MEMORY_ALLOCATIONS[offset].clear_dirty();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(baremetal)]
|
||||
#[cfg(feature = "swap")]
|
||||
pub fn rpt_is_dirty(&self, paddr: usize) -> bool {
|
||||
unsafe { MEMORY_ALLOCATIONS[(paddr - self.ram_start) / PAGE_SIZE].is_dirty() }
|
||||
}
|
||||
|
||||
#[cfg(baremetal)]
|
||||
#[cfg(feature = "swap")]
|
||||
/// Similar to alloc_page(), but this implementation takes the vaddr being allocated so we
|
||||
|
|
|
|||
Loading…
Reference in a new issue