#![allow(dead_code)]
pub mod kcmdline;
pub mod memory_region;
pub mod smp;
use alloc::{string::String, vec::Vec};
use kcmdline::KCmdlineArg;
use spin::Once;
use self::memory_region::MemoryRegion;
#[derive(Copy, Clone, Debug)]
pub enum BootloaderAcpiArg {
NotProvided,
Rsdp(usize),
Rsdt(usize),
Xsdt(usize),
}
#[derive(Copy, Clone, Debug)]
pub struct BootloaderFramebufferArg {
pub address: usize,
pub width: usize,
pub height: usize,
pub bpp: usize,
}
macro_rules! define_global_static_boot_arguments {
( $( $lower:ident, $upper:ident, $typ:ty; )* ) => {
$(
static $upper: Once<$typ> = Once::new();
pub fn $lower() -> &'static $typ {
$upper.get().unwrap()
}
)*
struct BootInitCallBacks {
$( $lower: fn(&'static Once<$typ>) -> (), )*
}
static BOOT_INIT_CALLBACKS: Once<BootInitCallBacks> = Once::new();
pub fn register_boot_init_callbacks($( $lower: fn(&'static Once<$typ>) -> (), )* ) {
BOOT_INIT_CALLBACKS.call_once(|| {
BootInitCallBacks { $( $lower, )* }
});
}
fn call_all_boot_init_callbacks() {
let callbacks = &BOOT_INIT_CALLBACKS.get().unwrap();
$( (callbacks.$lower)(&$upper); )*
}
};
}
define_global_static_boot_arguments!(
bootloader_name, BOOTLOADER_NAME, String;
kernel_cmdline, KERNEL_CMDLINE, KCmdlineArg;
initramfs, INITRAMFS, &'static [u8];
acpi_arg, ACPI_ARG, BootloaderAcpiArg;
framebuffer_arg, FRAMEBUFFER_ARG, BootloaderFramebufferArg;
memory_regions, MEMORY_REGIONS, Vec<MemoryRegion>;
);
pub fn init() {
call_all_boot_init_callbacks();
}
pub(crate) fn call_ostd_main() -> ! {
unsafe {
extern "Rust" {
fn __ostd_main() -> !;
}
__ostd_main();
}
}