mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-23 01:13: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 core::panic::PanicInfo;
|
||||||
use jinux_frame::println;
|
use jinux_frame::println;
|
||||||
use limine::LimineBootInfoRequest;
|
use limine::{LimineBootInfoRequest, LimineModuleRequest};
|
||||||
|
|
||||||
static BOOTLOADER_INFO: LimineBootInfoRequest = LimineBootInfoRequest::new(0);
|
static BOOTLOADER_INFO: LimineBootInfoRequest = LimineBootInfoRequest::new(0);
|
||||||
|
static BOOTLOADER_MODULE: LimineModuleRequest = LimineModuleRequest::new(0);
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
@ -21,9 +22,19 @@ pub extern "C" fn _start() -> ! {
|
|||||||
jinux_frame::init();
|
jinux_frame::init();
|
||||||
println!("[kernel] finish init jinux_frame");
|
println!("[kernel] finish init jinux_frame");
|
||||||
component::init_all(component::parse_metadata!()).unwrap();
|
component::init_all(component::parse_metadata!()).unwrap();
|
||||||
jinux_std::init();
|
jinux_std::init(read_ramdisk_content());
|
||||||
jinux_std::run_first_process();
|
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))]
|
#[cfg(not(test))]
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
|
@ -44,10 +44,10 @@ pub mod tty;
|
|||||||
mod util;
|
mod util;
|
||||||
pub mod vm;
|
pub mod vm;
|
||||||
|
|
||||||
pub fn init() {
|
pub fn init(ramdisk: &[u8]) {
|
||||||
driver::init();
|
driver::init();
|
||||||
process::fifo_scheduler::init();
|
process::fifo_scheduler::init();
|
||||||
fs::initramfs::init(read_ramdisk_content()).unwrap();
|
fs::initramfs::init(ramdisk).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_thread() {
|
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
|
/// first process never return
|
||||||
#[controlled]
|
#[controlled]
|
||||||
pub fn run_first_process() -> ! {
|
pub fn run_first_process() -> ! {
|
||||||
|
Reference in New Issue
Block a user