panic handler

uefi
Able 2022-02-18 02:37:09 -06:00
parent 19d1066350
commit a159b71770
Signed by untrusted user: able
GPG Key ID: D164AF5F5700BE51
5 changed files with 5 additions and 36 deletions

12
ableos/Cargo.lock generated
View File

@ -48,7 +48,6 @@ dependencies = [
"spin", "spin",
"uart_16550", "uart_16550",
"uefi", "uefi",
"uefi-services",
"unicode-width", "unicode-width",
"vga", "vga",
"volatile 0.2.7", "volatile 0.2.7",
@ -664,17 +663,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "uefi-services"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7840bddc6477dc443cc5652ca9683de9f10bd173691151c3160d734521bef3bd"
dependencies = [
"cfg-if",
"log",
"uefi",
]
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
version = "0.1.9" version = "0.1.9"

View File

@ -122,4 +122,3 @@ x86_64 = "*"
[target.'cfg(target_os = "uefi")'.dependencies] [target.'cfg(target_os = "uefi")'.dependencies]
uefi = { version="*",default-features = false, features = ["exts"] } uefi = { version="*",default-features = false, features = ["exts"] }
uefi-services = "0.11.0"

View File

@ -17,11 +17,11 @@ static ALLOCATOR: Dummy = Dummy;
*/ */
use linked_list_allocator::LockedHeap; use linked_list_allocator::LockedHeap;
#[cfg(not(target_os = "uefi"))] // #[cfg(not(target_os = "uefi"))]
#[global_allocator] #[global_allocator]
pub static ALLOCATOR: LockedHeap = LockedHeap::empty(); pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
#[cfg(not(target_os = "uefi"))] // #[cfg(not(target_os = "uefi"))]
#[alloc_error_handler] #[alloc_error_handler]
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! { fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
panic!("allocation error: {:?}", layout) panic!("allocation error: {:?}", layout)

View File

@ -7,16 +7,12 @@ pub fn shutdown() {
pub fn sloop() -> ! { pub fn sloop() -> ! {
loop {} loop {}
} }
use core::{ffi::c_void, sync::atomic::AtomicUsize, time::Duration};
use crate::kmain::kernel_main; use crate::kmain::kernel_main;
use uefi::{ use uefi::{
prelude::*, prelude::*,
proto::{ proto::console::gop::{GraphicsOutput, PixelFormat},
console::gop::{GraphicsOutput, PixelFormat},
pi::mp::MpServices,
},
}; };
use uefi::{proto::console::gop::FrameBuffer, ResultExt}; use uefi::{proto::console::gop::FrameBuffer, ResultExt};
@ -26,7 +22,7 @@ fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
.stdout() .stdout()
.reset(false) .reset(false)
.expect_success("Failed to reset output buffer"); .expect_success("Failed to reset output buffer");
uefi_services::init(&mut system_table).unwrap_success(); // uefi_services::init(&mut system_table).unwrap_success();
{ {
// Print out UEFI revision number // Print out UEFI revision number
@ -71,24 +67,10 @@ fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
warn!("UEFI Graphics Output Protocol is not supported"); warn!("UEFI Graphics Output Protocol is not supported");
} }
use uefi::proto::pi::mp::MpServices;
if let Ok(mp_support) = system_table.boot_services().locate_protocol::<MpServices>() {
let mp_support = mp_support
.expect("Warnings encountered while opening multi-processor services protocol");
let mp = unsafe { &mut *mp_support.get() };
let proc_count = mp.get_number_of_processors().unwrap().unwrap();
info!("Number of processors: {:?}", proc_count);
}
// exit boot services // exit boot services
kernel_main(); kernel_main();
} }
extern "efiapi" fn hi(_: *mut c_void) {
info!("Hello, world!");
}
use uefi::proto::console::gop::ModeInfo; use uefi::proto::console::gop::ModeInfo;
pub type PixelWriter = unsafe fn(&mut FrameBuffer, usize, [u8; 3]); pub type PixelWriter = unsafe fn(&mut FrameBuffer, usize, [u8; 3]);

View File

@ -10,7 +10,7 @@ use {crate::arch::sloop, core::panic::PanicInfo};
/// # Safety /// # Safety
/// This function is unsafe because it does not guarantee that the panic is handled. /// This function is unsafe because it does not guarantee that the panic is handled.
#[cfg(not(target_os = "uefi"))] // #[cfg(not(target_os = "uefi"))]
#[panic_handler] #[panic_handler]
fn panic(info: &PanicInfo) -> ! { fn panic(info: &PanicInfo) -> ! {
error!("{}", info); error!("{}", info);