#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(self::test_runner)]
#![reexport_test_harness_main = "test_main"]
#[cfg(feature = "loader_main")]
pub mod loader_main;
pub mod output;
pub mod memory;
pub mod header;
mod version;
use self::output::Framebuffer;
use self::memory::MemoryMap;
#[repr(C, packed)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BootInfo {
boot_mode: BootMode,
framebuffer: Framebuffer,
memmap: MemoryMap,
}
impl BootInfo {
#[cfg(feature = "loader_main")]
pub fn new(boot_mode: BootMode, memmap: MemoryMap, fb: Framebuffer) -> Self {
Self {
boot_mode,
memmap,
framebuffer: fb
}
}
pub const fn boot_mode(&self) -> BootMode {
self.boot_mode
}
pub const fn framebuffer(&self) -> Framebuffer {
self.framebuffer
}
pub const fn memory(&self) -> MemoryMap {
self.memmap
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BootMode {
Legacy,
Uefi,
}
pub const fn get_bootinfo() -> &'static BootInfo {
const BI_PHYS: u64 = 0x10000;
unsafe { &*(BI_PHYS as *const BootInfo) }
}
#[cfg(test)]
fn test_runner(tests: &[&dyn Fn()]) {
for test in tests {
test();
}
}