58 lines
1.4 KiB
Rust
58 lines
1.4 KiB
Rust
use domain::memory::MemoryRegion;
|
|
use platform::Platform;
|
|
use types::{
|
|
address::{EntryPoint, PhysicalAddress, StackPointer},
|
|
bounded::PageCount,
|
|
id::{CoreId, IrqId, ProcessId},
|
|
permission::PermissionSet,
|
|
time::{Ticks, TimerDuration},
|
|
};
|
|
|
|
pub struct MockPlatform {
|
|
ticks: Ticks,
|
|
core: CoreId,
|
|
cores: u8,
|
|
}
|
|
|
|
impl MockPlatform {
|
|
pub fn new(num_cores: u8) -> Self {
|
|
Self {
|
|
ticks: Ticks::from_raw(0),
|
|
core: CoreId::from_raw(0),
|
|
cores: num_cores,
|
|
}
|
|
}
|
|
|
|
pub fn set_ticks(&mut self, ticks: Ticks) {
|
|
self.ticks = ticks;
|
|
}
|
|
}
|
|
|
|
impl Platform for MockPlatform {
|
|
fn configure_protection(&mut self, _process: ProcessId, _regions: &[MemoryRegion]) {}
|
|
fn enable_user_mode(&mut self, _entry: EntryPoint, _stack: StackPointer) -> ! {
|
|
loop {}
|
|
}
|
|
fn set_timer(&mut self, _duration: TimerDuration) {}
|
|
fn current_ticks(&self) -> Ticks {
|
|
self.ticks
|
|
}
|
|
fn mask_irq(&mut self, _irq: IrqId) {}
|
|
fn unmask_irq(&mut self, _irq: IrqId) {}
|
|
fn send_ipi(&mut self, _target: CoreId) {}
|
|
fn core_id(&self) -> CoreId {
|
|
self.core
|
|
}
|
|
fn num_cores(&self) -> u8 {
|
|
self.cores
|
|
}
|
|
fn map_shared(
|
|
&mut self,
|
|
_process: ProcessId,
|
|
_base: PhysicalAddress,
|
|
_size: PageCount,
|
|
_permissions: PermissionSet,
|
|
) {
|
|
}
|
|
}
|