This commit is contained in:
2026-02-26 11:52:40 +01:00
parent 4dc05c4151
commit 79b75dc75b
8 changed files with 33 additions and 19 deletions

View File

@@ -16,7 +16,7 @@ use shared::syscall::exit;
use crate::{
fs::FILE_SYSTEM,
println,
scheduler::{ACTIVE_PID, PROCESS_COUNT, PROCESS_TABLE, scheduler_without_ret},
scheduler::{scheduler_without_ret, ACTIVE_PID, PROCESS_COUNT, PROCESS_TABLE},
time::elapsed_time_since_startup,
};
@@ -134,12 +134,9 @@ pub fn create_process_from_file<'a, T: Into<Path<'a>>>(path: T) -> i64 {
println!("Loading binary at address: {:x?}", content.as_ptr());
// SAFETY: Convert raw bytes into an executable function.
// The binary must be valid RISC-V machine code.
// Fallback: treat the file as a raw binary blob and execute in-place
let entry_point =
unsafe { core::mem::transmute::<*const u8, extern "C" fn()>(Vec::leak(content).as_ptr()) };
// Create a wrapper for the entry point function
let wrapper = Box::leak(Box::new(move || {
entry_point();
}));