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.rs45
1 files changed, 40 insertions, 5 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 {}
+}