add routines for manipulating the dirty field

This commit is contained in:
bunnie 2025-05-16 19:03:02 +08:00
parent 769616e266
commit 250bf4553e

View file

@ -4,6 +4,7 @@ use core::mem::size_of;
use aes_gcm_siv::Tag;
use crate::PAGE_SIZE;
use crate::SWAP_FLG_DIRTY;
use crate::SWAP_FLG_WIRED;
use crate::SWAPPER_PID;
@ -132,6 +133,12 @@ impl SwapAlloc {
pub fn is_wired(&self) -> bool { (self.vpn & SWAP_FLG_WIRED) != 0 }
pub fn set_dirty(&mut self) { self.vpn |= SWAP_FLG_DIRTY; }
pub fn clear_dirty(&mut self) { self.vpn &= !SWAP_FLG_DIRTY; }
pub fn is_dirty(&self) -> bool { self.vpn & SWAP_FLG_DIRTY == SWAP_FLG_DIRTY }
pub fn is_valid(&self) -> bool { self.vpn != 0 }
pub fn raw_pid(&self) -> u8 { self.vpn as u8 }