Skip to content

Commit

Permalink
Make protocol GUIDs associated constants
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Crawford <[email protected]>
  • Loading branch information
crawfxrd committed Dec 18, 2024
1 parent ba2813f commit 8c39c0c
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 12 deletions.
4 changes: 4 additions & 0 deletions crates/uefi/src/block_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
4 changes: 4 additions & 0 deletions crates/uefi/src/component_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ pub struct ComponentName {
) -> Status,
pub SupportedLanguages: *const u8,
}

impl ComponentName {
pub const GUID: Guid = guid!("6a7a5cff-e8d9-4f70-bada-75ab3025ce14");
}
4 changes: 4 additions & 0 deletions crates/uefi/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions crates/uefi/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions crates/uefi/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
12 changes: 12 additions & 0 deletions crates/uefi/src/guid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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)]
Expand Down
8 changes: 5 additions & 3 deletions crates/uefi/src/hii/database.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::guid::Guid;
use crate::status::Status;
use crate::Handle;
use crate::prelude::*;

use super::package::{HiiPackageHeader, HiiPackageKind, HiiPackageListHeader};

Expand Down Expand Up @@ -113,3 +111,7 @@ pub struct HiiDatabase {
DriverHandle: &mut Handle,
) -> Status,
}

impl HiiDatabase {
pub const GUID: Guid = guid!("ef9fc172-a1b2-4693-b327-6d32fc416042");
}
4 changes: 4 additions & 0 deletions crates/uefi/src/loaded_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
4 changes: 4 additions & 0 deletions crates/uefi/src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
8 changes: 8 additions & 0 deletions crates/uefi/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");
}
4 changes: 4 additions & 0 deletions crates/uefi/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
5 changes: 2 additions & 3 deletions crates/uefi_std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand All @@ -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 {
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 1 addition & 2 deletions crates/uefi_std/src/loaded_image.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use uefi::guid::LOADED_IMAGE_PROTOCOL_GUID;
use uefi::loaded_image::LoadedImage as UefiLoadedImage;

use crate::proto::Protocol;
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions crates/uefi_std/src/pointer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use uefi::guid::SIMPLE_POINTER_GUID;
use uefi::pointer::SimplePointer;

use crate::proto::Protocol;
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions crates/uefi_std/src/shell.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use uefi::guid::SHELL_GUID;
use uefi::shell::Shell as UefiShell;

use crate::proto::Protocol;
Expand All @@ -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 {
Expand Down

0 comments on commit 8c39c0c

Please sign in to comment.