use super::*;
use late_static::LateStatic;
#[repr(transparent)]
#[derive(Copy, Clone)]
pub struct SystemTable(*mut bits::SystemTable);
unsafe impl core::marker::Send for SystemTable {}
static mut SYSTEM_TABLE: LateStatic<efi::SystemTable> = LateStatic::new();
impl SystemTable {
pub(crate) unsafe fn init(system_table: *mut bits::SystemTable) {
LateStatic::assign(&SYSTEM_TABLE, SystemTable(system_table));
}
pub fn get() -> SystemTable {
unsafe {
*SYSTEM_TABLE
}
}
pub fn console_in_handle(&self) -> Handle {
unsafe {
Handle::new((*self.0).console_in_handle)
}
}
pub fn con_in(&self) -> protocols::SimpleTextInput {
unsafe {
protocols::SimpleTextInput::new((*self.0).con_out as _)
}
}
pub fn console_out_handle(&self) -> Handle {
unsafe {
Handle::new((*self.0).console_out_handle)
}
}
pub fn con_out(&self) -> protocols::SimpleTextOutput {
unsafe {
protocols::SimpleTextOutput::new((*self.0).con_out as _)
}
}
pub fn standard_error_handle(&self) -> Handle {
unsafe {
Handle::new((*self.0).standard_error_handle)
}
}
pub fn std_err(&self) -> protocols::SimpleTextOutput {
unsafe {
protocols::SimpleTextOutput::new((*self.0).std_err as _)
}
}
pub fn runtime_services(&self) -> RuntimeServices {
unsafe {
RuntimeServices::new((*self.0).runtime_services)
}
}
pub fn boot_services(&self) -> BootServices {
unsafe {
BootServices::new((*self.0).boot_services)
}
}
pub fn bits(&mut self) -> *mut bits::SystemTable {
self.0
}
}