Sync computers

This commit is contained in:
2026-02-28 18:55:10 +01:00
parent c3eb93e701
commit 9a983c56f3
29 changed files with 1564 additions and 28 deletions

View File

@@ -2,12 +2,17 @@
//!
//! Implements a minimal disk backend and exposes a global FILE_SYSTEM used by
//! the kernel to load user binaries.
use core::{cell::UnsafeCell, ops::Deref};
use core::{
cell::{LazyCell, UnsafeCell},
ops::Deref,
};
use bffs::{
io::{IoBase, Read, Seek},
path::Path,
Fat32FileSystem,
};
use hashbrown::HashMap;
const DISK_ADDR: *const u8 = 0x9000_0000 as *const _;
@@ -79,10 +84,20 @@ impl Read for Disk {
return Ok(0);
}
let size = usize::min(buf.len(), (self.size - self.pos) as usize);
(0..size).for_each(|i| {
buf[i] = unsafe { *DISK_ADDR.byte_add(i + self.pos as usize) };
});
unsafe {
core::ptr::copy_nonoverlapping(
DISK_ADDR.byte_add(self.pos as usize),
buf.as_mut_ptr(),
size,
);
}
self.pos += size as u64;
Ok(size)
}
}
pub struct KernelFDTable(LazyCell<HashMap<u64, Path<'static>>>);
unsafe impl Sync for KernelFDTable {}
pub static KERNEL_FILE_DESCRIPTOR_TABLE: KernelFDTable = KernelFDTable(LazyCell::new(HashMap::new));