Refactor
This commit is contained in:
@@ -79,9 +79,9 @@ impl Read for Disk {
|
||||
return Ok(0);
|
||||
}
|
||||
let size = usize::min(buf.len(), (self.size - self.pos) as usize);
|
||||
for i in 0..size {
|
||||
(0..size).for_each(|i| {
|
||||
buf[i] = unsafe { *DISK_ADDR.byte_add(i + self.pos as usize) };
|
||||
}
|
||||
});
|
||||
self.pos += size as u64;
|
||||
Ok(size)
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
iter_map_windows,
|
||||
str_from_raw_parts,
|
||||
macro_metavar_expr,
|
||||
macro_metavar_expr_concat
|
||||
macro_metavar_expr_concat,
|
||||
ptr_metadata
|
||||
)]
|
||||
|
||||
use alloc::string::String;
|
||||
use embedded_alloc::LlffHeap as Heap;
|
||||
use log::info;
|
||||
|
||||
@@ -42,7 +44,7 @@ mod uart;
|
||||
mod user;
|
||||
mod vga;
|
||||
|
||||
pub const HEAP_SIZE: usize = 1024 * 1024; // 1Mo RAM
|
||||
pub const HEAP_SIZE: usize = 1024 * 1024 * 32; // 32Mo RAM
|
||||
#[global_allocator]
|
||||
static HEAP: Heap = Heap::empty();
|
||||
|
||||
|
||||
@@ -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();
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user