refactor: apply newtypes throughout userspace API and display types
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.
This commit is contained in:
@@ -8,10 +8,10 @@ const VQUEUE_VA: usize = 0x21000;
|
||||
const CMDBUF_VA: usize = 0x23000;
|
||||
const PHYSINFO_VA: usize = 0x24000;
|
||||
const FB_VA: usize = 0x100000;
|
||||
const FB_WIDTH: u32 = 640;
|
||||
const FB_HEIGHT: u32 = 480;
|
||||
const FB_WIDTH: types::display::Dimension = types::display::Dimension::new(640);
|
||||
const FB_HEIGHT: types::display::Dimension = types::display::Dimension::new(480);
|
||||
const FB_BPP: usize = 4;
|
||||
const FB_PAGES: usize = (FB_WIDTH as usize * FB_HEIGHT as usize * FB_BPP + 4095) / 4096;
|
||||
const FB_PAGES: usize = (FB_WIDTH.raw() as usize * FB_HEIGHT.raw() as usize * FB_BPP + 4095) / 4096;
|
||||
|
||||
pub fn configure(uart: &Uart, display_pid: ProcessId) {
|
||||
let gpu = match VirtioGpu::probe() {
|
||||
@@ -43,8 +43,8 @@ pub fn configure(uart: &Uart, display_pid: ProcessId) {
|
||||
core::ptr::write_volatile(info, cmd_phys as u64);
|
||||
core::ptr::write_volatile(info.add(1), (cmd_phys + 512) as u64);
|
||||
core::ptr::write_volatile(info.add(2), fb_phys as u64);
|
||||
core::ptr::write_volatile(info.add(3), FB_WIDTH as u64);
|
||||
core::ptr::write_volatile(info.add(4), FB_HEIGHT as u64);
|
||||
core::ptr::write_volatile(info.add(3), FB_WIDTH.raw() as u64);
|
||||
core::ptr::write_volatile(info.add(4), FB_HEIGHT.raw() as u64);
|
||||
}
|
||||
|
||||
gpu.init_device(vq_phys);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use hw_virtio::mmio::{self, DirectMmio};
|
||||
use hw_virtio::queue::{QueueAddrs, VirtioQueue, QUEUE_SIZE};
|
||||
use hw_virtio::block::{self, DmaAddrs};
|
||||
use types::address::{PhysicalAddress, VirtualAddress};
|
||||
|
||||
const SECTOR_SIZE: usize = 512;
|
||||
|
||||
@@ -31,12 +32,12 @@ impl VirtioBlk {
|
||||
|
||||
let dma = unsafe {
|
||||
DmaAddrs {
|
||||
header_pa: core::ptr::addr_of!(REQ_HEADER) as u64,
|
||||
header_va: core::ptr::addr_of_mut!(REQ_HEADER) as usize,
|
||||
status_pa: core::ptr::addr_of!(REQ_STATUS) as u64,
|
||||
status_va: core::ptr::addr_of_mut!(REQ_STATUS) as usize,
|
||||
data_pa: core::ptr::addr_of!(SECTOR_BUF) as u64,
|
||||
data_va: core::ptr::addr_of_mut!(SECTOR_BUF) as usize,
|
||||
header_pa: PhysicalAddress::from_raw(core::ptr::addr_of!(REQ_HEADER) as usize),
|
||||
header_va: VirtualAddress::from_raw(core::ptr::addr_of_mut!(REQ_HEADER) as usize),
|
||||
status_pa: PhysicalAddress::from_raw(core::ptr::addr_of!(REQ_STATUS) as usize),
|
||||
status_va: VirtualAddress::from_raw(core::ptr::addr_of_mut!(REQ_STATUS) as usize),
|
||||
data_pa: PhysicalAddress::from_raw(core::ptr::addr_of!(SECTOR_BUF) as usize),
|
||||
data_va: VirtualAddress::from_raw(core::ptr::addr_of_mut!(SECTOR_BUF) as usize),
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use hw_virtio::mmio::{self, DirectMmio};
|
||||
use hw_virtio::queue::{QueueAddrs, VirtioQueue, QUEUE_SIZE};
|
||||
use hw_virtio::gpu::{self, GpuDmaAddrs};
|
||||
use types::address::{PhysicalAddress, VirtualAddress};
|
||||
use types::display::Dimension;
|
||||
|
||||
pub struct VirtioGpu {
|
||||
mmio: DirectMmio,
|
||||
@@ -20,15 +22,15 @@ impl VirtioGpu {
|
||||
mmio::init_legacy_device(&self.mmio, vqueue_phys, QUEUE_SIZE as u32);
|
||||
}
|
||||
|
||||
pub fn setup_framebuffer(&self, cmd_phys: usize, vq_phys: usize, fb_phys: usize, width: u32, height: u32) {
|
||||
pub fn setup_framebuffer(&self, cmd_phys: usize, vq_phys: usize, fb_phys: usize, width: Dimension, height: Dimension) {
|
||||
let queue = VirtioQueue::new(QueueAddrs::from_base(vq_phys));
|
||||
let dma = GpuDmaAddrs {
|
||||
cmd_pa: cmd_phys as u64,
|
||||
cmd_va: cmd_phys,
|
||||
resp_pa: (cmd_phys + 512) as u64,
|
||||
cmd_pa: PhysicalAddress::from_raw(cmd_phys),
|
||||
cmd_va: VirtualAddress::from_raw(cmd_phys),
|
||||
resp_pa: PhysicalAddress::from_raw(cmd_phys + 512),
|
||||
};
|
||||
gpu::create_2d(&self.mmio, &queue, &dma, 1, width, height);
|
||||
gpu::attach_backing(&self.mmio, &queue, &dma, 1, fb_phys as u64, width * height * 4);
|
||||
gpu::attach_backing(&self.mmio, &queue, &dma, 1, PhysicalAddress::from_raw(fb_phys), width.raw() as u32 * height.raw() as u32 * 4);
|
||||
gpu::set_scanout(&self.mmio, &queue, &dma, 0, 1, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user