1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 #include <efi.h> 5 6 #include "macro-fundamental.h" 7 8 /* gnu-efi 3.0.13 */ 9 #ifndef EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID 10 11 #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ 12 { 0xdd9e7534, 0x7762, 0x4698, {0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa} } 13 #define SimpleTextInputExProtocol ((EFI_GUID)EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID) 14 15 #define EFI_SHIFT_STATE_VALID 0x80000000 16 #define EFI_RIGHT_SHIFT_PRESSED 0x00000001 17 #define EFI_LEFT_SHIFT_PRESSED 0x00000002 18 #define EFI_RIGHT_CONTROL_PRESSED 0x00000004 19 #define EFI_LEFT_CONTROL_PRESSED 0x00000008 20 #define EFI_RIGHT_ALT_PRESSED 0x00000010 21 #define EFI_LEFT_ALT_PRESSED 0x00000020 22 #define EFI_RIGHT_LOGO_PRESSED 0x00000040 23 #define EFI_LEFT_LOGO_PRESSED 0x00000080 24 25 struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL; 26 27 typedef EFI_STATUS (EFIAPI *EFI_INPUT_RESET_EX)( 28 struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 29 BOOLEAN ExtendedVerification 30 ); 31 32 typedef UINT8 EFI_KEY_TOGGLE_STATE; 33 34 typedef struct { 35 UINT32 KeyShiftState; 36 EFI_KEY_TOGGLE_STATE KeyToggleState; 37 } EFI_KEY_STATE; 38 39 typedef struct { 40 EFI_INPUT_KEY Key; 41 EFI_KEY_STATE KeyState; 42 } EFI_KEY_DATA; 43 44 typedef EFI_STATUS (EFIAPI *EFI_INPUT_READ_KEY_EX)( 45 struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 46 EFI_KEY_DATA *KeyData 47 ); 48 49 typedef EFI_STATUS (EFIAPI *EFI_SET_STATE)( 50 struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 51 EFI_KEY_TOGGLE_STATE *KeyToggleState 52 ); 53 54 typedef EFI_STATUS (EFIAPI *EFI_KEY_NOTIFY_FUNCTION)( 55 EFI_KEY_DATA *KeyData 56 ); 57 58 typedef EFI_STATUS (EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY)( 59 struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 60 EFI_KEY_DATA KeyData, 61 EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, 62 VOID **NotifyHandle 63 ); 64 65 typedef EFI_STATUS (EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY)( 66 struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 67 VOID *NotificationHandle 68 ); 69 70 typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL { 71 EFI_INPUT_RESET_EX Reset; 72 EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx; 73 EFI_EVENT WaitForKeyEx; 74 EFI_SET_STATE SetState; 75 EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify; 76 EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify; 77 } EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL; 78 79 #endif 80 81 /* gnu-efi 3.0.14 */ 82 #ifndef EFI_IMAGE_MACHINE_RISCV64 83 #define EFI_IMAGE_MACHINE_RISCV64 0x5064 84 #endif 85 86 /* gnu-efi 3.0.14 */ 87 #ifndef EFI_DTB_TABLE_GUID 88 #define EFI_DTB_TABLE_GUID \ 89 { 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} } 90 #define EfiDtbTableGuid ((EFI_GUID)EFI_DTB_TABLE_GUID) 91 #endif 92 93 #ifndef EFI_DT_FIXUP_PROTOCOL_GUID 94 #define EFI_DT_FIXUP_PROTOCOL_GUID \ 95 { 0xe617d64c, 0xfe08, 0x46da, {0xf4, 0xdc, 0xbb, 0xd5, 0x87, 0x0c, 0x73, 0x00} } 96 #define EfiDtFixupProtocol ((EFI_GUID)EFI_DT_FIXUP_PROTOCOL_GUID) 97 98 #define EFI_DT_FIXUP_PROTOCOL_REVISION 0x00010000 99 100 /* Add nodes and update properties */ 101 #define EFI_DT_APPLY_FIXUPS 0x00000001 102 /* 103 * Reserve memory according to the /reserved-memory node 104 * and the memory reservation block 105 */ 106 #define EFI_DT_RESERVE_MEMORY 0x00000002 107 108 typedef struct _EFI_DT_FIXUP_PROTOCOL EFI_DT_FIXUP_PROTOCOL; 109 110 typedef EFI_STATUS (EFIAPI *EFI_DT_FIXUP) ( 111 IN EFI_DT_FIXUP_PROTOCOL *This, 112 IN VOID *Fdt, 113 IN OUT UINTN *BufferSize, 114 IN UINT32 Flags); 115 116 struct _EFI_DT_FIXUP_PROTOCOL { 117 UINT64 Revision; 118 EFI_DT_FIXUP Fixup; 119 }; 120 121 #endif 122 123 /* TCG EFI Protocol Specification */ 124 #ifndef EFI_TCG_GUID 125 126 #define EFI_TCG_GUID \ 127 &(const EFI_GUID) { 0xf541796d, 0xa62e, 0x4954, { 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd } } 128 129 typedef struct _TCG_VERSION { 130 UINT8 Major; 131 UINT8 Minor; 132 UINT8 RevMajor; 133 UINT8 RevMinor; 134 } TCG_VERSION; 135 136 typedef struct tdEFI_TCG2_VERSION { 137 UINT8 Major; 138 UINT8 Minor; 139 } EFI_TCG2_VERSION; 140 141 typedef struct _TCG_BOOT_SERVICE_CAPABILITY { 142 UINT8 Size; 143 struct _TCG_VERSION StructureVersion; 144 struct _TCG_VERSION ProtocolSpecVersion; 145 UINT8 HashAlgorithmBitmap; 146 BOOLEAN TPMPresentFlag; 147 BOOLEAN TPMDeactivatedFlag; 148 } TCG_BOOT_SERVICE_CAPABILITY; 149 150 typedef struct tdTREE_BOOT_SERVICE_CAPABILITY { 151 UINT8 Size; 152 EFI_TCG2_VERSION StructureVersion; 153 EFI_TCG2_VERSION ProtocolVersion; 154 UINT32 HashAlgorithmBitmap; 155 UINT32 SupportedEventLogs; 156 BOOLEAN TrEEPresentFlag; 157 UINT16 MaxCommandSize; 158 UINT16 MaxResponseSize; 159 UINT32 ManufacturerID; 160 } TREE_BOOT_SERVICE_CAPABILITY; 161 162 typedef UINT32 TCG_ALGORITHM_ID; 163 #define TCG_ALG_SHA 0x00000004 // The SHA1 algorithm 164 165 #define SHA1_DIGEST_SIZE 20 166 167 typedef struct _TCG_DIGEST { 168 UINT8 Digest[SHA1_DIGEST_SIZE]; 169 } TCG_DIGEST; 170 171 #define EV_IPL 13 172 173 typedef struct _TCG_PCR_EVENT { 174 UINT32 PCRIndex; 175 UINT32 EventType; 176 struct _TCG_DIGEST digest; 177 UINT32 EventSize; 178 UINT8 Event[1]; 179 } TCG_PCR_EVENT; 180 181 INTERFACE_DECL(_EFI_TCG); 182 183 typedef EFI_STATUS(EFIAPI * EFI_TCG_STATUS_CHECK) (IN struct _EFI_TCG * This, 184 OUT struct _TCG_BOOT_SERVICE_CAPABILITY * ProtocolCapability, 185 OUT UINT32 * TCGFeatureFlags, 186 OUT EFI_PHYSICAL_ADDRESS * EventLogLocation, 187 OUT EFI_PHYSICAL_ADDRESS * EventLogLastEntry); 188 189 typedef EFI_STATUS(EFIAPI * EFI_TCG_HASH_ALL) (IN struct _EFI_TCG * This, 190 IN UINT8 * HashData, 191 IN UINT64 HashDataLen, 192 IN TCG_ALGORITHM_ID AlgorithmId, 193 IN OUT UINT64 * HashedDataLen, IN OUT UINT8 ** HashedDataResult); 194 195 typedef EFI_STATUS(EFIAPI * EFI_TCG_LOG_EVENT) (IN struct _EFI_TCG * This, 196 IN struct _TCG_PCR_EVENT * TCGLogData, 197 IN OUT UINT32 * EventNumber, IN UINT32 Flags); 198 199 typedef EFI_STATUS(EFIAPI * EFI_TCG_PASS_THROUGH_TO_TPM) (IN struct _EFI_TCG * This, 200 IN UINT32 TpmInputParameterBlockSize, 201 IN UINT8 * TpmInputParameterBlock, 202 IN UINT32 TpmOutputParameterBlockSize, 203 IN UINT8 * TpmOutputParameterBlock); 204 205 typedef EFI_STATUS(EFIAPI * EFI_TCG_HASH_LOG_EXTEND_EVENT) (IN struct _EFI_TCG * This, 206 IN EFI_PHYSICAL_ADDRESS HashData, 207 IN UINT64 HashDataLen, 208 IN TCG_ALGORITHM_ID AlgorithmId, 209 IN struct _TCG_PCR_EVENT * TCGLogData, 210 IN OUT UINT32 * EventNumber, 211 OUT EFI_PHYSICAL_ADDRESS * EventLogLastEntry); 212 213 typedef struct _EFI_TCG { 214 EFI_TCG_STATUS_CHECK StatusCheck; 215 EFI_TCG_HASH_ALL HashAll; 216 EFI_TCG_LOG_EVENT LogEvent; 217 EFI_TCG_PASS_THROUGH_TO_TPM PassThroughToTPM; 218 EFI_TCG_HASH_LOG_EXTEND_EVENT HashLogExtendEvent; 219 } EFI_TCG; 220 221 #endif 222 223 /* TCG EFI Protocol Specification */ 224 #ifndef EFI_TCG2_GUID 225 226 #define EFI_TCG2_GUID \ 227 &(const EFI_GUID) { 0x607f766c, 0x7455, 0x42be, { 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f } } 228 229 typedef struct tdEFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL; 230 231 typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP; 232 typedef UINT32 EFI_TCG2_EVENT_LOG_FORMAT; 233 typedef UINT32 EFI_TCG2_EVENT_ALGORITHM_BITMAP; 234 235 typedef struct tdEFI_TCG2_BOOT_SERVICE_CAPABILITY { 236 UINT8 Size; 237 EFI_TCG2_VERSION StructureVersion; 238 EFI_TCG2_VERSION ProtocolVersion; 239 EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap; 240 EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs; 241 BOOLEAN TPMPresentFlag; 242 UINT16 MaxCommandSize; 243 UINT16 MaxResponseSize; 244 UINT32 ManufacturerID; 245 UINT32 NumberOfPCRBanks; 246 EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks; 247 } EFI_TCG2_BOOT_SERVICE_CAPABILITY; 248 249 #define EFI_TCG2_EVENT_HEADER_VERSION 1 250 251 typedef struct { 252 UINT32 HeaderSize; 253 UINT16 HeaderVersion; 254 UINT32 PCRIndex; 255 UINT32 EventType; 256 } _packed_ EFI_TCG2_EVENT_HEADER; 257 258 typedef struct tdEFI_TCG2_EVENT { 259 UINT32 Size; 260 EFI_TCG2_EVENT_HEADER Header; 261 UINT8 Event[1]; 262 } _packed_ EFI_TCG2_EVENT; 263 264 typedef EFI_STATUS(EFIAPI * EFI_TCG2_GET_CAPABILITY) (IN EFI_TCG2_PROTOCOL * This, 265 IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY * ProtocolCapability); 266 267 typedef EFI_STATUS(EFIAPI * EFI_TCG2_GET_EVENT_LOG) (IN EFI_TCG2_PROTOCOL * This, 268 IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat, 269 OUT EFI_PHYSICAL_ADDRESS * EventLogLocation, 270 OUT EFI_PHYSICAL_ADDRESS * EventLogLastEntry, 271 OUT BOOLEAN * EventLogTruncated); 272 273 typedef EFI_STATUS(EFIAPI * EFI_TCG2_HASH_LOG_EXTEND_EVENT) (IN EFI_TCG2_PROTOCOL * This, 274 IN UINT64 Flags, 275 IN EFI_PHYSICAL_ADDRESS DataToHash, 276 IN UINT64 DataToHashLen, IN EFI_TCG2_EVENT * EfiTcgEvent); 277 278 typedef EFI_STATUS(EFIAPI * EFI_TCG2_SUBMIT_COMMAND) (IN EFI_TCG2_PROTOCOL * This, 279 IN UINT32 InputParameterBlockSize, 280 IN UINT8 * InputParameterBlock, 281 IN UINT32 OutputParameterBlockSize, IN UINT8 * OutputParameterBlock); 282 283 typedef EFI_STATUS(EFIAPI * EFI_TCG2_GET_ACTIVE_PCR_BANKS) (IN EFI_TCG2_PROTOCOL * This, OUT UINT32 * ActivePcrBanks); 284 285 typedef EFI_STATUS(EFIAPI * EFI_TCG2_SET_ACTIVE_PCR_BANKS) (IN EFI_TCG2_PROTOCOL * This, IN UINT32 ActivePcrBanks); 286 287 typedef EFI_STATUS(EFIAPI * EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS) (IN EFI_TCG2_PROTOCOL * This, 288 OUT UINT32 * OperationPresent, OUT UINT32 * Response); 289 290 typedef struct tdEFI_TCG2_PROTOCOL { 291 EFI_TCG2_GET_CAPABILITY GetCapability; 292 EFI_TCG2_GET_EVENT_LOG GetEventLog; 293 EFI_TCG2_HASH_LOG_EXTEND_EVENT HashLogExtendEvent; 294 EFI_TCG2_SUBMIT_COMMAND SubmitCommand; 295 EFI_TCG2_GET_ACTIVE_PCR_BANKS GetActivePcrBanks; 296 EFI_TCG2_SET_ACTIVE_PCR_BANKS SetActivePcrBanks; 297 EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS GetResultOfSetActivePcrBanks; 298 } EFI_TCG2; 299 300 #endif 301 302 #ifndef EFI_LOAD_FILE2_PROTOCOL_GUID 303 #define EFI_LOAD_FILE2_PROTOCOL_GUID \ 304 {0x4006c0c1, 0xfcb3, 0x403e, {0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d} } 305 #define EfiLoadFile2Protocol ((EFI_GUID)EFI_LOAD_FILE2_PROTOCOL_GUID) 306 #endif 307 308 #define LINUX_INITRD_MEDIA_GUID \ 309 {0x5568e427, 0x68fc, 0x4f3d, {0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68} } 310 311 /* UEFI Platform Initialization (Vol2: DXE) */ 312 #ifndef SECURITY_PROTOCOL_GUID 313 314 #define SECURITY_PROTOCOL_GUID \ 315 &(const EFI_GUID) { 0xa46423e3, 0x4617, 0x49f1, { 0xb9, 0xff, 0xd1, 0xbf, 0xa9, 0x11, 0x58, 0x39 } } 316 #define SECURITY_PROTOCOL2_GUID \ 317 &(const EFI_GUID) { 0x94ab2f58, 0x1438, 0x4ef1, { 0x91, 0x52, 0x18, 0x94, 0x1a, 0x3a, 0x0e, 0x68 } } 318 319 struct _EFI_SECURITY2_PROTOCOL; 320 struct _EFI_SECURITY_PROTOCOL; 321 struct _EFI_DEVICE_PATH_PROTOCOL; 322 323 typedef struct _EFI_SECURITY2_PROTOCOL EFI_SECURITY2_PROTOCOL; 324 typedef struct _EFI_SECURITY_PROTOCOL EFI_SECURITY_PROTOCOL; 325 typedef struct _EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH_PROTOCOL; 326 327 typedef EFI_STATUS (EFIAPI *EFI_SECURITY_FILE_AUTHENTICATION_STATE) ( 328 const EFI_SECURITY_PROTOCOL *This, 329 UINT32 AuthenticationStatus, 330 const EFI_DEVICE_PATH_PROTOCOL *File 331 ); 332 333 typedef EFI_STATUS (EFIAPI *EFI_SECURITY2_FILE_AUTHENTICATION) ( 334 const EFI_SECURITY2_PROTOCOL *This, 335 const EFI_DEVICE_PATH_PROTOCOL *DevicePath, 336 VOID *FileBuffer, 337 UINTN FileSize, 338 BOOLEAN BootPolicy 339 ); 340 341 struct _EFI_SECURITY2_PROTOCOL { 342 EFI_SECURITY2_FILE_AUTHENTICATION FileAuthentication; 343 }; 344 345 struct _EFI_SECURITY_PROTOCOL { 346 EFI_SECURITY_FILE_AUTHENTICATION_STATE FileAuthenticationState; 347 }; 348 349 #endif 350 351 #ifndef EFI_CONSOLE_CONTROL_GUID 352 353 #define EFI_CONSOLE_CONTROL_GUID \ 354 &(const EFI_GUID) { 0xf42f7782, 0x12e, 0x4c12, { 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 } } 355 356 struct _EFI_CONSOLE_CONTROL_PROTOCOL; 357 358 typedef enum { 359 EfiConsoleControlScreenText, 360 EfiConsoleControlScreenGraphics, 361 EfiConsoleControlScreenMaxValue, 362 } EFI_CONSOLE_CONTROL_SCREEN_MODE; 363 364 typedef EFI_STATUS (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE)( 365 struct _EFI_CONSOLE_CONTROL_PROTOCOL *This, 366 EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode, 367 BOOLEAN *UgaExists, 368 BOOLEAN *StdInLocked 369 ); 370 371 typedef EFI_STATUS (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE)( 372 struct _EFI_CONSOLE_CONTROL_PROTOCOL *This, 373 EFI_CONSOLE_CONTROL_SCREEN_MODE Mode 374 ); 375 376 typedef EFI_STATUS (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN)( 377 struct _EFI_CONSOLE_CONTROL_PROTOCOL *This, 378 CHAR16 *Password 379 ); 380 381 typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL { 382 EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode; 383 EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode; 384 EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN LockStdIn; 385 } EFI_CONSOLE_CONTROL_PROTOCOL; 386 387 #endif 388