Every syscall stub now uses proper types from types/ — CapSlot,
EntryPoint, StackPointer, VirtualAddress, PageCount, ProcessId,
PermissionSet, Ticks. The compiler prevents swapping entry/stack,
passing a ProcessId where a CapSlot is expected, or using an
address as a page count.
New display types in types/display.rs:
- Color(u32) with rgb() constructor
- ScreenCoord(u16) for x/y positions
- Dimension(u16) for width/height
Updated throughout:
- userspace/syscall.rs: all params typed, returns Option instead
of sentinel usize::MAX
- server-framework: endpoint param is CapSlot
- port-framebuffer: trait uses Color, ScreenCoord, Dimension
- hw-virtio: DmaAddrs uses PhysicalAddress/VirtualAddress,
GPU commands use Dimension
- All servers, drivers, bins, apps updated for new signatures
- permission-manager: process field uses ProcessId
- PermissionSet: added bits() accessor
89 tests pass, full QEMU boot verified.
78 lines
2.5 KiB
Rust
78 lines
2.5 KiB
Rust
use server_framework::{Decode, Encode};
|
|
use types::display::{Color, Dimension, ScreenCoord};
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum DisplayRequest {
|
|
DrawRect { x: ScreenCoord, y: ScreenCoord, w: Dimension, h: Dimension, color: Color },
|
|
Clear { color: Color },
|
|
Flush,
|
|
GetDimensions,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum DisplayResponse {
|
|
Ok,
|
|
Dimensions { width: Dimension, height: Dimension },
|
|
Error,
|
|
}
|
|
|
|
impl Encode for DisplayRequest {
|
|
fn encode(&self) -> [usize; 4] {
|
|
match self {
|
|
DisplayRequest::DrawRect { x, y, w, h, color } => {
|
|
let xy = (x.raw() as usize) | ((y.raw() as usize) << 16);
|
|
let wh = (w.raw() as usize) | ((h.raw() as usize) << 16);
|
|
[0, xy, wh, color.raw() as usize]
|
|
}
|
|
DisplayRequest::Clear { color } => [1, color.raw() as usize, 0, 0],
|
|
DisplayRequest::Flush => [2, 0, 0, 0],
|
|
DisplayRequest::GetDimensions => [3, 0, 0, 0],
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Decode for DisplayRequest {
|
|
fn decode(words: [usize; 4]) -> Option<Self> {
|
|
match words[0] {
|
|
0 => {
|
|
let x = ScreenCoord::new((words[1] & 0xFFFF) as u16);
|
|
let y = ScreenCoord::new(((words[1] >> 16) & 0xFFFF) as u16);
|
|
let w = Dimension::new((words[2] & 0xFFFF) as u16);
|
|
let h = Dimension::new(((words[2] >> 16) & 0xFFFF) as u16);
|
|
let color = Color::from_raw(words[3] as u32);
|
|
Some(DisplayRequest::DrawRect { x, y, w, h, color })
|
|
}
|
|
1 => Some(DisplayRequest::Clear { color: Color::from_raw(words[1] as u32) }),
|
|
2 => Some(DisplayRequest::Flush),
|
|
3 => Some(DisplayRequest::GetDimensions),
|
|
_ => None,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Encode for DisplayResponse {
|
|
fn encode(&self) -> [usize; 4] {
|
|
match self {
|
|
DisplayResponse::Ok => [0, 0, 0, 0],
|
|
DisplayResponse::Dimensions { width, height } => {
|
|
[1, width.raw() as usize, height.raw() as usize, 0]
|
|
}
|
|
DisplayResponse::Error => [2, 0, 0, 0],
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Decode for DisplayResponse {
|
|
fn decode(words: [usize; 4]) -> Option<Self> {
|
|
match words[0] {
|
|
0 => Some(DisplayResponse::Ok),
|
|
1 => Some(DisplayResponse::Dimensions {
|
|
width: Dimension::new(words[1] as u16),
|
|
height: Dimension::new(words[2] as u16),
|
|
}),
|
|
2 => Some(DisplayResponse::Error),
|
|
_ => None,
|
|
}
|
|
}
|
|
}
|