Added kernel cmdline support and retrieval of initrd

usermode
ondra05 2022-12-08 22:21:21 +01:00
parent 7fbc348508
commit 0f08c059a6
5 changed files with 36 additions and 10 deletions

View File

@ -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.

View File

@ -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

View File

@ -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()
}

View File

@ -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;