uefi/table/
cfg.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! Configuration table utilities.
4//!
5//! The configuration table is an array of GUIDs and pointers to extra system tables.
6//!
7//! For example, it can be used to find the ACPI tables.
8//!
9//! This module contains the actual entries of the configuration table,
10//! as well as GUIDs for many known vendor tables.
11//!
12//! See <https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-configuration-table-properties-table>.
13
14use crate::{Guid, guid};
15use bitflags::bitflags;
16use core::ffi::c_void;
17
18/// Contains a set of GUID / pointer for a vendor-specific table.
19///
20/// The UEFI standard guarantees each entry is unique.
21///
22/// See <https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-configuration-table>.
23#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
24#[repr(C)]
25pub struct ConfigTableEntry {
26    /// The GUID identifying this table.
27    pub guid: Guid,
28    /// The starting address of this table.
29    ///
30    /// Whether this is a physical or virtual address depends on the table.
31    pub address: *const c_void,
32}
33
34impl ConfigTableEntry {
35    /// Entry pointing to the old ACPI 1 RSDP.
36    pub const ACPI_GUID: Guid = guid!("eb9d2d30-2d88-11d3-9a16-0090273fc14d");
37
38    /// Entry pointing to the ACPI 2 RSDP.
39    pub const ACPI2_GUID: Guid = guid!("8868e871-e4f1-11d3-bc22-0080c73c8881");
40
41    /// Entry pointing to the SMBIOS 1.0 table.
42    pub const SMBIOS_GUID: Guid = guid!("eb9d2d31-2d88-11d3-9a16-0090273fc14d");
43
44    /// Entry pointing to the SMBIOS 3.0 table.
45    pub const SMBIOS3_GUID: Guid = guid!("f2fd1544-9794-4a2c-992e-e5bbcf20e394");
46
47    /// Entry pointing to the EFI System Resource table (ESRT).
48    pub const ESRT_GUID: Guid = guid!("b122a263-3661-4f68-9929-78f8b0d62180");
49
50    /// Hand-off Blocks are used to pass data from the early pre-UEFI environment to the UEFI drivers.
51    ///
52    /// Most OS loaders or applications should not mess with this.
53    pub const HAND_OFF_BLOCK_LIST_GUID: Guid = guid!("7739f24c-93d7-11d4-9a3a-0090273fc14d");
54
55    /// Table used in the early boot environment to record memory ranges.
56    pub const MEMORY_TYPE_INFORMATION_GUID: Guid = guid!("4c19049f-4137-4dd3-9c10-8b97a83ffdfa");
57
58    /// Used to identify Hand-off Blocks which store
59    /// status codes reported during the pre-UEFI environment.
60    pub const MEMORY_STATUS_CODE_RECORD_GUID: Guid = guid!("060cc026-4c0d-4dda-8f41-595fef00a502");
61
62    /// Provides additional information about regions within the run-time memory blocks.
63    /// See <https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-memory-attributes-table>.
64    pub const MEMORY_ATTRIBUTES_GUID: Guid = guid!("dcfa911d-26eb-469f-a220-38b7dc461220");
65
66    /// Constants used for UEFI signature database variable access.
67    /// See <https://uefi.org/specs/UEFI/2.11/32_Secure_Boot_and_Driver_Signing.html#uefi-image-variable-guid-variable-name>.
68    pub const IMAGE_SECURITY_DATABASE_GUID: Guid = guid!("d719b2cb-3d3a-4596-a3bc-dad00e67656f");
69
70    /// Table which provides Driver eXecution Environment services.
71    pub const DXE_SERVICES_GUID: Guid = guid!("05ad34ba-6f02-4214-952e-4da0398e2bb9");
72
73    /// LZMA-compressed filesystem.
74    pub const LZMA_COMPRESS_GUID: Guid = guid!("ee4e5898-3914-4259-9d6e-dc7bd79403cf");
75
76    /// A custom compressed filesystem used by the Tiano UEFI implementation.
77    pub const TIANO_COMPRESS_GUID: Guid = guid!("a31280ad-481e-41b6-95e8-127f4c984779");
78
79    /// Pointer to the debug image info table.
80    pub const DEBUG_IMAGE_INFO_GUID: Guid = guid!("49152e77-1ada-4764-b7a2-7afefed95e8b");
81
82    /// GUID of the UEFI properties table.
83    ///
84    /// The properties table is used to provide additional info
85    /// about the UEFI implementation.
86    pub const PROPERTIES_TABLE_GUID: Guid = guid!("880aaca3-4adc-4a04-9079-b747340825e5");
87}
88
89/// Entry pointing to the old ACPI 1 RSDP.
90#[deprecated(
91    since = "0.36.0",
92    note = "please use `ConfigTableEntry::ACPI_GUID` instead"
93)]
94pub const ACPI_GUID: Guid = ConfigTableEntry::ACPI_GUID;
95
96/// Entry pointing to the ACPI 2 RSDP.
97#[deprecated(
98    since = "0.36.0",
99    note = "please use `ConfigTableEntry::ACPI2_GUID` instead"
100)]
101pub const ACPI2_GUID: Guid = ConfigTableEntry::ACPI2_GUID;
102
103/// Entry pointing to the SMBIOS 1.0 table.
104#[deprecated(
105    since = "0.36.0",
106    note = "please use `ConfigTableEntry::SMBIOS_GUID` instead"
107)]
108pub const SMBIOS_GUID: Guid = ConfigTableEntry::SMBIOS_GUID;
109
110/// Entry pointing to the SMBIOS 3.0 table.
111#[deprecated(
112    since = "0.36.0",
113    note = "please use `ConfigTableEntry::SMBIOS3_GUID` instead"
114)]
115pub const SMBIOS3_GUID: Guid = ConfigTableEntry::SMBIOS3_GUID;
116
117/// Entry pointing to the EFI System Resource table (ESRT).
118#[deprecated(
119    since = "0.36.0",
120    note = "please use `ConfigTableEntry::ESRT_GUID` instead"
121)]
122pub const ESRT_GUID: Guid = ConfigTableEntry::ESRT_GUID;
123
124/// GUID of the UEFI properties table.
125///
126/// The properties table is used to provide additional info
127/// about the UEFI implementation.
128#[deprecated(
129    since = "0.36.0",
130    note = "please use `ConfigTableEntry::PROPERTIES_TABLE_GUID` instead"
131)]
132pub const PROPERTIES_TABLE_GUID: Guid = ConfigTableEntry::PROPERTIES_TABLE_GUID;
133
134/// This table contains additional information about the UEFI implementation.
135#[repr(C)]
136#[derive(Debug)]
137pub struct PropertiesTable {
138    /// Version of the UEFI properties table.
139    ///
140    /// The only valid version currently is 0x10_000.
141    pub version: u32,
142    /// Length in bytes of this table.
143    ///
144    /// The initial version's length is 16.
145    pub length: u32,
146    /// Memory protection attributes.
147    pub memory_protection: MemoryProtectionAttribute,
148}
149
150bitflags! {
151    /// Flags describing memory protection.
152    #[repr(transparent)]
153    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
154    pub struct MemoryProtectionAttribute: usize {
155        /// If this bit is set, then the UEFI implementation will mark pages
156        /// containing data as non-executable.
157        const NON_EXECUTABLE_DATA = 1;
158    }
159}
160
161/// Hand-off Blocks are used to pass data from the early pre-UEFI environment to the UEFI drivers.
162///
163/// Most OS loaders or applications should not mess with this.
164#[deprecated(
165    since = "0.36.0",
166    note = "please use `ConfigTableEntry::HAND_OFF_BLOCK_LIST_GUID` instead"
167)]
168pub const HAND_OFF_BLOCK_LIST_GUID: Guid = ConfigTableEntry::HAND_OFF_BLOCK_LIST_GUID;
169
170/// Table used in the early boot environment to record memory ranges.
171#[deprecated(
172    since = "0.36.0",
173    note = "please use `ConfigTableEntry::MEMORY_TYPE_INFORMATION_GUID` instead"
174)]
175pub const MEMORY_TYPE_INFORMATION_GUID: Guid = ConfigTableEntry::MEMORY_TYPE_INFORMATION_GUID;
176
177/// Used to identify Hand-off Blocks which store
178/// status codes reported during the pre-UEFI environment.
179#[deprecated(
180    since = "0.36.0",
181    note = "please use `ConfigTableEntry::MEMORY_STATUS_CODE_RECORD_GUID` instead"
182)]
183pub const MEMORY_STATUS_CODE_RECORD_GUID: Guid = ConfigTableEntry::MEMORY_STATUS_CODE_RECORD_GUID;
184
185/// Table which provides Driver eXecution Environment services.
186#[deprecated(
187    since = "0.36.0",
188    note = "please use `ConfigTableEntry::DXE_SERVICES_GUID` instead"
189)]
190pub const DXE_SERVICES_GUID: Guid = ConfigTableEntry::DXE_SERVICES_GUID;
191
192/// LZMA-compressed filesystem.
193#[deprecated(
194    since = "0.36.0",
195    note = "please use `ConfigTableEntry::LZMA_COMPRESS_GUID` instead"
196)]
197pub const LZMA_COMPRESS_GUID: Guid = ConfigTableEntry::LZMA_COMPRESS_GUID;
198
199/// A custom compressed filesystem used by the Tiano UEFI implementation.
200#[deprecated(
201    since = "0.36.0",
202    note = "please use `ConfigTableEntry::TIANO_COMPRESS_GUID` instead"
203)]
204pub const TIANO_COMPRESS_GUID: Guid = ConfigTableEntry::TIANO_COMPRESS_GUID;
205/// Pointer to the debug image info table.
206#[deprecated(
207    since = "0.36.0",
208    note = "please use `ConfigTableEntry::DEBUG_IMAGE_INFO_GUID` instead"
209)]
210pub const DEBUG_IMAGE_INFO_GUID: Guid = ConfigTableEntry::DEBUG_IMAGE_INFO_GUID;