Add the rust std as a custom sysroot

This commit is contained in:
2026-03-17 18:29:00 +01:00
parent 404a681254
commit fadecc7c95
47 changed files with 806 additions and 320 deletions

View File

@@ -9,9 +9,9 @@ use log::info;
use shared::syscall::SysCall;
use crate::{
KBD_DRIVER, MOUSE_DRIVER,
boot::sbi::{ExtensionID, TimerFunctionID},
clear_csr,
drivers::{keyboard::KBD_DRIVER, mouse::MOUSE_DRIVER},
process::{ExecutionContext, exit_process, sleep},
read_csr,
riscv::{disable_interrupt, dump_cpu},
@@ -160,6 +160,15 @@ unsafe extern "C" fn supervisor_trap_handler(
unsafe { (*interrupt_state).a[0] = fd as u64 };
}
SysCall::Close => {
let fd = a1;
let mut scheduler = SCHEDULER.lock();
let current_process = scheduler.get_current_process();
let mut vnode = current_process.fd_table[fd as usize].take().unwrap();
vnode.close();
}
SysCall::Write => {
let fd = a1;
let buf =
@@ -168,7 +177,8 @@ unsafe extern "C" fn supervisor_trap_handler(
let mut scheduler = SCHEDULER.lock();
let current_process = scheduler.get_current_process();
let vnode = current_process.fd_table[fd as usize].as_mut().unwrap();
vnode.write(buf).unwrap();
let res = vnode.write(buf).unwrap();
unsafe { (*interrupt_state).a[0] = res as u64 };
}
SysCall::Read => {
let fd = a1;
@@ -182,6 +192,8 @@ unsafe extern "C" fn supervisor_trap_handler(
if res == 0 && !buf.is_empty() {
loop_syscall(interrupt_state);
scheduler.schedule(&mut interrupt_state);
} else {
unsafe { (*interrupt_state).a[0] = res as u64 };
}
}
SysCall::Seek => {
@@ -197,6 +209,17 @@ unsafe extern "C" fn supervisor_trap_handler(
let vnode = current_process.fd_table[fd as usize].as_mut().unwrap();
vnode.seek(seek).unwrap();
}
SysCall::Spawn => {
let path = unsafe { str::from_raw_parts(a1 as *const u8, a2 as usize) };
let mut scheduler = SCHEDULER.lock();
scheduler.create_process_from_file(path, 0, core::ptr::null());
}
SysCall::ExecVE => {
// let path = unsafe { str::from_raw_parts(a1 as *const u8, a2 as usize) };
// let mut scheduler = SCHEDULER.lock();
// scheduler.create_process_from_file(path, &[]);
unimplemented!("ExecVE is not implemented")
}
SysCall::Alloc => {
let layout = Layout::from_size_align(a1 as usize, a2 as usize).unwrap();
// Allocate memory and put the pointer in a0