style: cargo fmt kernel crates

This commit is contained in:
2026-10-26 19:07:54 +01:00
parent 818eaecadd
commit 1c04ddf909
50 changed files with 995 additions and 499 deletions

View File

@@ -6,7 +6,9 @@ pub struct Uart {
impl Uart {
pub fn new() -> Self {
Self { base: board::UART_BASE }
Self {
base: board::UART_BASE,
}
}
pub fn put_char(&self, byte: u8) {
@@ -30,7 +32,11 @@ impl Uart {
let mut i = 0;
while value > 0 {
let digit = (value & 0xF) as u8;
buf[i] = if digit < 10 { b'0' + digit } else { b'a' + digit - 10 };
buf[i] = if digit < 10 {
b'0' + digit
} else {
b'a' + digit - 10
};
value >>= 4;
i += 1;
}

View File

@@ -1,6 +1,6 @@
use hw_virtio::mmio::{self, DirectMmio};
use hw_virtio::queue::{QueueAddrs, VirtioQueue, QUEUE_SIZE};
use hw_virtio::block::{self, DmaAddrs};
use hw_virtio::mmio::{self, DirectMmio};
use hw_virtio::queue::{QUEUE_SIZE, QueueAddrs, VirtioQueue};
use types::address::{PhysicalAddress, VirtualAddress};
const SECTOR_SIZE: usize = 512;
@@ -11,7 +11,11 @@ struct VirtqMem {
}
static mut VQUEUE: VirtqMem = VirtqMem { _data: [0; 8192] };
static mut REQ_HEADER: block::BlockReqHeader = block::BlockReqHeader { req_type: 0, reserved: 0, sector: 0 };
static mut REQ_HEADER: block::BlockReqHeader = block::BlockReqHeader {
req_type: 0,
reserved: 0,
sector: 0,
};
static mut REQ_STATUS: u8 = 0xFF;
static mut SECTOR_BUF: [u8; SECTOR_SIZE] = [0; SECTOR_SIZE];

View File

@@ -1,6 +1,6 @@
use hw_virtio::mmio::{self, DirectMmio};
use hw_virtio::queue::{QueueAddrs, VirtioQueue, QUEUE_SIZE};
use hw_virtio::gpu::{self, GpuDmaAddrs};
use hw_virtio::mmio::{self, DirectMmio};
use hw_virtio::queue::{QUEUE_SIZE, QueueAddrs, VirtioQueue};
use types::address::{PhysicalAddress, VirtualAddress};
use types::display::Dimension;
@@ -26,7 +26,14 @@ 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: Dimension, height: Dimension) -> bool {
pub fn setup_framebuffer(
&self,
cmd_phys: usize,
vq_phys: usize,
fb_phys: usize,
width: Dimension,
height: Dimension,
) -> bool {
let queue = VirtioQueue::new(QueueAddrs::from_base(vq_phys));
let dma = GpuDmaAddrs {
cmd_pa: PhysicalAddress::from_raw(cmd_phys),
@@ -34,7 +41,14 @@ impl VirtioGpu {
resp_pa: PhysicalAddress::from_raw(cmd_phys + 512),
};
let ok1 = gpu::create_2d(&self.mmio, &queue, &dma, 1, width, height);
let ok2 = gpu::attach_backing(&self.mmio, &queue, &dma, 1, PhysicalAddress::from_raw(fb_phys), width.raw() as u32 * height.raw() as u32 * 4);
let ok2 = gpu::attach_backing(
&self.mmio,
&queue,
&dma,
1,
PhysicalAddress::from_raw(fb_phys),
width.raw() as u32 * height.raw() as u32 * 4,
);
let ok3 = gpu::set_scanout(&self.mmio, &queue, &dma, 0, 1, width, height);
ok1 && ok2 && ok3
}