feat: pass both initrd base and size
This commit is contained in:
@@ -62,7 +62,8 @@ extern "C" fn __aa64_bsp_main(fdt_base: usize) -> ! {
|
||||
if fdt_base != 0 {
|
||||
let fdt = DeviceTree::from_phys(fdt_base + 0xFFFFFF8000000000);
|
||||
if let Ok(fdt) = fdt {
|
||||
// fdt.dump(Level::Debug);
|
||||
use crate::debug::Level;
|
||||
fdt.dump(Level::Debug);
|
||||
initrd = fdt.initrd();
|
||||
} else {
|
||||
initrd = None;
|
||||
|
||||
+13
-10
@@ -51,17 +51,18 @@ pub(self) static PROCESSES: IrqSafeSpinLock<BTreeMap<Pid, ProcessRef>> =
|
||||
/// Unsafe: May only be called once.
|
||||
pub unsafe fn enter(initrd: Option<(usize, usize)>) -> ! {
|
||||
SCHED.init();
|
||||
if let Some((start, end)) = initrd {
|
||||
let initrd = Box::into_raw(Box::new((mem::virtualize(start), mem::virtualize(end))));
|
||||
let initrd = Box::into_raw(Box::new(initrd));
|
||||
|
||||
spawn!(fn (initrd_ptr: usize) {
|
||||
use memfs::Ramfs;
|
||||
use vfs::{Filesystem, Ioctx};
|
||||
use crate::fs::MemfsBlockAlloc;
|
||||
debugln!("Running kernel init process");
|
||||
spawn!(fn (initrd_ptr: usize) {
|
||||
use memfs::Ramfs;
|
||||
use vfs::{Filesystem, Ioctx};
|
||||
use crate::fs::MemfsBlockAlloc;
|
||||
debugln!("Running kernel init process");
|
||||
|
||||
let (start, end) = unsafe { *(initrd_ptr as *const (usize, usize)) };
|
||||
let initrd = unsafe { *(initrd_ptr as *const Option<(usize, usize)>) };
|
||||
if let Some((start, end)) = initrd {
|
||||
let size = end - start;
|
||||
let start = mem::virtualize(start);
|
||||
|
||||
infoln!("Constructing initrd filesystem in memory, this may take a while...");
|
||||
let fs = unsafe {
|
||||
@@ -76,7 +77,9 @@ pub unsafe fn enter(initrd: Option<(usize, usize)>) -> ! {
|
||||
let mut file = node.open().unwrap();
|
||||
|
||||
Process::execve(|space| elf::load_elf(space, &mut file), 0).unwrap();
|
||||
}, initrd as usize);
|
||||
}
|
||||
} else {
|
||||
infoln!("No initrd, exiting!");
|
||||
}
|
||||
}, initrd as usize);
|
||||
SCHED.enter();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user