1#![allow(non_upper_case_globals)]
4
5extern crate alloc;
6use alloc::format;
7use alloc::string::{String, ToString};
8
9use uguid::{guid, Guid};
10use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
11
12pub const EfiCustomModeEnable: Guid = guid!("c076ec0c-7028-4399-a072-71ee5c448b9f");
14pub const EfiGlobalVariable: Guid = guid!("8be4df61-93ca-11d2-aa0d-00e098032b8c");
15pub const EfiImageSecurityDatabase: Guid = guid!("d719b2cb-3d3a-4596-a3bc-dad00e67656f");
16pub const EfiSecureBootEnable: Guid = guid!("f0a30bc7-af08-4556-99c4-001009c93a44");
17pub const LoaderInfo: Guid = guid!("4a67b082-0a4c-41cf-b6c7-440b29bb8c4f");
18pub const ShimVariable: Guid = guid!("605dab50-e046-4300-abb6-3dd810dd8b23");
19pub const VMMBootOrder: Guid = guid!("668f4529-63d0-4bb5-b65d-6fbb9d36a44a");
20
21pub const EfiCertPkcs7: Guid = guid!("4aafd29d-68df-49ee-8aa9-347d375665a7");
23pub const EfiCertSha256: Guid = guid!("c1c41626-504c-4092-aca9-41f936934328");
24pub const EfiCertSha384: Guid = guid!("ff3e5307-9fd0-48c9-85f1-8ad56c701e01");
25pub const EfiCertSha512: Guid = guid!("093e0fae-a6c4-4f50-9f1b-d41e2b89c19a");
26pub const EfiCertRsa2048: Guid = guid!("3c5766e8-269c-4e34-aa14-ed776e85b3b6");
27pub const EfiCertX509: Guid = guid!("a5c059a1-94e4-4aa7-87b5-ab155c2bf072");
28pub const EfiCertExternalMgmt: Guid = guid!("452e8ced-dfff-4b8c-ae01-5118862e682c");
29
30pub const MicrosoftVendor: Guid = guid!("77fa9abd-0359-4d32-bd60-28f4e78f784b");
32pub const OvmfEnrollDefaultKeys: Guid = guid!("a0baa8a3-041d-48a8-bc87-c36d121b5e3d");
33
34pub const EfiEndOfDxeEventGroup: Guid = guid!("02ce967a-dd7e-4ffc-9ee7-810cf0470880");
36pub const EfiEventExitBootServices: Guid = guid!("27abf055-b1b8-4c26-8048-748f37baa2df");
37pub const EfiEventReadyToBoot: Guid = guid!("7ce88fb3-4bd7-4679-87a8-a8d8dee50d2b");
38
39pub const EfiSmmVariableProtocol: Guid = guid!("ed32d533-99e6-4209-9cc0-2d72cdd998a7");
41pub const VarCheckPolicyLibMmiHandler: Guid = guid!("da1b0d11-d1a7-46c4-9dc9-f3714875c6eb");
42
43pub const Acpi2Cfg: Guid = guid!("8868e871-e4f1-11d3-bc22-0080c73c8881");
45pub const AcpiCfg: Guid = guid!("eb9d2d30-2d88-11d3-9a16-0090273fc14d");
46pub const DebugImageInfoCfg: Guid = guid!("49152e77-1ada-4764-b7a2-7afefed95e8b");
47pub const DxeServicesCfg: Guid = guid!("05ad34ba-6f02-4214-952e-4da0398e2bb9");
48pub const HandOffBlockListCfg: Guid = guid!("7739f24c-93d7-11d4-9a3a-0090273fc14d");
49pub const MemoryTypeInfoCfg: Guid = guid!("4c19049f-4137-4dd3-9c10-8b97a83ffdfa");
50pub const SmbiosCfg: Guid = guid!("eb9d2d31-2d88-11d3-9a16-0090273fc14d");
51
52pub const FdtHob: Guid = guid!("16958446-19B7-480B-B047-7485AD3F716D");
54pub const OvmfPkgPlatformInfo: Guid = guid!("dec9b486-1f16-47c7-8f68-df1a41888ba5");
55pub const PcdDatabase: Guid = guid!("9b3ada4f-ae56-4c24-8dea-f03b7558ae50");
56pub const SecPlatformInformation2: Guid = guid!("9e9f374b-8f16-4230-9824-5846ee766a97");
57
58pub fn try_pretty_name(guid: &Guid) -> Option<&'static str> {
59 match *guid {
60 EfiCustomModeEnable => Some("EfiCustomModeEnable"),
61 EfiGlobalVariable => Some("EfiGlobalVariable"),
62 EfiImageSecurityDatabase => Some("EfiImageSecurityDatabase"),
63 EfiSecureBootEnable => Some("EfiSecureBootEnable"),
64 LoaderInfo => Some("LoaderInfo"),
65 ShimVariable => Some("ShimVariable"),
66 VMMBootOrder => Some("VMMBootOrder"),
67
68 EfiCertPkcs7 => Some("EfiCertPkcs7"),
69 EfiCertSha256 => Some("EfiCertSha256"),
70 EfiCertSha384 => Some("EfiCertSha384"),
71 EfiCertSha512 => Some("EfiCertSha512"),
72 EfiCertRsa2048 => Some("EfiCertRsa2048"),
73 EfiCertX509 => Some("EfiCertX509"),
74 EfiCertExternalMgmt => Some("EfiCertExternalMgmt"),
75
76 MicrosoftVendor => Some("MicrosoftVendor"),
77 OvmfEnrollDefaultKeys => Some("OvmfEnrollDefaultKeys"),
78
79 EfiEndOfDxeEventGroup => Some("EfiEndOfDxeEventGroup"),
80 EfiEventExitBootServices => Some("EfiEventExitBootServices"),
81 EfiEventReadyToBoot => Some("EfiEventReadyToBoot"),
82
83 EfiSmmVariableProtocol => Some("EfiSmmVariableProtocol"),
84 VarCheckPolicyLibMmiHandler => Some("VarCheckPolicyLibMmiHandler"),
85
86 Acpi2Cfg => Some("Acpi2Cfg"),
87 AcpiCfg => Some("AcpiCfg"),
88 DebugImageInfoCfg => Some("DebugImageInfoCfg"),
89 DxeServicesCfg => Some("DxeServicesCfg"),
90 HandOffBlockListCfg => Some("HandOffBlockListCfg"),
91 MemoryTypeInfoCfg => Some("MemoryTypeInfoCfg"),
92 SmbiosCfg => Some("SmbiosCfg"),
93
94 FdtHob => Some("FdtHob"),
95 OvmfPkgPlatformInfo => Some("OvmfPkgPlatformInfo"),
96 PcdDatabase => Some("PcdDatabase"),
97 SecPlatformInformation2 => Some("SecPlatformInformation2"),
98
99 _ => None,
100 }
101}
102
103pub fn pretty_name(guid: &Guid) -> String {
104 match try_pretty_name(guid) {
105 Some(name) => name.to_string(),
106 None => format!("{guid}"),
107 }
108}
109
110#[repr(C, packed)]
112#[derive(Debug, Clone, Copy, FromBytes, IntoBytes, KnownLayout, Immutable)]
113pub struct RawGuid {
114 bytes: [u8; 16],
115}
116
117impl From<RawGuid> for Guid {
118 fn from(raw: RawGuid) -> Self {
119 Self::from_bytes(raw.bytes)
120 }
121}
122
123impl From<Guid> for RawGuid {
124 fn from(guid: Guid) -> Self {
125 Self {
126 bytes: guid.to_bytes(),
127 }
128 }
129}