From 5c449f19cb067f87970dffdcc97cb3a874c144c8 Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 02:08:57 +0700 Subject: [PATCH 01/14] uefi: change `Fn` closure to `FnMut` --- uefi/src/system.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/uefi/src/system.rs b/uefi/src/system.rs index cdfcc81bd..134207289 100644 --- a/uefi/src/system.rs +++ b/uefi/src/system.rs @@ -51,9 +51,9 @@ pub fn uefi_revision() -> Revision { /// Call `f` with a slice of [`ConfigTableEntry`]. Each entry provides access to /// a vendor-specific table. -pub fn with_config_table(f: F) -> R +pub fn with_config_table(mut f: F) -> R where - F: Fn(&[ConfigTableEntry]) -> R, + F: FnMut(&[ConfigTableEntry]) -> R, { let st = table::system_table_raw_panicking(); // SAFETY: valid per requirements of `set_system_table`. @@ -75,9 +75,9 @@ where /// /// This function will panic if called after exiting boot services, or if stdin /// is not available. -pub fn with_stdin(f: F) -> R +pub fn with_stdin(mut f: F) -> R where - F: Fn(&mut Input) -> R, + F: FnMut(&mut Input) -> R, { let st = table::system_table_raw_panicking(); // SAFETY: valid per requirements of `set_system_table`. @@ -101,9 +101,9 @@ where /// /// This function will panic if called after exiting boot services, or if stdout /// is not available. -pub fn with_stdout(f: F) -> R +pub fn with_stdout(mut f: F) -> R where - F: Fn(&mut Output) -> R, + F: FnMut(&mut Output) -> R, { let st = table::system_table_raw_panicking(); // SAFETY: valid per requirements of `set_system_table`. @@ -127,9 +127,9 @@ where /// /// This function will panic if called after exiting boot services, or if stderr /// is not available. -pub fn with_stderr(f: F) -> R +pub fn with_stderr(mut f: F) -> R where - F: Fn(&mut Output) -> R, + F: FnMut(&mut Output) -> R, { let st = table::system_table_raw_panicking(); // SAFETY: valid per requirements of `set_system_table`. From 0f04e79b59b66f8bce46d87bc85d444b46a531bc Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 10:43:23 +0700 Subject: [PATCH 02/14] test: add with_config_table_compile_test --- uefi/src/system.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/uefi/src/system.rs b/uefi/src/system.rs index 134207289..f204c3cac 100644 --- a/uefi/src/system.rs +++ b/uefi/src/system.rs @@ -146,3 +146,22 @@ where f(stderr) } + +#[cfg(test)] +mod tests { + use super::*; + use crate::table::cfg::ACPI2_GUID; + + #[test] + fn with_config_table_compile_test() { + let mut address_acpi2 = None; + with_config_table(|slice| { + for i in slice { + match i.guid { + ACPI2_GUID => address_acpi2 = Some(i.address), + _ => {} + } + } + }); + } +} From 845f43de70e1096614d756bf1916194add94e33e Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 10:55:05 +0700 Subject: [PATCH 03/14] test: compile test only --- uefi/src/system.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uefi/src/system.rs b/uefi/src/system.rs index f204c3cac..942afd918 100644 --- a/uefi/src/system.rs +++ b/uefi/src/system.rs @@ -152,7 +152,7 @@ mod tests { use super::*; use crate::table::cfg::ACPI2_GUID; - #[test] + // compile test only fn with_config_table_compile_test() { let mut address_acpi2 = None; with_config_table(|slice| { From df4bb88afc6b1a19c76467f3c1d0d30da00f76eb Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 11:06:59 +0700 Subject: [PATCH 04/14] test: compile test only --- uefi/src/system.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/uefi/src/system.rs b/uefi/src/system.rs index 942afd918..ee053f680 100644 --- a/uefi/src/system.rs +++ b/uefi/src/system.rs @@ -153,6 +153,7 @@ mod tests { use crate::table::cfg::ACPI2_GUID; // compile test only + #[allow(dead_code)] fn with_config_table_compile_test() { let mut address_acpi2 = None; with_config_table(|slice| { From cd4ef6b8b531c893e3832302e42a76047d4dcac0 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 8 May 2025 11:25:43 -0400 Subject: [PATCH 05/14] xtask: Improve error message for enums in uefi-raw Instead of a generic "forbidden type of item" error, recommend using the `newtype_enum!` macro. --- xtask/src/check_raw.rs | 43 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/xtask/src/check_raw.rs b/xtask/src/check_raw.rs index 5d9ccb38d..a696fd175 100644 --- a/xtask/src/check_raw.rs +++ b/xtask/src/check_raw.rs @@ -23,12 +23,28 @@ use syn::{ }; use walkdir::WalkDir; +/// Type of an `Item`. +#[derive(Debug, Eq, PartialEq)] +enum ItemKind { + Enum, + Other, +} + +impl From<&Item> for ItemKind { + fn from(item: &Item) -> Self { + match item { + Item::Enum(_) => Self::Enum, + _ => Self::Other, + } + } +} + /// All possible validation error kinds. #[derive(Debug, Eq, PartialEq)] enum ErrorKind { ForbiddenAbi, ForbiddenAttr, - ForbiddenItemKind, + ForbiddenItemKind(ItemKind), ForbiddenRepr, ForbiddenType, MalformedAttrs, @@ -47,7 +63,9 @@ impl Display for ErrorKind { match self { Self::ForbiddenAbi => "forbidden ABI", Self::ForbiddenAttr => "forbidden attribute", - Self::ForbiddenItemKind => "forbidden type of item", + Self::ForbiddenItemKind(ItemKind::Enum) => + "forbidden use of enum; use the `newtype_enum!` macro instead", + Self::ForbiddenItemKind(_) => "forbidden type of item", Self::ForbiddenRepr => "forbidden repr", Self::ForbiddenType => "forbidden type", Self::MalformedAttrs => "malformed attribute contents", @@ -364,7 +382,11 @@ fn check_item(item: &Item, src: &Path) -> Result<(), Error> { // Allow. } item => { - return Err(Error::new(ErrorKind::ForbiddenItemKind, src, item)); + return Err(Error::new( + ErrorKind::ForbiddenItemKind(item.into()), + src, + item, + )); } } @@ -424,7 +446,7 @@ mod tests { } #[test] - fn test_invalid_item() { + fn test_invalid_item_enum() { // Rust enums are not allowed. check_item_err( parse_quote! { @@ -432,7 +454,18 @@ mod tests { A } }, - ErrorKind::ForbiddenItemKind, + ErrorKind::ForbiddenItemKind(ItemKind::Enum), + ); + } + + #[test] + fn test_invalid_item_other() { + // Top-level functions are not allowed. + check_item_err( + parse_quote! { + pub fn x() {} + }, + ErrorKind::ForbiddenItemKind(ItemKind::Other), ); } From 2b66913418caa485b6e8fbaa0b9b29e396845aea Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 01:25:00 +0700 Subject: [PATCH 06/14] uefi: move constants into ConfigTableEntry --- uefi/src/table/cfg.rs | 81 ++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/uefi/src/table/cfg.rs b/uefi/src/table/cfg.rs index bbeebe456..a1241f8dd 100644 --- a/uefi/src/table/cfg.rs +++ b/uefi/src/table/cfg.rs @@ -26,26 +26,53 @@ pub struct ConfigTableEntry { /// Whether this is a physical or virtual address depends on the table. pub address: *const c_void, } -/// Entry pointing to the old ACPI 1 RSDP. -pub const ACPI_GUID: Guid = guid!("eb9d2d30-2d88-11d3-9a16-0090273fc14d"); -///Entry pointing to the ACPI 2 RSDP. -pub const ACPI2_GUID: Guid = guid!("8868e871-e4f1-11d3-bc22-0080c73c8881"); +impl ConfigTableEntry { + /// Entry pointing to the old ACPI 1 RSDP. + pub const ACPI_GUID: Guid = guid!("eb9d2d30-2d88-11d3-9a16-0090273fc14d"); -/// Entry pointing to the SMBIOS 1.0 table. -pub const SMBIOS_GUID: Guid = guid!("eb9d2d31-2d88-11d3-9a16-0090273fc14d"); + /// Entry pointing to the ACPI 2 RSDP. + pub const ACPI2_GUID: Guid = guid!("8868e871-e4f1-11d3-bc22-0080c73c8881"); -/// Entry pointing to the SMBIOS 3.0 table. -pub const SMBIOS3_GUID: Guid = guid!("f2fd1544-9794-4a2c-992e-e5bbcf20e394"); + /// Entry pointing to the SMBIOS 1.0 table. + pub const SMBIOS_GUID: Guid = guid!("eb9d2d31-2d88-11d3-9a16-0090273fc14d"); -/// Entry pointing to the EFI System Resource table (ESRT). -pub const ESRT_GUID: Guid = guid!("b122a263-3661-4f68-9929-78f8b0d62180"); + /// Entry pointing to the SMBIOS 3.0 table. + pub const SMBIOS3_GUID: Guid = guid!("f2fd1544-9794-4a2c-992e-e5bbcf20e394"); -/// GUID of the UEFI properties table. -/// -/// The properties table is used to provide additional info -/// about the UEFI implementation. -pub const PROPERTIES_TABLE_GUID: Guid = guid!("880aaca3-4adc-4a04-9079-b747340825e5"); + /// Entry pointing to the EFI System Resource table (ESRT). + pub const ESRT_GUID: Guid = guid!("b122a263-3661-4f68-9929-78f8b0d62180"); + + /// Hand-off Blocks are used to pass data from the early pre-UEFI environment to the UEFI drivers. + /// + /// Most OS loaders or applications should not mess with this. + pub const HAND_OFF_BLOCK_LIST_GUID: Guid = guid!("7739f24c-93d7-11d4-9a3a-0090273fc14d"); + + /// Table used in the early boot environment to record memory ranges. + pub const MEMORY_TYPE_INFORMATION_GUID: Guid = guid!("4c19049f-4137-4dd3-9c10-8b97a83ffdfa"); + + /// Used to identify Hand-off Blocks which store + /// status codes reported during the pre-UEFI environment. + pub const MEMORY_STATUS_CODE_RECORD_GUID: Guid = guid!("060cc026-4c0d-4dda-8f41-595fef00a502"); + + /// Table which provides Driver eXecution Environment services. + pub const DXE_SERVICES_GUID: Guid = guid!("05ad34ba-6f02-4214-952e-4da0398e2bb9"); + + /// LZMA-compressed filesystem. + pub const LZMA_COMPRESS_GUID: Guid = guid!("ee4e5898-3914-4259-9d6e-dc7bd79403cf"); + + /// A custom compressed filesystem used by the Tiano UEFI implementation. + pub const TIANO_COMPRESS_GUID: Guid = guid!("a31280ad-481e-41b6-95e8-127f4c984779"); + + /// Pointer to the debug image info table. + pub const DEBUG_IMAGE_INFO_GUID: Guid = guid!("49152e77-1ada-4764-b7a2-7afefed95e8b"); + + /// GUID of the UEFI properties table. + /// + /// The properties table is used to provide additional info + /// about the UEFI implementation. + pub const PROPERTIES_TABLE_GUID: Guid = guid!("880aaca3-4adc-4a04-9079-b747340825e5"); +} /// This table contains additional information about the UEFI implementation. #[repr(C)] @@ -73,27 +100,3 @@ bitflags! { const NON_EXECUTABLE_DATA = 1; } } - -/// Hand-off Blocks are used to pass data from the early pre-UEFI environment to the UEFI drivers. -/// -/// Most OS loaders or applications should not mess with this. -pub const HAND_OFF_BLOCK_LIST_GUID: Guid = guid!("7739f24c-93d7-11d4-9a3a-0090273fc14d"); - -/// Table used in the early boot environment to record memory ranges. -pub const MEMORY_TYPE_INFORMATION_GUID: Guid = guid!("4c19049f-4137-4dd3-9c10-8b97a83ffdfa"); - -/// Used to identify Hand-off Blocks which store -/// status codes reported during the pre-UEFI environment. -pub const MEMORY_STATUS_CODE_RECORD_GUID: Guid = guid!("060cc026-4c0d-4dda-8f41-595fef00a502"); - -/// Table which provides Driver eXecution Environment services. -pub const DXE_SERVICES_GUID: Guid = guid!("05ad34ba-6f02-4214-952e-4da0398e2bb9"); - -/// LZMA-compressed filesystem. -pub const LZMA_COMPRESS_GUID: Guid = guid!("ee4e5898-3914-4259-9d6e-dc7bd79403cf"); - -/// A custom compressed filesystem used by the Tiano UEFI implementation. -pub const TIANO_COMPRESS_GUID: Guid = guid!("a31280ad-481e-41b6-95e8-127f4c984779"); - -/// Pointer to the debug image info table. -pub const DEBUG_IMAGE_INFO_GUID: Guid = guid!("49152e77-1ada-4764-b7a2-7afefed95e8b"); From 747273a4446c39e0fd921319e2b40bce7c834c73 Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 01:26:36 +0700 Subject: [PATCH 07/14] uefi: ConfigTableEntry add two GUID --- uefi/src/table/cfg.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/uefi/src/table/cfg.rs b/uefi/src/table/cfg.rs index a1241f8dd..a7a91d051 100644 --- a/uefi/src/table/cfg.rs +++ b/uefi/src/table/cfg.rs @@ -55,6 +55,16 @@ impl ConfigTableEntry { /// status codes reported during the pre-UEFI environment. pub const MEMORY_STATUS_CODE_RECORD_GUID: Guid = guid!("060cc026-4c0d-4dda-8f41-595fef00a502"); + /// Provides additional information about regions within the run-time memory blocks. + /// + /// https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-memory-attributes-table + pub const MEMORY_ATTRIBUTES_GUID: Guid = guid!("dcfa911d-26eb-469f-a220-38b7dc461220"); + + /// Constants used for UEFI signature database variable access. + /// + /// https://uefi.org/specs/UEFI/2.11/32_Secure_Boot_and_Driver_Signing.html#uefi-image-variable-guid-variable-name + pub const IMAGE_SECURITY_DATABASE_GUID: Guid = guid!("d719b2cb-3d3a-4596-a3bc-dad00e67656f"); + /// Table which provides Driver eXecution Environment services. pub const DXE_SERVICES_GUID: Guid = guid!("05ad34ba-6f02-4214-952e-4da0398e2bb9"); From 122943a9f7a24325a6c8bc152bb5c53155259191 Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 01:27:21 +0700 Subject: [PATCH 08/14] doc: add example use uefi::table::cfg::ConfigTableEntry --- uefi/src/system.rs | 18 ++++++++++++++++++ uefi/src/table/cfg.rs | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/uefi/src/system.rs b/uefi/src/system.rs index ee053f680..473d4de41 100644 --- a/uefi/src/system.rs +++ b/uefi/src/system.rs @@ -51,6 +51,24 @@ pub fn uefi_revision() -> Revision { /// Call `f` with a slice of [`ConfigTableEntry`]. Each entry provides access to /// a vendor-specific table. +/// +/// # Example +/// +/// ```rust,no_run +/// use uefi::system::with_config_table; +/// use uefi::table::cfg::ConfigTableEntry; +/// +/// with_config_table(|slice| { +/// for i in slice { +/// match i.guid { +/// ConfigTableEntry::ACPI_GUID => println!("ACPI"), +/// ConfigTableEntry::ACPI2_GUID => println!("ACPI2"), +/// guid => println!("GUID: {}", guid), +/// } +/// } +/// }); +/// ``` +pub fn with_config_table(f: F) -> R pub fn with_config_table(mut f: F) -> R where F: FnMut(&[ConfigTableEntry]) -> R, diff --git a/uefi/src/table/cfg.rs b/uefi/src/table/cfg.rs index a7a91d051..5adc7fc54 100644 --- a/uefi/src/table/cfg.rs +++ b/uefi/src/table/cfg.rs @@ -8,6 +8,8 @@ //! //! This module contains the actual entries of the configuration table, //! as well as GUIDs for many known vendor tables. +//! +//! https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-configuration-table-properties-table use crate::{guid, Guid}; use bitflags::bitflags; @@ -16,6 +18,8 @@ use core::ffi::c_void; /// Contains a set of GUID / pointer for a vendor-specific table. /// /// The UEFI standard guarantees each entry is unique. +/// +/// https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-configuration-table #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(C)] pub struct ConfigTableEntry { From ea342cb802504d1aa1cfebfa54c1990ae1eabe41 Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 01:36:31 +0700 Subject: [PATCH 09/14] doc: changelog --- uefi/CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 2cac6355a..61c29e4cc 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -1,8 +1,11 @@ # uefi - [Unreleased] +## Added +- Added `ConfigTableEntry::MEMORY_ATTRIBUTES_GUID` and `ConfigTableEntry::IMAGE_SECURITY_DATABASE_GUID`. + ## Changed -- **Breaking:** `boot::stall` now take `Duration` instead of - `usize`. +- **Breaking:** `boot::stall` now take `core::time::Duration` instead of `usize`. +- **Breaking:** `*_GUID` constants has been moved to `ConfigTableEntry::*_GUID`. # uefi - 0.35.0 (2025-05-04) From 1dd667c612b4ff81dc9ff7eb3ef51cf62ddf5004 Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 01:44:12 +0700 Subject: [PATCH 10/14] lints: format --- uefi/src/table/cfg.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uefi/src/table/cfg.rs b/uefi/src/table/cfg.rs index 5adc7fc54..270d7df77 100644 --- a/uefi/src/table/cfg.rs +++ b/uefi/src/table/cfg.rs @@ -8,7 +8,7 @@ //! //! This module contains the actual entries of the configuration table, //! as well as GUIDs for many known vendor tables. -//! +//! //! https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-configuration-table-properties-table use crate::{guid, Guid}; @@ -18,7 +18,7 @@ use core::ffi::c_void; /// Contains a set of GUID / pointer for a vendor-specific table. /// /// The UEFI standard guarantees each entry is unique. -/// +/// /// https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-configuration-table #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(C)] @@ -60,12 +60,12 @@ impl ConfigTableEntry { pub const MEMORY_STATUS_CODE_RECORD_GUID: Guid = guid!("060cc026-4c0d-4dda-8f41-595fef00a502"); /// Provides additional information about regions within the run-time memory blocks. - /// + /// /// https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-memory-attributes-table pub const MEMORY_ATTRIBUTES_GUID: Guid = guid!("dcfa911d-26eb-469f-a220-38b7dc461220"); /// Constants used for UEFI signature database variable access. - /// + /// /// https://uefi.org/specs/UEFI/2.11/32_Secure_Boot_and_Driver_Signing.html#uefi-image-variable-guid-variable-name pub const IMAGE_SECURITY_DATABASE_GUID: Guid = guid!("d719b2cb-3d3a-4596-a3bc-dad00e67656f"); From d644a5d8dec093e498569eea845bf040c048bb91 Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 01:50:33 +0700 Subject: [PATCH 11/14] doc: fix URL errors --- uefi/src/table/cfg.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/uefi/src/table/cfg.rs b/uefi/src/table/cfg.rs index 270d7df77..0aff1374f 100644 --- a/uefi/src/table/cfg.rs +++ b/uefi/src/table/cfg.rs @@ -9,7 +9,7 @@ //! This module contains the actual entries of the configuration table, //! as well as GUIDs for many known vendor tables. //! -//! https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-configuration-table-properties-table +//! See . use crate::{guid, Guid}; use bitflags::bitflags; @@ -19,7 +19,7 @@ use core::ffi::c_void; /// /// The UEFI standard guarantees each entry is unique. /// -/// https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-configuration-table +/// See . #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(C)] pub struct ConfigTableEntry { @@ -60,13 +60,11 @@ impl ConfigTableEntry { pub const MEMORY_STATUS_CODE_RECORD_GUID: Guid = guid!("060cc026-4c0d-4dda-8f41-595fef00a502"); /// Provides additional information about regions within the run-time memory blocks. - /// - /// https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-memory-attributes-table + /// See . pub const MEMORY_ATTRIBUTES_GUID: Guid = guid!("dcfa911d-26eb-469f-a220-38b7dc461220"); /// Constants used for UEFI signature database variable access. - /// - /// https://uefi.org/specs/UEFI/2.11/32_Secure_Boot_and_Driver_Signing.html#uefi-image-variable-guid-variable-name + /// See . pub const IMAGE_SECURITY_DATABASE_GUID: Guid = guid!("d719b2cb-3d3a-4596-a3bc-dad00e67656f"); /// Table which provides Driver eXecution Environment services. From e36eeba231ab4dde9b6f668b1f2cfdcb504d3fce Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Sat, 10 May 2025 13:26:28 +0700 Subject: [PATCH 12/14] uefi: `table::cfg::*_GUID` constants now deprecated --- uefi/CHANGELOG.md | 2 +- uefi/src/system.rs | 6 +-- uefi/src/table/cfg.rs | 96 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 4 deletions(-) diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 61c29e4cc..fbd8c4c3a 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -5,7 +5,7 @@ ## Changed - **Breaking:** `boot::stall` now take `core::time::Duration` instead of `usize`. -- **Breaking:** `*_GUID` constants has been moved to `ConfigTableEntry::*_GUID`. +- `table::cfg::*_GUID` constants now deprecated. Use `ConfigTableEntry::*_GUID` instead. # uefi - 0.35.0 (2025-05-04) diff --git a/uefi/src/system.rs b/uefi/src/system.rs index 473d4de41..2f4374aee 100644 --- a/uefi/src/system.rs +++ b/uefi/src/system.rs @@ -61,9 +61,9 @@ pub fn uefi_revision() -> Revision { /// with_config_table(|slice| { /// for i in slice { /// match i.guid { -/// ConfigTableEntry::ACPI_GUID => println!("ACPI"), -/// ConfigTableEntry::ACPI2_GUID => println!("ACPI2"), -/// guid => println!("GUID: {}", guid), +/// ConfigTableEntry::ACPI_GUID => println!("Found ACPI1"), +/// ConfigTableEntry::ACPI2_GUID => println!("Found ACPI2"), +/// guid => println!("Found {}", guid), /// } /// } /// }); diff --git a/uefi/src/table/cfg.rs b/uefi/src/table/cfg.rs index 0aff1374f..408871591 100644 --- a/uefi/src/table/cfg.rs +++ b/uefi/src/table/cfg.rs @@ -86,6 +86,51 @@ impl ConfigTableEntry { pub const PROPERTIES_TABLE_GUID: Guid = guid!("880aaca3-4adc-4a04-9079-b747340825e5"); } +/// Entry pointing to the old ACPI 1 RSDP. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::ACPI_GUID` instead" +)] +pub const ACPI_GUID: Guid = ConfigTableEntry::ACPI_GUID; + +/// Entry pointing to the ACPI 2 RSDP. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::ACPI2_GUID` instead" +)] +pub const ACPI2_GUID: Guid = ConfigTableEntry::ACPI2_GUID; + +/// Entry pointing to the SMBIOS 1.0 table. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::SMBIOS_GUID` instead" +)] +pub const SMBIOS_GUID: Guid = ConfigTableEntry::SMBIOS_GUID; + +/// Entry pointing to the SMBIOS 3.0 table. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::SMBIOS3_GUID` instead" +)] +pub const SMBIOS3_GUID: Guid = ConfigTableEntry::SMBIOS3_GUID; + +/// Entry pointing to the EFI System Resource table (ESRT). +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::ESRT_GUID` instead" +)] +pub const ESRT_GUID: Guid = ConfigTableEntry::ESRT_GUID; + +/// GUID of the UEFI properties table. +/// +/// The properties table is used to provide additional info +/// about the UEFI implementation. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::PROPERTIES_TABLE_GUID` instead" +)] +pub const PROPERTIES_TABLE_GUID: Guid = ConfigTableEntry::PROPERTIES_TABLE_GUID; + /// This table contains additional information about the UEFI implementation. #[repr(C)] #[derive(Debug)] @@ -112,3 +157,54 @@ bitflags! { const NON_EXECUTABLE_DATA = 1; } } + +/// Hand-off Blocks are used to pass data from the early pre-UEFI environment to the UEFI drivers. +/// +/// Most OS loaders or applications should not mess with this. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::HAND_OFF_BLOCK_LIST_GUID` instead" +)] +pub const HAND_OFF_BLOCK_LIST_GUID: Guid = ConfigTableEntry::HAND_OFF_BLOCK_LIST_GUID; + +/// Table used in the early boot environment to record memory ranges. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::MEMORY_TYPE_INFORMATION_GUID` instead" +)] +pub const MEMORY_TYPE_INFORMATION_GUID: Guid = ConfigTableEntry::MEMORY_TYPE_INFORMATION_GUID; + +/// Used to identify Hand-off Blocks which store +/// status codes reported during the pre-UEFI environment. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::MEMORY_STATUS_CODE_RECORD_GUID` instead" +)] +pub const MEMORY_STATUS_CODE_RECORD_GUID: Guid = ConfigTableEntry::MEMORY_STATUS_CODE_RECORD_GUID; + +/// Table which provides Driver eXecution Environment services. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::DXE_SERVICES_GUID` instead" +)] +pub const DXE_SERVICES_GUID: Guid = ConfigTableEntry::DXE_SERVICES_GUID; + +/// LZMA-compressed filesystem. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::LZMA_COMPRESS_GUID` instead" +)] +pub const LZMA_COMPRESS_GUID: Guid = ConfigTableEntry::LZMA_COMPRESS_GUID; + +/// A custom compressed filesystem used by the Tiano UEFI implementation. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::TIANO_COMPRESS_GUID` instead" +)] +pub const TIANO_COMPRESS_GUID: Guid = ConfigTableEntry::TIANO_COMPRESS_GUID; +/// Pointer to the debug image info table. +#[deprecated( + since = "0.35.1", + note = "please use `ConfigTableEntry::DEBUG_IMAGE_INFO_GUID` instead" +)] +pub const DEBUG_IMAGE_INFO_GUID: Guid = ConfigTableEntry::DEBUG_IMAGE_INFO_GUID; From 6af1d9ec33573cbf16db4ce98632afa0ace5c9c8 Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Fri, 9 May 2025 02:08:57 +0700 Subject: [PATCH 13/14] uefi: change `Fn` closure to `FnMut` --- uefi/src/system.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/uefi/src/system.rs b/uefi/src/system.rs index 2f4374aee..76f0a305d 100644 --- a/uefi/src/system.rs +++ b/uefi/src/system.rs @@ -68,7 +68,6 @@ pub fn uefi_revision() -> Revision { /// } /// }); /// ``` -pub fn with_config_table(f: F) -> R pub fn with_config_table(mut f: F) -> R where F: FnMut(&[ConfigTableEntry]) -> R, @@ -170,14 +169,18 @@ mod tests { use super::*; use crate::table::cfg::ACPI2_GUID; - // compile test only #[allow(dead_code)] + #[allow(clippy::assertions_on_constants)] fn with_config_table_compile_test() { - let mut address_acpi2 = None; + assert!(false, "compile test only"); + let mut acpi2_address = None; with_config_table(|slice| { for i in slice { match i.guid { - ACPI2_GUID => address_acpi2 = Some(i.address), + ACPI2_GUID => { + acpi2_address = Some(i.address); + break; + } _ => {} } } From 70822d391c0754b780edfee2e9a8d4f2669e7bc5 Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Sun, 11 May 2025 11:00:58 +0700 Subject: [PATCH 14/14] doc: changelog --- uefi/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index fbd8c4c3a..838e1173c 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -6,6 +6,8 @@ ## Changed - **Breaking:** `boot::stall` now take `core::time::Duration` instead of `usize`. - `table::cfg::*_GUID` constants now deprecated. Use `ConfigTableEntry::*_GUID` instead. +- `system::with_config_table`, `system::with_stdin`, `system::with_stdout` and `system::with_stderr` + now take mutably closure. # uefi - 0.35.0 (2025-05-04)