feat: implement capability-based memory management foundation

This commit is contained in:
Faynot
2026-05-05 01:30:16 +03:00
parent a45587042b
commit d542b5586d
8 changed files with 200 additions and 80 deletions

View File

@@ -0,0 +1,25 @@
use crate::cap::{Capability, CapObject, Relation, CapRights};
use crate::mem::address::PhysAddr;
pub struct PMActor {
pub root_untyped: Capability,
pub managed_range: (PhysAddr, PhysAddr),
}
impl PMActor {
pub fn carve_region(&self, offset: usize, size: usize) -> Capability {
if let CapObject::Memory { phys, .. } = self.root_untyped.object {
Capability {
object: CapObject::Memory {
phys: PhysAddr(phys.0 + offset as u64),
size_pages: size / 4096,
},
rights: CapRights::READ | CapRights::WRITE | CapRights::GRANT,
relation: Relation::Strong,
token_sig: 0xDEAD_BEEF,
}
} else {
panic!("PM: Root is not memory!");
}
}
}