Skip to content

Commit 01cc917

Browse files
uefi-raw: Add SystemTable
1 parent 12e4a20 commit 01cc917

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

uefi-raw/src/table/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod revision;
66
pub mod boot;
77
pub mod configuration;
88
pub mod runtime;
9+
pub mod system;
910

1011
pub use header::Header;
1112
pub use revision::Revision;

uefi-raw/src/table/system.rs

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

0 commit comments

Comments
 (0)