From 56b399a7d79a36304a93adab67220ae2af1b93a9 Mon Sep 17 00:00:00 2001 From: Nick Shipp Date: Mon, 1 Oct 2018 21:41:35 -0400 Subject: Switch to uefi-rs --- bunny/src/main.rs | 49 +++++++++---------------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) (limited to 'bunny/src/main.rs') diff --git a/bunny/src/main.rs b/bunny/src/main.rs index e7f5c70..cfb2f4a 100644 --- a/bunny/src/main.rs +++ b/bunny/src/main.rs @@ -2,24 +2,20 @@ #![no_std] #![no_main] -extern crate efi; -extern crate x86_64; -extern crate volatile; +#[macro_use] +extern crate log; #[macro_use] mod println; mod interrupt; mod lapic; mod io; -mod uefi; mod inttraits; -use core::panic::PanicInfo; use core::ptr; use core::slice; -use efi::types::Handle; -use efi::SystemTable; +use uefi::prelude::*; use x86_64::instructions::interrupts; use self::interrupt::*; @@ -28,8 +24,6 @@ use self::inttraits::*; const NUM_CORES: u8 = 4; -static mut SYSTEM_TABLE: *const SystemTable = 0 as *const SystemTable; - #[allow(improper_ctypes)] extern "C" { #[link_name = "llvm.x86.rdtsc"] @@ -49,23 +43,18 @@ fn busy() { } #[no_mangle] -pub extern fn efi_main(_handle: Handle, systab: &SystemTable) -> ! { +pub extern fn efi_main(_handle: uefi::Handle, systab: &'static SystemTable) -> ! { /* * Disable interrupts to avoid noise generated before we actually * have anything to do *with* interrupts */ interrupts::disable(); - /* - * Save EFI system table ptr to globally accessible location. - * MUST do this before calling println!(), or just about anything else. - */ - unsafe { - SYSTEM_TABLE = systab; - } + /* Initialize UEFI boot services (logger, allocator) */ + uefi_services::init(systab); - println!("FUZZY BUNNIES {}", env!("CARGO_PKG_VERSION")); - println!("efi_main @ 0x{:x}", efi_main as *const u8 as usize); + info!("FUZZY BUNNIES {}", env!("CARGO_PKG_VERSION")); + info!("efi_main @ 0x{:x}", efi_main as *const u8 as usize); /* Set up basic exception handlers */ register_handlers(); @@ -133,7 +122,7 @@ pub extern fn efi_main(_handle: Handle, systab: &SystemTable) -> ! { n_aps = unsafe { ptr::read_volatile(0x6001 as *const u8) }; } - dprintln!("All cores online"); + debug!("All cores online"); /* All good, turn interrupts back on and idle */ interrupts::enable(); @@ -142,23 +131,3 @@ pub extern fn efi_main(_handle: Handle, systab: &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 {} -} -- cgit v1.2.3-54-g00ecf