forked from AbleOS/ableos
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
|
# Setting a default resolution for the framebuffer
|
||||||
RESOLUTION=800x600x24
|
RESOLUTION=800x600x24
|
||||||
|
|
||||||
MODULE_PATH=boot:///boot/initramfs.tar
|
MODULE_PATH=boot:///boot/initrd.tar
|
||||||
MODULE_CMDLINE=This is the first module.
|
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 spin::Mutex;
|
||||||
use uart_16550::SerialPort;
|
use uart_16550::SerialPort;
|
||||||
use x86_64::VirtAddr;
|
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() -> ! {
|
unsafe extern "C" fn _kernel_start() -> ! {
|
||||||
static HDHM_REQ: LimineHhdmRequest = LimineHhdmRequest::new(0);
|
static HDHM_REQ: LimineHhdmRequest = LimineHhdmRequest::new(0);
|
||||||
static MMAP_REQ: LimineMmapRequest = LimineMmapRequest::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();
|
SERIAL_CONSOLE.lock().init();
|
||||||
crate::logger::init().expect("failed to set logger");
|
crate::logger::init().expect("failed to set logger");
|
||||||
|
@ -39,7 +41,27 @@ unsafe extern "C" fn _kernel_start() -> ! {
|
||||||
gdt::init();
|
gdt::init();
|
||||||
interrupts::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
|
/// Format args to serial console
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
//! AbleOS Kernel Entrypoint
|
//! AbleOS Kernel Entrypoint
|
||||||
|
|
||||||
pub fn kmain() -> ! {
|
pub fn kmain(cmdline: &str, initrd: Option<&'static [u8]>) -> ! {
|
||||||
log::trace!("Entered kmain");
|
log::debug!("Entered kmain");
|
||||||
|
log::info!("Cmdline: \"{cmdline}\"");
|
||||||
|
let initrd = initrd.expect("no initrd found");
|
||||||
|
|
||||||
crate::arch::sloop()
|
crate::arch::sloop()
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
pub mod allocator;
|
mod allocator;
|
||||||
pub mod arch;
|
mod arch;
|
||||||
pub mod kmain;
|
mod kmain;
|
||||||
pub mod logger;
|
mod logger;
|
||||||
pub mod task;
|
mod syscalls;
|
||||||
|
mod task;
|
||||||
|
|
||||||
use versioning::Version;
|
use versioning::Version;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue