Skip to content

Commit d21fdc5

Browse files
authored
Merge pull request #870 from nicholasbishop/bishop-raw-system-table
uefi-raw: Add SystemTable
2 parents 163aea3 + 01cc917 commit d21fdc5

File tree

4 files changed

+73
-2
lines changed

4 files changed

+73
-2
lines changed

uefi-raw/src/table/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::Revision;
22

33
/// The common header that all UEFI tables begin with.
4-
#[derive(Debug)]
4+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
55
#[repr(C)]
66
pub struct Header {
77
/// Unique identifier for this table.

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/revision.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use core::fmt;
3030
/// assert_eq!(Revision::EFI_2_31.to_string(), "2.3.1");
3131
/// assert_eq!(Revision::EFI_2_100.to_string(), "2.10");
3232
/// ```
33-
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
33+
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd)]
3434
#[repr(transparent)]
3535
pub struct Revision(pub u32);
3636

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)