feat: add Platform::map_shared and wire memory delegation to page mapping

This commit is contained in:
2026-10-18 01:30:23 +02:00
parent 4844b6c2d2
commit dcadb83088
3 changed files with 36 additions and 5 deletions

View File

@@ -39,10 +39,22 @@ impl<P: Platform> Kernel<P> {
Err(e) => return SyscallOutcome::Complete(SyscallResult::Error(e)), Err(e) => return SyscallOutcome::Complete(SyscallResult::Error(e)),
}; };
match self.grant_cap(target_pid, resource, restricted) { if let Err(e) = self.grant_cap(target_pid, resource.clone(), restricted) {
Ok(_) => SyscallOutcome::Complete(SyscallResult::Ok), return SyscallOutcome::Complete(SyscallResult::Error(e));
Err(e) => SyscallOutcome::Complete(SyscallResult::Error(e)),
} }
if let domain::resource::Resource::Memory(region_id) = &resource {
if let Some(region) = self.regions.get(*region_id) {
self.platform.map_shared(
target_pid,
region.base(),
region.size(),
restricted,
);
}
}
SyscallOutcome::Complete(SyscallResult::Ok)
} }
pub(crate) fn handle_revoke( pub(crate) fn handle_revoke(

View File

@@ -2,8 +2,10 @@ use domain::memory::MemoryRegion;
use domain::thread::SavedContext; use domain::thread::SavedContext;
use platform::Platform; use platform::Platform;
use types::{ use types::{
address::{EntryPoint, StackPointer}, address::{EntryPoint, PhysicalAddress, StackPointer},
bounded::PageCount,
id::{CoreId, IrqId, ProcessId}, id::{CoreId, IrqId, ProcessId},
permission::PermissionSet,
time::{Ticks, TimerDuration}, time::{Ticks, TimerDuration},
}; };
@@ -46,4 +48,12 @@ impl Platform for MockPlatform {
fn num_cores(&self) -> u8 { fn num_cores(&self) -> u8 {
self.cores self.cores
} }
fn map_shared(
&mut self,
_process: ProcessId,
_base: PhysicalAddress,
_size: PageCount,
_permissions: PermissionSet,
) {
}
} }

View File

@@ -2,8 +2,10 @@
use domain::{memory::MemoryRegion, thread::SavedContext}; use domain::{memory::MemoryRegion, thread::SavedContext};
use types::{ use types::{
address::{EntryPoint, StackPointer}, address::{EntryPoint, PhysicalAddress, StackPointer},
bounded::PageCount,
id::{CoreId, IrqId, ProcessId}, id::{CoreId, IrqId, ProcessId},
permission::PermissionSet,
time::{Ticks, TimerDuration}, time::{Ticks, TimerDuration},
}; };
@@ -20,4 +22,11 @@ pub trait Platform {
fn send_ipi(&mut self, target: CoreId); fn send_ipi(&mut self, target: CoreId);
fn core_id(&self) -> CoreId; fn core_id(&self) -> CoreId;
fn num_cores(&self) -> u8; fn num_cores(&self) -> u8;
fn map_shared(
&mut self,
process: ProcessId,
base: PhysicalAddress,
size: PageCount,
permissions: PermissionSet,
);
} }