From 8c39c0c7c55a6c8c76926445e72165eca29b17c8 Mon Sep 17 00:00:00 2001 From: Tim Crawford <tcrawford@system76.com> Date: Tue, 17 Dec 2024 13:50:12 -0700 Subject: [PATCH] Make protocol GUIDs associated constants Signed-off-by: Tim Crawford <tcrawford@system76.com> --- crates/uefi/src/block_io.rs | 4 ++++ crates/uefi/src/component_name.rs | 4 ++++ crates/uefi/src/device.rs | 4 ++++ crates/uefi/src/fs.rs | 8 ++++++++ crates/uefi/src/graphics.rs | 4 ++++ crates/uefi/src/guid.rs | 12 ++++++++++++ crates/uefi/src/hii/database.rs | 8 +++++--- crates/uefi/src/loaded_image.rs | 4 ++++ crates/uefi/src/pointer.rs | 4 ++++ crates/uefi/src/shell.rs | 8 ++++++++ crates/uefi/src/text.rs | 4 ++++ crates/uefi_std/src/fs.rs | 5 ++--- crates/uefi_std/src/loaded_image.rs | 3 +-- crates/uefi_std/src/pointer.rs | 3 +-- crates/uefi_std/src/shell.rs | 3 +-- 15 files changed, 66 insertions(+), 12 deletions(-) diff --git a/crates/uefi/src/block_io.rs b/crates/uefi/src/block_io.rs index 251df43..05b3e4c 100644 --- a/crates/uefi/src/block_io.rs +++ b/crates/uefi/src/block_io.rs @@ -34,3 +34,7 @@ pub struct BlockIo { ) -> Status, pub FlushBlocks: extern "efiapi" fn(&BlockIo) -> Status, } + +impl BlockIo { + pub const GUID: Guid = guid!("964e5b21-6459-11d2-8e39-00a0c969723b"); +} diff --git a/crates/uefi/src/component_name.rs b/crates/uefi/src/component_name.rs index be69bfa..70ed571 100644 --- a/crates/uefi/src/component_name.rs +++ b/crates/uefi/src/component_name.rs @@ -13,3 +13,7 @@ pub struct ComponentName { ) -> Status, pub SupportedLanguages: *const u8, } + +impl ComponentName { + pub const GUID: Guid = guid!("6a7a5cff-e8d9-4f70-bada-75ab3025ce14"); +} diff --git a/crates/uefi/src/device.rs b/crates/uefi/src/device.rs index f70e91c..3206c64 100644 --- a/crates/uefi/src/device.rs +++ b/crates/uefi/src/device.rs @@ -96,6 +96,10 @@ pub struct DevicePath { pub Length: u16, } +impl DevicePath { + pub const GUID: Guid = guid!("09576e91-6d3f-11d2-8e39-00a0c969723b"); +} + #[repr(C)] pub struct VendorDevicePath { pub Header: DevicePath, diff --git a/crates/uefi/src/fs.rs b/crates/uefi/src/fs.rs index 9c2254f..2e7085b 100644 --- a/crates/uefi/src/fs.rs +++ b/crates/uefi/src/fs.rs @@ -20,6 +20,10 @@ pub struct SimpleFileSystem { pub OpenVolume: extern "efiapi" fn(&mut SimpleFileSystem, Root: &mut *mut File) -> Status, } +impl SimpleFileSystem { + pub const GUID: Guid = guid!("964e5b22-6459-11d2-8e39-00a0c969723b"); +} + #[repr(C)] pub struct FileInfo { pub Size: u64, @@ -47,6 +51,10 @@ impl Default for FileInfo { } } +impl FileInfo { + pub const ID: Guid = guid!("09576e92-6d3f-11d2-8e39-00a0c969723b"); +} + #[repr(C)] pub struct File { pub Revision: u64, diff --git a/crates/uefi/src/graphics.rs b/crates/uefi/src/graphics.rs index d99d4ce..987798d 100644 --- a/crates/uefi/src/graphics.rs +++ b/crates/uefi/src/graphics.rs @@ -126,3 +126,7 @@ pub struct GraphicsOutput { ) -> Status, pub Mode: &'static mut GraphicsOutputMode, } + +impl GraphicsOutput { + pub const GUID: Guid = guid!("9042a9de-23dc-4a38-96fb-7aded080516a"); +} diff --git a/crates/uefi/src/guid.rs b/crates/uefi/src/guid.rs index 720efed..c664dfa 100644 --- a/crates/uefi/src/guid.rs +++ b/crates/uefi/src/guid.rs @@ -39,20 +39,27 @@ pub const SMBIOS3_TABLE_GUID: Guid = guid!("f2fd1544-9794-4a2c-992e-e5bbcf20e394 pub const SAL_SYSTEM_TABLE_GUID: Guid = guid!("eb9d2d32-2d88-11d3-9a16-0090273fc14d"); pub const HCDP_TABLE_GUID: Guid = guid!("f951938d-620b-42ef-8279-a84b79617898"); pub const UGA_IO_PROTOCOL_GUID: Guid = guid!("61a4d49e-6f68-4f1b-b922-a86eed0b07a2"); +#[deprecated(note = "use `TextOutput::GUID`")] pub const SIMPLE_TEXT_OUTPUT_GUID: Guid = guid!("387477c2-69c7-11d2-8e39-00a0c969723b"); pub const GLOBAL_VARIABLE_GUID: Guid = guid!("8be4df61-93ca-11d2-aa0d-00e098032b8c"); pub const UV_SYSTEM_TABLE_GUID: Guid = guid!("3b13a7d4-633e-11dd-93ec-da2556d89593"); pub const LINUX_EFI_CRASH_GUID: Guid = guid!("cfc8fc79-be2e-4ddc-97f0-9f98bfe298a0"); +#[deprecated(note = "use `LoadedImage::GUID`")] pub const LOADED_IMAGE_PROTOCOL_GUID: Guid = guid!("5b1b31a1-9562-11d2-8e3f-00a0c969723b"); pub const LOADED_IMAGE_DEVICE_PATH_GUID: Guid = guid!("bc62157e-3e33-4fec-9920-2d3b36d750df"); +#[deprecated(note = "use `GraphicsOutput::GUID`")] pub const GRAPHICS_OUTPUT_PROTOCOL_GUID: Guid = guid!("9042a9de-23dc-4a38-96fb-7aded080516a"); pub const UGA_PROTOCOL_GUID: Guid = guid!("982c298b-f4fa-41cb-b838-77aa688fb839"); pub const PCI_IO_PROTOCOL_GUID: Guid = guid!("4cf5b200-68b8-4ca5-9eec-b23e3f50029a"); +#[deprecated(note = "use `FileInfo::ID`")] pub const FILE_INFO_ID: Guid = guid!("09576e92-6d3f-11d2-8e39-00a0c969723b"); pub const SYSTEM_RESOURCE_TABLE_GUID: Guid = guid!("b122a263-3661-4f68-9929-78f8b0d62180"); +#[deprecated(note = "use `BlockIo::GUID`")] pub const BLOCK_IO_GUID: Guid = guid!("964e5b21-6459-11d2-8e39-00a0c969723b"); +#[deprecated(note = "use `SimplFileSystem::GUID`")] pub const FILE_SYSTEM_GUID: Guid = guid!("964e5b22-6459-11d2-8e39-00a0c969723b"); pub const LOAD_FILE_GUID: Guid = guid!("56ec3091-954c-11d2-8e3f-00a0c969723b"); +#[deprecated(note = "use `DevicePath::GUID`")] pub const DEVICE_PATH_GUID: Guid = guid!("09576e91-6d3f-11d2-8e39-00a0c969723b"); pub const DEVICE_TREE_GUID: Guid = guid!("b1b621d5-f19c-41a5-830b-d9152c69aae0"); pub const PROPERTIES_TABLE_GUID: Guid = guid!("880aaca3-4adc-4a04-9079-b747340825e5"); @@ -66,10 +73,15 @@ pub const DXE_SERVICES_TABLE_GUID: Guid = guid!("05ad34ba-6f02-4214-952e-4da0398 pub const HOB_LIST_GUID: Guid = guid!("7739f24c-93d7-11d4-9a3a-0090273fc14d"); pub const MEMORY_TYPE_INFORMATION_GUID: Guid = guid!("4c19049f-4137-4dd3-9c10-8b97a83ffdfa"); pub const DEBUG_IMAGE_INFO_TABLE_GUID: Guid = guid!("49152e77-1ada-4764-b7a2-7afefed95e8b"); +#[deprecated(note = "use `Shell::GUID`")] pub const SHELL_GUID: Guid = guid!("6302d008-7f9b-4f30-87ac-60c9fef5da4e"); +#[deprecated(note = "use `ShellParameters::GUID`")] pub const SHELL_PARAMETERS_GUID: Guid = guid!("752f3136-4e16-4fdc-a22a-e5f46812f4ca"); +#[deprecated(note = "use `SimplePointer::GUID`")] pub const SIMPLE_POINTER_GUID: Guid = guid!("31878c87-0b75-11d5-9a4f-0090273fc14d"); +#[deprecated(note = "use `HiiDatabase::GUID`")] pub const HII_DATABASE_GUID: Guid = guid!("ef9fc172-a1b2-4693-b327-6d32fc416042"); +#[deprecated(note = "use `ComponentName::GUID`")] pub const COMPONENT_NAME2_GUID: Guid = guid!("6a7a5cff-e8d9-4f70-bada-75ab3025ce14"); #[derive(Copy, Clone, Debug, Eq, PartialEq)] diff --git a/crates/uefi/src/hii/database.rs b/crates/uefi/src/hii/database.rs index 15c9f6d..592169a 100644 --- a/crates/uefi/src/hii/database.rs +++ b/crates/uefi/src/hii/database.rs @@ -1,6 +1,4 @@ -use crate::guid::Guid; -use crate::status::Status; -use crate::Handle; +use crate::prelude::*; use super::package::{HiiPackageHeader, HiiPackageKind, HiiPackageListHeader}; @@ -113,3 +111,7 @@ pub struct HiiDatabase { DriverHandle: &mut Handle, ) -> Status, } + +impl HiiDatabase { + pub const GUID: Guid = guid!("ef9fc172-a1b2-4693-b327-6d32fc416042"); +} diff --git a/crates/uefi/src/loaded_image.rs b/crates/uefi/src/loaded_image.rs index 0681302..75f1995 100644 --- a/crates/uefi/src/loaded_image.rs +++ b/crates/uefi/src/loaded_image.rs @@ -17,3 +17,7 @@ pub struct LoadedImage { pub ImageDataType: MemoryType, pub Unload: extern "efiapi" fn(ImageHandle: Handle) -> Status, } + +impl LoadedImage { + pub const GUID: Guid = guid!("5b1b31a1-9562-11d2-8e3f-00a0c969723b"); +} diff --git a/crates/uefi/src/pointer.rs b/crates/uefi/src/pointer.rs index 6d22e93..2e326c2 100644 --- a/crates/uefi/src/pointer.rs +++ b/crates/uefi/src/pointer.rs @@ -27,3 +27,7 @@ pub struct SimplePointer { pub WaitForInput: Event, pub Mode: &'static mut SimplePointerMode, } + +impl SimplePointer { + pub const GUID: Guid = guid!("31878c87-0b75-11d5-9a4f-0090273fc14d"); +} diff --git a/crates/uefi/src/shell.rs b/crates/uefi/src/shell.rs index 2bc624e..2ff96f0 100644 --- a/crates/uefi/src/shell.rs +++ b/crates/uefi/src/shell.rs @@ -11,6 +11,10 @@ pub struct Shell { //TODO } +impl Shell { + pub const GUID: Guid = guid!("6302d008-7f9b-4f30-87ac-60c9fef5da4e"); +} + #[repr(C)] pub struct ShellParameters { pub Argv: *const *const u16, @@ -19,3 +23,7 @@ pub struct ShellParameters { pub StdOut: Handle, pub StdErr: Handle, } + +impl ShellParameters { + pub const GUID: Guid = guid!("752f3136-4e16-4fdc-a22a-e5f46812f4ca"); +} diff --git a/crates/uefi/src/text.rs b/crates/uefi/src/text.rs index dd0f313..de2d1e2 100644 --- a/crates/uefi/src/text.rs +++ b/crates/uefi/src/text.rs @@ -38,3 +38,7 @@ pub struct TextOutput { pub EnableCursor: extern "efiapi" fn(&TextOutput, bool) -> Status, pub Mode: &'static TextOutputMode, } + +impl TextOutput { + pub const GUID: Guid = guid!("387477c2-69c7-11d2-8e39-00a0c969723b"); +} diff --git a/crates/uefi_std/src/fs.rs b/crates/uefi_std/src/fs.rs index 4a3243a..28383e7 100644 --- a/crates/uefi_std/src/fs.rs +++ b/crates/uefi_std/src/fs.rs @@ -2,7 +2,6 @@ use core::default::Default; use core::{mem, ptr, slice}; use uefi::fs::{File as InnerFile, FileInfo, SimpleFileSystem, FILE_MODE_READ}; -use uefi::guid::{FILE_INFO_ID, FILE_SYSTEM_GUID}; use crate::ffi::wstr; use crate::prelude::*; @@ -12,7 +11,7 @@ pub struct FileSystem(pub &'static mut SimpleFileSystem); impl Protocol<SimpleFileSystem> for FileSystem { fn guid() -> Guid { - FILE_SYSTEM_GUID + SimpleFileSystem::GUID } fn new(inner: &'static mut SimpleFileSystem) -> Self { @@ -41,7 +40,7 @@ impl File { slice::from_raw_parts_mut(&mut info as *mut _ as *mut u8, mem::size_of_val(&info)) }; let mut len = buf.len(); - let status = (self.0.GetInfo)(self.0, &FILE_INFO_ID, &mut len, buf.as_mut_ptr()); + let status = (self.0.GetInfo)(self.0, &FileInfo::ID, &mut len, buf.as_mut_ptr()); match status { Status::SUCCESS => Ok(info), diff --git a/crates/uefi_std/src/loaded_image.rs b/crates/uefi_std/src/loaded_image.rs index 39378f8..6ba34e4 100644 --- a/crates/uefi_std/src/loaded_image.rs +++ b/crates/uefi_std/src/loaded_image.rs @@ -1,4 +1,3 @@ -use uefi::guid::LOADED_IMAGE_PROTOCOL_GUID; use uefi::loaded_image::LoadedImage as UefiLoadedImage; use crate::proto::Protocol; @@ -8,7 +7,7 @@ pub struct LoadedImage(pub &'static mut UefiLoadedImage); impl Protocol<UefiLoadedImage> for LoadedImage { fn guid() -> Guid { - LOADED_IMAGE_PROTOCOL_GUID + UefiLoadedImage::GUID } fn new(inner: &'static mut UefiLoadedImage) -> Self { diff --git a/crates/uefi_std/src/pointer.rs b/crates/uefi_std/src/pointer.rs index 513769f..d6635c5 100644 --- a/crates/uefi_std/src/pointer.rs +++ b/crates/uefi_std/src/pointer.rs @@ -1,4 +1,3 @@ -use uefi::guid::SIMPLE_POINTER_GUID; use uefi::pointer::SimplePointer; use crate::proto::Protocol; @@ -8,7 +7,7 @@ pub struct Pointer(pub &'static mut SimplePointer); impl Protocol<SimplePointer> for Pointer { fn guid() -> Guid { - SIMPLE_POINTER_GUID + SimplePointer::GUID } fn new(inner: &'static mut SimplePointer) -> Self { diff --git a/crates/uefi_std/src/shell.rs b/crates/uefi_std/src/shell.rs index f6dff41..f8102ed 100644 --- a/crates/uefi_std/src/shell.rs +++ b/crates/uefi_std/src/shell.rs @@ -1,4 +1,3 @@ -use uefi::guid::SHELL_GUID; use uefi::shell::Shell as UefiShell; use crate::proto::Protocol; @@ -8,7 +7,7 @@ pub struct Shell(pub &'static mut UefiShell); impl Protocol<UefiShell> for Shell { fn guid() -> Guid { - SHELL_GUID + UefiShell::GUID } fn new(inner: &'static mut UefiShell) -> Self { -- GitLab