Added kernel cmdline support and retrieval of initrd
This commit is contained in:
parent
b68984dc7f
commit
0249353a6b
|
@ -18,5 +18,5 @@ TERM_BACKDROP=008080
|
|||
# Setting a default resolution for the framebuffer
|
||||
RESOLUTION=800x600x24
|
||||
|
||||
MODULE_PATH=boot:///boot/initramfs.tar
|
||||
MODULE_PATH=boot:///boot/initrd.tar
|
||||
MODULE_CMDLINE=This is the first module.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use limine::{LimineHhdmRequest, LimineMmapRequest};
|
||||
use limine::{LimineHhdmRequest, LimineKernelFileRequest, LimineMmapRequest, LimineModuleRequest};
|
||||
use spin::Mutex;
|
||||
use uart_16550::SerialPort;
|
||||
use x86_64::VirtAddr;
|
||||
|
@ -14,6 +14,8 @@ static SERIAL_CONSOLE: Mutex<SerialPort> = Mutex::new(unsafe { SerialPort::new(0
|
|||
unsafe extern "C" fn _kernel_start() -> ! {
|
||||
static HDHM_REQ: LimineHhdmRequest = LimineHhdmRequest::new(0);
|
||||
static MMAP_REQ: LimineMmapRequest = LimineMmapRequest::new(0);
|
||||
static KFILE_REQ: LimineKernelFileRequest = LimineKernelFileRequest::new(0);
|
||||
static MOD_REQ: LimineModuleRequest = LimineModuleRequest::new(0);
|
||||
|
||||
SERIAL_CONSOLE.lock().init();
|
||||
crate::logger::init().expect("failed to set logger");
|
||||
|
@ -39,7 +41,27 @@ unsafe extern "C" fn _kernel_start() -> ! {
|
|||
gdt::init();
|
||||
interrupts::init();
|
||||
|
||||
crate::kmain::kmain()
|
||||
crate::kmain::kmain(
|
||||
KFILE_REQ
|
||||
.get_response()
|
||||
.get()
|
||||
.and_then(|r| r.kernel_file.get())
|
||||
.expect("failed to get kernel file from Limine")
|
||||
.cmdline
|
||||
.to_string()
|
||||
.unwrap_or_default(),
|
||||
MOD_REQ
|
||||
.get_response()
|
||||
.get()
|
||||
.and_then(|r| r.modules())
|
||||
.and_then(|m| m.get(0))
|
||||
.map(|file| unsafe {
|
||||
core::slice::from_raw_parts(
|
||||
file.base.as_ptr().expect("invalid initrd"),
|
||||
file.length as usize,
|
||||
)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
/// Format args to serial console
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
//! AbleOS Kernel Entrypoint
|
||||
|
||||
pub fn kmain() -> ! {
|
||||
log::trace!("Entered kmain");
|
||||
pub fn kmain(cmdline: &str, initrd: Option<&'static [u8]>) -> ! {
|
||||
log::debug!("Entered kmain");
|
||||
log::info!("Cmdline: \"{cmdline}\"");
|
||||
let initrd = initrd.expect("no initrd found");
|
||||
|
||||
crate::arch::sloop()
|
||||
}
|
||||
|
|
|
@ -10,11 +10,12 @@
|
|||
|
||||
extern crate alloc;
|
||||
|
||||
pub mod allocator;
|
||||
pub mod arch;
|
||||
pub mod kmain;
|
||||
pub mod logger;
|
||||
pub mod task;
|
||||
mod allocator;
|
||||
mod arch;
|
||||
mod kmain;
|
||||
mod logger;
|
||||
mod syscalls;
|
||||
mod task;
|
||||
|
||||
use versioning::Version;
|
||||
|
||||
|
|
Loading…
Reference in a new issue