#![no_std]
#![allow(non_snake_case)]
#![deny(unused_crate_dependencies)]
#![deny(unused_imports)]
#![deny(clippy::enum_glob_use)]
#![deny(clippy::inline_asm_x86_att_syntax)]
#![deny(clippy::panic)]
#![deny(clippy::ref_binding_to_reference)]
#![deny(clippy::unwrap_used)]
#![deny(clippy::wildcard_dependencies)]
#![warn(clippy::borrow_as_ptr)]
#![warn(clippy::cast_lossless)]
#![warn(clippy::default_union_representation)]
#![warn(clippy::float_arithmetic)]
#![warn(clippy::macro_use_imports)]
#![warn(clippy::match_same_arms)]
#![warn(clippy::ptr_as_ptr)]
#![warn(clippy::same_name_method)]
#![warn(clippy::self_named_module_files)]
#![warn(clippy::semicolon_if_nothing_returned)]
#![warn(clippy::shadow_unrelated)]
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "alloc")]
pub mod global_alloc;
pub mod guid;
pub mod hii;
pub mod mem;
pub mod prelude;
pub mod status;
pub mod table;
pub mod proto;
use core::ptr;
use prelude::*;
pub type ImageEntryFn = extern "efiapi" fn(Handle, &mut SystemTable) -> Status;
static mut SYSTEM_TABLE: Option<ptr::NonNull<SystemTable>> = None;
pub fn system_table() -> &'static mut SystemTable {
unsafe { SYSTEM_TABLE.expect("system table not available").as_mut() }
}
#[cfg(not(feature = "alloc"))]
pub fn init(st: &mut SystemTable) {
unsafe {
SYSTEM_TABLE = ptr::NonNull::new(st as *mut _);
}
}
#[cfg(feature = "alloc")]
pub fn init(st: &mut SystemTable) {
unsafe {
SYSTEM_TABLE = ptr::NonNull::new(st as *mut _);
global_alloc::init(st.boot_services());
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(transparent)]
pub struct Handle(ptr::NonNull<usize>);
impl Handle {
pub unsafe fn uninit() -> Self {
Handle(ptr::NonNull::dangling())
}
}
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Tpl(usize);
impl Tpl {
pub const NONE: Self = Self(0);
pub const APPLICATION: Self = Self(4);
pub const CALLBACK: Self = Self(8);
pub const NOTIFY: Self = Self(16);
pub const HIGH_LEVEL: Self = Self(31);
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(transparent)]
pub struct Event(ptr::NonNull<usize>);
impl Event {
pub unsafe fn uninit() -> Self {
Self(ptr::NonNull::dangling())
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(transparent)]
pub struct EventType(u32);
impl EventType {
pub const NONE: Self = Self(0);
pub const TIMER: Self = Self(0x8000_0000);
pub const RUNTIME: Self = Self(0x4000_0000);
pub const NOTIFY_WAIT: Self = Self(0x0000_0100);
pub const NOTIFY_SIGNAL: Self = Self(0x0000_0200);
pub const SIGNAL_EXIT_BOOT_SERVICES: Self = Self(0x0000_0201);
pub const SIGNAL_VIRTUAL_ADDRESS_CHANGE: Self = Self(0x6000_0202);
}
#[cfg(feature = "panic_handler")]
#[doc(hidden)]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {
unsafe {
core::arch::asm!("hlt");
}
}
}