Add debug infos on panic

This commit is contained in:
2026-03-22 14:27:56 +01:00
parent 897775f63a
commit 15ecefb5fb
14 changed files with 282 additions and 50 deletions

View File

@@ -1,10 +1,5 @@
use core::{alloc::Layout, time::Duration};
use bffs::path::Path;
use io::SeekFrom;
use crate::fs::File;
#[repr(u64)]
pub enum SysCall {
Read = 0,
@@ -100,10 +95,12 @@ macro_rules! syscall {
};
}
pub fn exit() {
pub fn exit() -> ! {
unsafe {
syscall!(SysCall::Exit);
}
#[allow(clippy::empty_loop)]
loop {}
}
pub fn sleep(duration: Duration) {
@@ -128,6 +125,8 @@ pub fn write_int_temp(content: u64) {
}
}
#[allow(unknown_lints)]
#[allow(fuzzy_provenance_casts)]
pub fn alloc(layout: Layout) -> *mut u8 {
unsafe {
let size = layout.size();
@@ -143,13 +142,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<P: AsRef<Path>>(path: P) -> File {
pub fn open(path: &str) -> u64 {
unsafe {
let path_str = path.as_ref().as_str();
let ptr = path_str.as_ptr();
let size = path_str.len();
let ptr = path.as_ptr();
let size = path.len();
let (fd, ..) = syscall!(SysCall::Open, ptr as u64, size as u64);
File::from_raw_fd(fd)
fd
}
}
pub fn close(file_descriptor: u64) {
@@ -173,29 +171,23 @@ pub fn read(file_descriptor: u64, buf: &mut [u8]) -> u64 {
len
}
}
pub fn seek(file_descriptor: u64, seek: SeekFrom) {
/// seek_type: 0 -> start, 1 -> end, 2 -> current
pub fn seek(file_descriptor: u64, seek_type: u8, seek: u64) {
unsafe {
let (discriminant, value) = match seek {
SeekFrom::Start(v) => (0, v),
SeekFrom::End(v) => (1, v as u64),
SeekFrom::Current(v) => (2, v as u64),
};
syscall!(SysCall::Seek, file_descriptor, discriminant, value);
syscall!(SysCall::Seek, file_descriptor, seek_type as u64, seek);
}
}
pub fn spawn<P: AsRef<Path>>(path: P) {
pub fn spawn(path: &str) {
unsafe {
let path_str = path.as_ref().as_str();
let ptr = path_str.as_ptr();
let size = path_str.len();
let ptr = path.as_ptr();
let size = path.len();
syscall!(SysCall::Spawn, ptr as u64, size as u64);
}
}
pub fn execve<P: AsRef<Path>>(path: P) {
pub fn execve(path: &str) {
unsafe {
let path_str = path.as_ref().as_str();
let ptr = path_str.as_ptr();
let size = path_str.len();
let ptr = path.as_ptr();
let size = path.len();
syscall!(SysCall::ExecVE, ptr as u64, size as u64);
}
}