Skip to content

Commit fca0eaa

Browse files
committed
Add panic and collections
1 parent a211f1b commit fca0eaa

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

uefi_std/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![no_std]
22
#![feature(alloc)]
33
#![feature(core_intrinsics)]
4+
#![feature(lang_items)]
45
#![feature(prelude_import)]
56
#![feature(raw)]
67
#![feature(slice_concat_ext)]
@@ -66,6 +67,7 @@ pub use alloc_crate::borrow;
6667
pub use alloc_crate::fmt;
6768
pub use alloc_crate::format;
6869
pub use core::pin;
70+
pub use alloc_crate::collections;
6971
pub use alloc_crate::slice;
7072
pub use alloc_crate::str;
7173
pub use alloc_crate::string;
@@ -81,13 +83,18 @@ pub use uefi_alloc;
8183

8284
pub mod io;
8385
pub mod math;
86+
pub mod panic;
8487
pub mod rt;
8588

8689
#[global_allocator]
8790
static ALLOCATOR: uefi_alloc::Allocator = uefi_alloc::Allocator;
8891

89-
pub static mut HANDLE: uefi::Handle = uefi::Handle(0);
90-
pub static mut SYSTEM_TABLE: *mut uefi::system::SystemTable = 0 as *mut uefi::system::SystemTable;
92+
static mut HANDLE: uefi::Handle = uefi::Handle(0);
93+
static mut SYSTEM_TABLE: *mut uefi::system::SystemTable = 0 as *mut uefi::system::SystemTable;
94+
95+
pub fn handle() -> uefi::Handle {
96+
unsafe { HANDLE }
97+
}
9198

9299
pub fn system_table() -> &'static uefi::system::SystemTable {
93100
unsafe { & *SYSTEM_TABLE }

uefi_std/src/panic.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// These functions are used by the compiler, but not
2+
// for a bare-bones hello world. These are normally
3+
// provided by libstd.
4+
#[lang = "eh_personality"]
5+
#[no_mangle]
6+
pub extern fn rust_eh_personality() {}
7+
8+
// This function may be needed based on the compilation target.
9+
#[lang = "eh_unwind_resume"]
10+
#[no_mangle]
11+
pub extern fn rust_eh_unwind_resume() {
12+
loop {}
13+
}
14+
15+
#[panic_handler]
16+
#[no_mangle]
17+
pub extern fn rust_begin_panic(pi: &::core::panic::PanicInfo) -> ! {
18+
print!("SETUP PANIC: {}", pi);
19+
20+
loop {}
21+
}
22+
23+
#[lang = "oom"]
24+
#[no_mangle]
25+
pub extern "C" fn rust_oom(layout: ::core::alloc::Layout) -> ! {
26+
println!(
27+
"SETUP OOM: {} bytes aligned to {} bytes\n",
28+
layout.size(),
29+
layout.align()
30+
);
31+
32+
loop {}
33+
}
34+
35+
#[allow(non_snake_case)]
36+
#[no_mangle]
37+
pub extern fn _Unwind_Resume() {
38+
loop {}
39+
}

0 commit comments

Comments
 (0)