uefi_raw/table/
system.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3use crate::protocol::console::{SimpleTextInputProtocol, SimpleTextOutputProtocol};
4use crate::table::boot::BootServices;
5use crate::table::configuration::ConfigurationTable;
6use crate::table::runtime::RuntimeServices;
7use crate::table::Header;
8use crate::{Char16, Handle};
9use core::ptr;
10
11#[derive(Clone, Debug, Eq, PartialEq)]
12#[repr(C)]
13pub struct SystemTable {
14    pub header: Header,
15
16    pub firmware_vendor: *const Char16,
17    pub firmware_revision: u32,
18
19    pub stdin_handle: Handle,
20    pub stdin: *mut SimpleTextInputProtocol,
21
22    pub stdout_handle: Handle,
23    pub stdout: *mut SimpleTextOutputProtocol,
24
25    pub stderr_handle: Handle,
26    pub stderr: *mut SimpleTextOutputProtocol,
27
28    pub runtime_services: *mut RuntimeServices,
29    pub boot_services: *mut BootServices,
30
31    pub number_of_configuration_table_entries: usize,
32    pub configuration_table: *mut ConfigurationTable,
33}
34
35impl SystemTable {
36    pub const SIGNATURE: u64 = 0x5453_5953_2049_4249;
37}
38
39impl Default for SystemTable {
40    /// Create a `SystemTable` with most fields set to zero.
41    ///
42    /// The only fields not set to zero are:
43    /// * [`Header::signature`] is set to [`SystemTable::SIGNATURE`].
44    /// * [`Header::size`] is set to the size in bytes of `SystemTable`.
45    fn default() -> Self {
46        Self {
47            header: Header {
48                signature: Self::SIGNATURE,
49                size: u32::try_from(size_of::<Self>()).unwrap(),
50                ..Header::default()
51            },
52
53            firmware_vendor: ptr::null_mut(),
54            firmware_revision: 0,
55
56            stdin_handle: ptr::null_mut(),
57            stdin: ptr::null_mut(),
58
59            stdout_handle: ptr::null_mut(),
60            stdout: ptr::null_mut(),
61
62            stderr_handle: ptr::null_mut(),
63            stderr: ptr::null_mut(),
64
65            runtime_services: ptr::null_mut(),
66            boot_services: ptr::null_mut(),
67
68            number_of_configuration_table_entries: 0,
69            configuration_table: ptr::null_mut(),
70        }
71    }
72}