aboutsummaryrefslogtreecommitdiff
path: root/bunny/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bunny/src/main.rs')
-rw-r--r--bunny/src/main.rs49
1 files changed, 9 insertions, 40 deletions
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 {}
-}