panic handler
This commit is contained in:
parent
77e6f29568
commit
d609e6d78c
12
ableos/Cargo.lock
generated
12
ableos/Cargo.lock
generated
|
@ -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"
|
||||||
|
|
|
@ -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"
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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]);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue