mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 17:03:23 +00:00
Use bootloader to load initramfs
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
dba89b508d
commit
902b0421c3
@ -10,9 +10,10 @@ extern crate jinux_frame;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use jinux_frame::println;
|
||||
use limine::LimineBootInfoRequest;
|
||||
use limine::{LimineBootInfoRequest, LimineModuleRequest};
|
||||
|
||||
static BOOTLOADER_INFO: LimineBootInfoRequest = LimineBootInfoRequest::new(0);
|
||||
static BOOTLOADER_MODULE: LimineModuleRequest = LimineModuleRequest::new(0);
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn _start() -> ! {
|
||||
@ -21,9 +22,19 @@ pub extern "C" fn _start() -> ! {
|
||||
jinux_frame::init();
|
||||
println!("[kernel] finish init jinux_frame");
|
||||
component::init_all(component::parse_metadata!()).unwrap();
|
||||
jinux_std::init();
|
||||
jinux_std::init(read_ramdisk_content());
|
||||
jinux_std::run_first_process();
|
||||
}
|
||||
|
||||
fn read_ramdisk_content() -> &'static [u8] {
|
||||
let module_info = BOOTLOADER_MODULE.get_response().get().unwrap();
|
||||
assert!(module_info.module_count == 1);
|
||||
let ramdisk_file = &module_info.modules()[0];
|
||||
let base_ptr = ramdisk_file.base.as_ptr().unwrap();
|
||||
let length = ramdisk_file.length as usize;
|
||||
unsafe { core::slice::from_raw_parts(base_ptr, length) }
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
|
@ -44,10 +44,10 @@ pub mod tty;
|
||||
mod util;
|
||||
pub mod vm;
|
||||
|
||||
pub fn init() {
|
||||
pub fn init(ramdisk: &[u8]) {
|
||||
driver::init();
|
||||
process::fifo_scheduler::init();
|
||||
fs::initramfs::init(read_ramdisk_content()).unwrap();
|
||||
fs::initramfs::init(ramdisk).unwrap();
|
||||
}
|
||||
|
||||
fn init_thread() {
|
||||
@ -78,10 +78,6 @@ fn init_thread() {
|
||||
}
|
||||
}
|
||||
|
||||
fn read_ramdisk_content() -> &'static [u8] {
|
||||
include_bytes!("../../../../regression/ramdisk/build/ramdisk.cpio")
|
||||
}
|
||||
|
||||
/// first process never return
|
||||
#[controlled]
|
||||
pub fn run_first_process() -> ! {
|
||||
|
Reference in New Issue
Block a user