Skip to content

Commit

Permalink
uefi-raw: Add SystemTable
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasbishop committed Jun 19, 2023
1 parent 12e4a20 commit 01cc917
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions uefi-raw/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod revision;
pub mod boot;
pub mod configuration;
pub mod runtime;
pub mod system;

pub use header::Header;
pub use revision::Revision;
70 changes: 70 additions & 0 deletions uefi-raw/src/table/system.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
use crate::protocol::console::{SimpleTextInputProtocol, SimpleTextOutputProtocol};
use crate::table::boot::BootServices;
use crate::table::configuration::ConfigurationTable;
use crate::table::runtime::RuntimeServices;
use crate::table::Header;
use crate::{Char16, Handle};
use core::{mem, ptr};

#[derive(Clone, Debug, Eq, PartialEq)]
#[repr(C)]
pub struct SystemTable {
pub header: Header,

pub firmware_vendor: *const Char16,
pub firmware_revision: u32,

pub stdin_handle: Handle,
pub stdin: *mut SimpleTextInputProtocol,

pub stdout_handle: Handle,
pub stdout: *mut SimpleTextOutputProtocol,

pub stderr_handle: Handle,
pub stderr: *mut SimpleTextOutputProtocol,

pub runtime_services: *mut RuntimeServices,
pub boot_services: *mut BootServices,

pub number_of_configuration_table_entries: usize,
pub configuration_table: *mut ConfigurationTable,
}

impl SystemTable {
pub const SIGNATURE: u64 = 0x5453_5953_2049_4249;
}

impl Default for SystemTable {
/// Create a `SystemTable` with most fields set to zero.
///
/// The only fields not set to zero are:
/// * [`Header::signature`] is set to [`SystemTable::SIGNATURE`].
/// * [`Header::size`] is set to the size in bytes of `SystemTable`.
fn default() -> Self {
Self {
header: Header {
signature: Self::SIGNATURE,
size: u32::try_from(mem::size_of::<Self>()).unwrap(),
..Header::default()
},

firmware_vendor: ptr::null_mut(),
firmware_revision: 0,

stdin_handle: ptr::null_mut(),
stdin: ptr::null_mut(),

stdout_handle: ptr::null_mut(),
stdout: ptr::null_mut(),

stderr_handle: ptr::null_mut(),
stderr: ptr::null_mut(),

runtime_services: ptr::null_mut(),
boot_services: ptr::null_mut(),

number_of_configuration_table_entries: 0,
configuration_table: ptr::null_mut(),
}
}
}

0 comments on commit 01cc917

Please sign in to comment.