diff options
Diffstat (limited to 'bunny/src')
-rw-r--r-- | bunny/src/main.rs | 45 | ||||
-rw-r--r-- | bunny/src/println.rs | 2 |
2 files changed, 41 insertions, 6 deletions
diff --git a/bunny/src/main.rs b/bunny/src/main.rs index cfb2f4a..4a3eb74 100644 --- a/bunny/src/main.rs +++ b/bunny/src/main.rs @@ -11,9 +11,11 @@ mod interrupt; mod lapic; mod io; mod inttraits; +mod efifb; use core::ptr; use core::slice; +use core::panic::PanicInfo; use uefi::prelude::*; use x86_64::instructions::interrupts; @@ -23,6 +25,13 @@ use self::lapic::*; use self::inttraits::*; const NUM_CORES: u8 = 4; +const RESOLUTION: (usize, usize) = (1920, 1080); + +static mut SYSTEM_TABLE: Option<&'static SystemTable> = None; + +pub(crate) fn system_table() -> &'static SystemTable { + SYSTEM_TABLE.expect("System table is missing!") +} #[allow(improper_ctypes)] extern "C" { @@ -50,15 +59,20 @@ pub extern fn efi_main(_handle: uefi::Handle, systab: &'static SystemTable) -> ! */ interrupts::disable(); - /* Initialize UEFI boot services (logger, allocator) */ - uefi_services::init(systab); - - info!("FUZZY BUNNIES {}", env!("CARGO_PKG_VERSION")); - info!("efi_main @ 0x{:x}", efi_main as *const u8 as usize); + /* Save global reference to the system table */ + SYSTEM_TABLE = Some(systab); /* Set up basic exception handlers */ register_handlers(); + /* Initialize early framebuffer */ + efifb::init(); + + interrupts::enable(); + + info!("FUZZY BUNNIES {}", env!("CARGO_PKG_VERSION")); + info!("efi_main @ 0x{:x}", efi_main as *const u8 as usize); + /* Set up AP bootstrap (real->long transition) code */ let code = include_bytes!(concat!(env!("OUT_DIR"), "/ap_boot.bin")); let dest = unsafe { @@ -90,6 +104,7 @@ pub extern fn efi_main(_handle: uefi::Handle, systab: &'static SystemTable) -> ! } /* Disable the PICs to prepare for other cores */ + interrupts::disable(); unsafe { io::out::<u8>(io::PIC1_DATA, io::PIC_DISABLE); io::out::<u8>(io::PIC2_DATA, io::PIC_DISABLE); @@ -131,3 +146,23 @@ pub extern fn efi_main(_handle: uefi::Handle, systab: &'static SystemTable) -> ! unsafe { asm!("hlt"); } } } + +#[lang = "eh_personality"] +#[no_mangle] +pub extern fn eh_personality() { } + +#[no_mangle] +#[panic_handler] +pub extern fn panic_impl(pi: &PanicInfo) -> ! { + println!("!!! PANIC !!!"); + + if let Some(loc) = pi.location() { + println!("in file {}:{}:{}", loc.file(), loc.line(), loc.column()); + } + + if let Some(msg) = pi.message() { + println!("{}", msg); + } + + loop {} +} diff --git a/bunny/src/println.rs b/bunny/src/println.rs index 15f74de..761f974 100644 --- a/bunny/src/println.rs +++ b/bunny/src/println.rs @@ -2,7 +2,7 @@ macro_rules! print { ($($arg:tt)*) => ({ use core::fmt::Write; - uefi_services::system_table().stdout() + crate::system_table().stdout() .write_fmt(format_args!($($arg)*)) .expect("could not write to console"); }); |