refactor: replace manual debug_putchar with libkos::println!

Init, storage server, and hello app now use println!/print! macros
instead of manual byte-by-byte UART output.
This commit is contained in:
2026-10-19 01:00:33 +02:00
parent 052d7c4a64
commit 818eaecadd
3 changed files with 27 additions and 58 deletions

View File

@@ -1,5 +1,7 @@
#![no_std]
extern crate alloc;
pub mod adapters;
pub mod filesystem;
pub mod fs;
@@ -20,23 +22,17 @@ fn shared_buf() -> &'static mut [u8] {
unsafe { core::slice::from_raw_parts_mut(SHARED_BUF_VA as *mut u8, SHARED_BUF_SIZE) }
}
fn debug_print(s: &[u8]) {
for &b in s {
syscall::debug_putchar(b);
}
}
pub fn run() -> ! {
debug_print(b"storage: started\n");
libkos::println!("storage: started");
let device = driver_block_virtio::VirtioBlockDevice::new();
let fat16 = fs::fat16::Fat16::mount(device);
if fat16.is_none() {
debug_print(b"storage: FAT16 mount failed\n");
libkos::println!("storage: FAT16 mount failed");
loop { syscall::yield_now(); }
}
let mut fat16 = fat16.unwrap();
debug_print(b"storage: FAT16 mounted\n");
libkos::println!("storage: FAT16 mounted");
let ep = types::bounded::CapSlot::new(0).unwrap();
@@ -53,13 +49,16 @@ pub fn run() -> ! {
let name_len = filename_len.min(32);
name_buf[..name_len].copy_from_slice(&buf[..name_len]);
debug_print(b"storage: read ");
debug_print(&name_buf[..name_len]);
debug_print(b"...");
let name = core::str::from_utf8(&name_buf[..name_len]).unwrap_or("?");
libkos::print!("storage: read {}...", name);
let file_size = read_entire_file(&mut fat16, &name_buf[..name_len], buf);
debug_print(if file_size > 0 { b"ok\n" } else { b"NOT FOUND\n" });
if file_size > 0 {
libkos::println!("ok");
} else {
libkos::println!("NOT FOUND");
}
syscall::send(ep, file_size, 0, 0, 0);
}