From 9204e0dc00f16053c80986896aeb32f582fcb48e Mon Sep 17 00:00:00 2001 From: Nick Shipp Date: Mon, 15 Mar 2021 15:55:35 -0400 Subject: The past --- bunny/Xargo.toml | 2 -- bunny/src/main.rs | 45 ++++++++++++++++++++++++++++++++++++++++----- bunny/src/println.rs | 2 +- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/bunny/Xargo.toml b/bunny/Xargo.toml index c2a2569..e69de29 100644 --- a/bunny/Xargo.toml +++ b/bunny/Xargo.toml @@ -1,2 +0,0 @@ -[target.x86_64-pc-uefi.dependencies.alloc] -features = [] 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::(io::PIC1_DATA, io::PIC_DISABLE); io::out::(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"); }); -- cgit v1.2.3-54-g00ecf