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

@@ -4,3 +4,8 @@ version = "0.1.0"
edition = "2024"
[dependencies]
bffs = { path = "../bffs" }
[features]
kernel = []
user = []

9
crates/shared/src/fs.rs Normal file
View File

@@ -0,0 +1,9 @@
pub struct File {
fd: u64,
}
impl File {
pub unsafe fn new(fd: u64) -> Self {
Self { fd }
}
}

View File

@@ -1,3 +1,4 @@
#![no_std]
pub mod fs;
pub mod syscall;

View File

@@ -1,7 +1,10 @@
use core::{alloc::Layout, time::Duration};
use bffs::path::Path;
#[repr(u64)]
pub enum SysCall {
Open = 2,
Alloc = 40,
Dealloc = 41,
Exit = 60,
@@ -14,6 +17,7 @@ pub enum SysCall {
impl From<u64> for SysCall {
fn from(value: u64) -> Self {
match value {
2 => SysCall::Open,
40 => SysCall::Alloc,
41 => SysCall::Dealloc,
60 => SysCall::Exit,
@@ -124,3 +128,12 @@ pub fn dealloc(ptr: *mut u8, layout: core::alloc::Layout) {
syscall!(SysCall::Dealloc, ptr as u64, size as u64, align as u64);
}
}
pub fn open<'a, P: Into<Path<'a>>>(path: P) -> u64 {
unsafe {
let path_str = path.into().as_str();
let ptr = path_str.as_ptr();
let size = path_str.len();
let (fd, ..) = syscall!(SysCall::Open, ptr as u64, size as u64);
fd
}
}