summaryrefslogtreecommitdiffstats
path: root/src/boot/efi/proto
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot/efi/proto')
-rw-r--r--src/boot/efi/proto/block-io.h43
-rw-r--r--src/boot/efi/proto/console-control.h28
-rw-r--r--src/boot/efi/proto/device-path.h86
-rw-r--r--src/boot/efi/proto/dt-fixup.h30
-rw-r--r--src/boot/efi/proto/file-io.h83
-rw-r--r--src/boot/efi/proto/graphics-output.h78
-rw-r--r--src/boot/efi/proto/load-file.h21
-rw-r--r--src/boot/efi/proto/loaded-image.h29
-rw-r--r--src/boot/efi/proto/rng.h20
-rw-r--r--src/boot/efi/proto/security-arch.h32
-rw-r--r--src/boot/efi/proto/shell-parameters.h15
-rw-r--r--src/boot/efi/proto/simple-text-io.h182
-rw-r--r--src/boot/efi/proto/tcg.h117
13 files changed, 764 insertions, 0 deletions
diff --git a/src/boot/efi/proto/block-io.h b/src/boot/efi/proto/block-io.h
new file mode 100644
index 0000000..e977f70
--- /dev/null
+++ b/src/boot/efi/proto/block-io.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_BLOCK_IO_PROTOCOL_GUID \
+ GUID_DEF(0x0964e5b21, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+
+typedef struct EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;
+struct EFI_BLOCK_IO_PROTOCOL {
+ uint64_t Revision;
+ struct {
+ uint32_t MediaId;
+ bool RemovableMedia;
+ bool MediaPresent;
+ bool LogicalPartition;
+ bool ReadOnly;
+ bool WriteCaching;
+ uint32_t BlockSize;
+ uint32_t IoAlign;
+ EFI_LBA LastBlock;
+ EFI_LBA LowestAlignedLba;
+ uint32_t LogicalBlocksPerPhysicalBlock;
+ uint32_t OptimalTransferLengthGranularity;
+ } *Media;
+
+ EFI_STATUS (EFIAPI *Reset)(
+ EFI_BLOCK_IO_PROTOCOL *This,
+ bool ExtendedVerification);
+ EFI_STATUS (EFIAPI *ReadBlocks)(
+ EFI_BLOCK_IO_PROTOCOL *This,
+ uint32_t MediaId,
+ EFI_LBA LBA,
+ size_t BufferSize,
+ void *Buffer);
+ EFI_STATUS (EFIAPI *WriteBlocks)(
+ EFI_BLOCK_IO_PROTOCOL *This,
+ uint32_t MediaId,
+ EFI_LBA LBA,
+ size_t BufferSize,
+ void *Buffer);
+ EFI_STATUS (EFIAPI *FlushBlocks)(EFI_BLOCK_IO_PROTOCOL *This);
+};
diff --git a/src/boot/efi/proto/console-control.h b/src/boot/efi/proto/console-control.h
new file mode 100644
index 0000000..d3a92ea
--- /dev/null
+++ b/src/boot/efi/proto/console-control.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \
+ GUID_DEF(0xf42f7782, 0x12e, 0x4c12, 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21)
+
+typedef enum {
+ EfiConsoleControlScreenText,
+ EfiConsoleControlScreenGraphics,
+ EfiConsoleControlScreenMaxValue,
+} EFI_CONSOLE_CONTROL_SCREEN_MODE;
+
+typedef struct EFI_CONSOLE_CONTROL_PROTOCOL EFI_CONSOLE_CONTROL_PROTOCOL;
+struct EFI_CONSOLE_CONTROL_PROTOCOL {
+ EFI_STATUS (EFIAPI *GetMode)(
+ EFI_CONSOLE_CONTROL_PROTOCOL *This,
+ EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode,
+ bool *UgaExists,
+ bool *StdInLocked);
+ EFI_STATUS (EFIAPI *SetMode)(
+ EFI_CONSOLE_CONTROL_PROTOCOL *This,
+ EFI_CONSOLE_CONTROL_SCREEN_MODE Mode);
+ EFI_STATUS(EFIAPI *LockStdIn)(
+ EFI_CONSOLE_CONTROL_PROTOCOL *This,
+ char16_t *Password);
+};
diff --git a/src/boot/efi/proto/device-path.h b/src/boot/efi/proto/device-path.h
new file mode 100644
index 0000000..0fabae1
--- /dev/null
+++ b/src/boot/efi/proto/device-path.h
@@ -0,0 +1,86 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_DEVICE_PATH_PROTOCOL_GUID \
+ GUID_DEF(0x09576e91, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
+ GUID_DEF(0x8b843e20, 0x8132, 0x4852, 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
+#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \
+ GUID_DEF(0x05c99a21, 0xc70f, 0x4ad2, 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e)
+
+/* Device path types. */
+enum {
+ HARDWARE_DEVICE_PATH = 0x01,
+ ACPI_DEVICE_PATH = 0x02,
+ MESSAGING_DEVICE_PATH = 0x03,
+ MEDIA_DEVICE_PATH = 0x04,
+ BBS_DEVICE_PATH = 0x05,
+ END_DEVICE_PATH_TYPE = 0x7f,
+};
+
+/* Device path sub-types. */
+enum {
+ END_INSTANCE_DEVICE_PATH_SUBTYPE = 0x01,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE = 0xff,
+
+ MEDIA_HARDDRIVE_DP = 0x01,
+ MEDIA_VENDOR_DP = 0x03,
+ MEDIA_FILEPATH_DP = 0x04,
+ MEDIA_PIWG_FW_FILE_DP = 0x06,
+ MEDIA_PIWG_FW_VOL_DP = 0x07,
+};
+
+struct _packed_ EFI_DEVICE_PATH_PROTOCOL {
+ uint8_t Type;
+ uint8_t SubType;
+ uint16_t Length;
+};
+
+typedef struct {
+ EFI_DEVICE_PATH Header;
+ EFI_GUID Guid;
+} _packed_ VENDOR_DEVICE_PATH;
+
+#define MBR_TYPE_PCAT 0x01U
+#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02U
+#define NO_DISK_SIGNATURE 0x00U
+#define SIGNATURE_TYPE_MBR 0x01U
+#define SIGNATURE_TYPE_GUID 0x02U
+
+typedef struct {
+ EFI_DEVICE_PATH Header;
+ uint32_t PartitionNumber;
+ uint64_t PartitionStart;
+ uint64_t PartitionSize;
+ union {
+ uint8_t Signature[16];
+ EFI_GUID SignatureGuid;
+ };
+ uint8_t MBRType;
+ uint8_t SignatureType;
+} _packed_ HARDDRIVE_DEVICE_PATH;
+
+typedef struct {
+ EFI_DEVICE_PATH Header;
+ char16_t PathName[];
+} _packed_ FILEPATH_DEVICE_PATH;
+
+typedef struct {
+ char16_t* (EFIAPI *ConvertDeviceNodeToText)(
+ const EFI_DEVICE_PATH *DeviceNode,
+ bool DisplayOnly,
+ bool AllowShortcuts);
+ char16_t* (EFIAPI *ConvertDevicePathToText)(
+ const EFI_DEVICE_PATH *DevicePath,
+ bool DisplayOnly,
+ bool AllowShortcuts);
+} EFI_DEVICE_PATH_TO_TEXT_PROTOCOL;
+
+typedef struct {
+ EFI_DEVICE_PATH* (EFIAPI *ConvertTextToDevicNode)(
+ const char16_t *TextDeviceNode);
+ EFI_DEVICE_PATH* (EFIAPI *ConvertTextToDevicPath)(
+ const char16_t *ConvertTextToDevicPath);
+} EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL;
diff --git a/src/boot/efi/proto/dt-fixup.h b/src/boot/efi/proto/dt-fixup.h
new file mode 100644
index 0000000..6edbef5
--- /dev/null
+++ b/src/boot/efi/proto/dt-fixup.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_DTB_TABLE_GUID \
+ GUID_DEF(0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
+#define EFI_DT_FIXUP_PROTOCOL_GUID \
+ GUID_DEF(0xe617d64c, 0xfe08, 0x46da, 0xf4, 0xdc, 0xbb, 0xd5, 0x87, 0x0c, 0x73, 0x00)
+
+#define EFI_DT_FIXUP_PROTOCOL_REVISION 0x00010000
+
+/* Add nodes and update properties */
+#define EFI_DT_APPLY_FIXUPS 0x00000001
+
+/*
+ * Reserve memory according to the /reserved-memory node
+ * and the memory reservation block
+ */
+#define EFI_DT_RESERVE_MEMORY 0x00000002
+
+typedef struct EFI_DT_FIXUP_PROTOCOL EFI_DT_FIXUP_PROTOCOL;
+struct EFI_DT_FIXUP_PROTOCOL {
+ uint64_t Revision;
+ EFI_STATUS (EFIAPI *Fixup)(
+ EFI_DT_FIXUP_PROTOCOL *This,
+ void *Fdt,
+ size_t *BufferSize,
+ uint32_t Flags);
+};
diff --git a/src/boot/efi/proto/file-io.h b/src/boot/efi/proto/file-io.h
new file mode 100644
index 0000000..001ad48
--- /dev/null
+++ b/src/boot/efi/proto/file-io.h
@@ -0,0 +1,83 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
+ GUID_DEF(0x0964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+#define EFI_FILE_INFO_ID \
+ GUID_DEF(0x009576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+
+#define EFI_FILE_MODE_READ 0x0000000000000001U
+#define EFI_FILE_MODE_WRITE 0x0000000000000002U
+#define EFI_FILE_MODE_CREATE 0x8000000000000000U
+
+#define EFI_FILE_READ_ONLY 0x01U
+#define EFI_FILE_HIDDEN 0x02U
+#define EFI_FILE_SYSTEM 0x04U
+#define EFI_FILE_RESERVED 0x08U
+#define EFI_FILE_DIRECTORY 0x10U
+#define EFI_FILE_ARCHIVE 0x20U
+#define EFI_FILE_VALID_ATTR 0x37U
+
+typedef struct {
+ uint64_t Size;
+ uint64_t FileSize;
+ uint64_t PhysicalSize;
+ EFI_TIME CreateTime;
+ EFI_TIME LastAccessTime;
+ EFI_TIME ModificationTime;
+ uint64_t Attribute;
+ char16_t FileName[];
+} EFI_FILE_INFO;
+
+/* Some broken firmware violates the EFI spec by still advancing the readdir
+ * position when returning EFI_BUFFER_TOO_SMALL, effectively skipping over any files when
+ * the buffer was too small. Therefore, we always start with a buffer that should handle FAT32
+ * max file name length. */
+#define EFI_FILE_INFO_MIN_SIZE (offsetof(EFI_FILE_INFO, FileName) + 256U * sizeof(char16_t))
+
+typedef struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
+struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {
+ uint64_t Revision;
+ EFI_STATUS (EFIAPI *OpenVolume)(
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
+ EFI_FILE **Root);
+};
+
+struct EFI_FILE_PROTOCOL {
+ uint64_t Revision;
+ EFI_STATUS (EFIAPI *Open)(
+ EFI_FILE *This,
+ EFI_FILE **NewHandle,
+ char16_t *FileName,
+ uint64_t OpenMode,
+ uint64_t Attributes);
+ EFI_STATUS (EFIAPI *Close)(EFI_FILE *This);
+ EFI_STATUS (EFIAPI *Delete)(EFI_FILE *This);
+ EFI_STATUS (EFIAPI *Read)(
+ EFI_FILE *This,
+ size_t *BufferSize,
+ void *Buffer);
+ EFI_STATUS (EFIAPI *Write)(
+ EFI_FILE *This,
+ size_t *BufferSize,
+ void *Buffer);
+ EFI_STATUS (EFIAPI *GetPosition)(EFI_FILE *This, uint64_t *Position);
+ EFI_STATUS (EFIAPI *SetPosition)(EFI_FILE *This, uint64_t Position);
+ EFI_STATUS (EFIAPI *GetInfo)(
+ EFI_FILE *This,
+ EFI_GUID *InformationType,
+ size_t *BufferSize,
+ void *Buffer);
+ EFI_STATUS (EFIAPI *SetInfo)(
+ EFI_FILE *This,
+ EFI_GUID *InformationType,
+ size_t BufferSize,
+ void *Buffer);
+ EFI_STATUS (EFIAPI *Flush)(EFI_FILE *This);
+ void *OpenEx;
+ void *ReadEx;
+ void *WriteEx;
+ void *FlushEx;
+};
diff --git a/src/boot/efi/proto/graphics-output.h b/src/boot/efi/proto/graphics-output.h
new file mode 100644
index 0000000..f49e580
--- /dev/null
+++ b/src/boot/efi/proto/graphics-output.h
@@ -0,0 +1,78 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
+ GUID_DEF(0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
+
+typedef enum {
+ PixelRedGreenBlueReserved8BitPerColor,
+ PixelBlueGreenRedReserved8BitPerColor,
+ PixelBitMask,
+ PixelBltOnly,
+ PixelFormatMax,
+} EFI_GRAPHICS_PIXEL_FORMAT;
+
+typedef enum {
+ EfiBltVideoFill,
+ EfiBltVideoToBltBuffer,
+ EfiBltBufferToVideo,
+ EfiBltVideoToVideo,
+ EfiGraphicsOutputBltOperationMax,
+} EFI_GRAPHICS_OUTPUT_BLT_OPERATION;
+
+typedef struct {
+ uint32_t RedMask;
+ uint32_t GreenMask;
+ uint32_t BlueMask;
+ uint32_t ReservedMask;
+} EFI_PIXEL_BITMASK;
+
+typedef struct {
+ uint8_t Blue;
+ uint8_t Green;
+ uint8_t Red;
+ uint8_t Reserved;
+} EFI_GRAPHICS_OUTPUT_BLT_PIXEL;
+
+typedef struct {
+ uint32_t Version;
+ uint32_t HorizontalResolution;
+ uint32_t VerticalResolution;
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+ EFI_PIXEL_BITMASK PixelInformation;
+ uint32_t PixelsPerScanLine;
+} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;
+
+typedef struct EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL;
+struct EFI_GRAPHICS_OUTPUT_PROTOCOL {
+ EFI_STATUS (EFIAPI *QueryMode)(
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ uint32_t ModeNumber,
+ size_t *SizeOfInfo,
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info);
+ EFI_STATUS(EFIAPI *SetMode)(
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ uint32_t ModeNumber);
+ EFI_STATUS (EFIAPI *Blt)(
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
+ EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
+ size_t SourceX,
+ size_t SourceY,
+ size_t DestinationX,
+ size_t DestinationY,
+ size_t Width,
+ size_t Height,
+ size_t Delta);
+
+ struct {
+ uint32_t MaxMode;
+ uint32_t Mode;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
+ size_t SizeOfInfo;
+ EFI_PHYSICAL_ADDRESS FrameBufferBase;
+ size_t FrameBufferSize;
+ } *Mode;
+};
diff --git a/src/boot/efi/proto/load-file.h b/src/boot/efi/proto/load-file.h
new file mode 100644
index 0000000..2e01ce5
--- /dev/null
+++ b/src/boot/efi/proto/load-file.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_LOAD_FILE_PROTOCOL_GUID \
+ GUID_DEF(0x56EC3091, 0x954C, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+#define EFI_LOAD_FILE2_PROTOCOL_GUID \
+ GUID_DEF(0x4006c0c1, 0xfcb3, 0x403e, 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d)
+
+typedef struct EFI_LOAD_FILE_PROTOCOL EFI_LOAD_FILE_PROTOCOL;
+typedef EFI_LOAD_FILE_PROTOCOL EFI_LOAD_FILE2_PROTOCOL;
+
+struct EFI_LOAD_FILE_PROTOCOL {
+ EFI_STATUS (EFIAPI *LoadFile)(
+ EFI_LOAD_FILE_PROTOCOL *This,
+ EFI_DEVICE_PATH *FilePath,
+ bool BootPolicy,
+ size_t *BufferSize,
+ void *Buffer);
+};
diff --git a/src/boot/efi/proto/loaded-image.h b/src/boot/efi/proto/loaded-image.h
new file mode 100644
index 0000000..46371e7
--- /dev/null
+++ b/src/boot/efi/proto/loaded-image.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_LOADED_IMAGE_PROTOCOL_GUID \
+ GUID_DEF(0x5B1B31A1, 0x9562, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B)
+#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \
+ GUID_DEF(0xbc62157e, 0x3e33, 0x4fec, 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf)
+
+typedef EFI_STATUS (EFIAPI *EFI_IMAGE_ENTRY_POINT)(
+ EFI_HANDLE ImageHandle,
+ EFI_SYSTEM_TABLE *SystemTable);
+
+typedef struct {
+ uint32_t Revision;
+ EFI_HANDLE ParentHandle;
+ EFI_SYSTEM_TABLE *SystemTable;
+ EFI_HANDLE DeviceHandle;
+ EFI_DEVICE_PATH *FilePath;
+ void *Reserved;
+ uint32_t LoadOptionsSize;
+ void *LoadOptions;
+ void *ImageBase;
+ uint64_t ImageSize;
+ EFI_MEMORY_TYPE ImageCodeType;
+ EFI_MEMORY_TYPE ImageDataType;
+ EFI_STATUS (EFIAPI *Unload)(EFI_HANDLE ImageHandle);
+} EFI_LOADED_IMAGE_PROTOCOL;
diff --git a/src/boot/efi/proto/rng.h b/src/boot/efi/proto/rng.h
new file mode 100644
index 0000000..8ed1fd4
--- /dev/null
+++ b/src/boot/efi/proto/rng.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_RNG_PROTOCOL_GUID \
+ GUID_DEF(0x3152bca5, 0xeade, 0x433d, 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44)
+
+typedef struct EFI_RNG_PROTOCOL EFI_RNG_PROTOCOL;
+struct EFI_RNG_PROTOCOL {
+ EFI_STATUS (EFIAPI *GetInfo)(
+ EFI_RNG_PROTOCOL *This,
+ size_t *RNGAlgorithmListSize,
+ EFI_GUID *RNGAlgorithmList);
+ EFI_STATUS (EFIAPI *GetRNG)(
+ EFI_RNG_PROTOCOL *This,
+ EFI_GUID *RNGAlgorithm,
+ size_t RNGValueLength,
+ uint8_t *RNGValue);
+};
diff --git a/src/boot/efi/proto/security-arch.h b/src/boot/efi/proto/security-arch.h
new file mode 100644
index 0000000..2675c61
--- /dev/null
+++ b/src/boot/efi/proto/security-arch.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_SECURITY_ARCH_PROTOCOL_GUID \
+ GUID_DEF(0xA46423E3, 0x4617, 0x49f1, 0xB9, 0xFF, 0xD1, 0xBF, 0xA9, 0x11, 0x58, 0x39)
+#define EFI_SECURITY2_ARCH_PROTOCOL_GUID \
+ GUID_DEF(0x94ab2f58, 0x1438, 0x4ef1, 0x91, 0x52, 0x18, 0x94, 0x1a, 0x3a, 0x0e, 0x68)
+
+typedef struct EFI_SECURITY_ARCH_PROTOCOL EFI_SECURITY_ARCH_PROTOCOL;
+typedef struct EFI_SECURITY2_ARCH_PROTOCOL EFI_SECURITY2_ARCH_PROTOCOL;
+
+typedef EFI_STATUS (EFIAPI *EFI_SECURITY_FILE_AUTHENTICATION_STATE)(
+ const EFI_SECURITY_ARCH_PROTOCOL *This,
+ uint32_t AuthenticationStatus,
+ const EFI_DEVICE_PATH *File);
+
+typedef EFI_STATUS (EFIAPI *EFI_SECURITY2_FILE_AUTHENTICATION)(
+ const EFI_SECURITY2_ARCH_PROTOCOL *This,
+ const EFI_DEVICE_PATH *DevicePath,
+ void *FileBuffer,
+ size_t FileSize,
+ bool BootPolicy);
+
+struct EFI_SECURITY_ARCH_PROTOCOL {
+ EFI_SECURITY_FILE_AUTHENTICATION_STATE FileAuthenticationState;
+};
+
+struct EFI_SECURITY2_ARCH_PROTOCOL {
+ EFI_SECURITY2_FILE_AUTHENTICATION FileAuthentication;
+};
diff --git a/src/boot/efi/proto/shell-parameters.h b/src/boot/efi/proto/shell-parameters.h
new file mode 100644
index 0000000..8080922
--- /dev/null
+++ b/src/boot/efi/proto/shell-parameters.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_SHELL_PARAMETERS_PROTOCOL_GUID \
+ GUID_DEF(0x752f3136, 0x4e16, 0x4fdc, 0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca)
+
+typedef struct {
+ char16_t **Argv;
+ size_t Argc;
+ void *StdIn;
+ void *StdOut;
+ void *StdErr;
+} EFI_SHELL_PARAMETERS_PROTOCOL;
diff --git a/src/boot/efi/proto/simple-text-io.h b/src/boot/efi/proto/simple-text-io.h
new file mode 100644
index 0000000..95016d3
--- /dev/null
+++ b/src/boot/efi/proto/simple-text-io.h
@@ -0,0 +1,182 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
+ GUID_DEF(0x387477c1, 0x69c7, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
+ GUID_DEF(0xdd9e7534, 0x7762, 0x4698, 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa)
+#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
+ GUID_DEF(0x387477c2, 0x69c7, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+
+#define EFI_SHIFT_STATE_VALID 0x80000000U
+#define EFI_RIGHT_SHIFT_PRESSED 0x00000001U
+#define EFI_LEFT_SHIFT_PRESSED 0x00000002U
+#define EFI_RIGHT_CONTROL_PRESSED 0x00000004U
+#define EFI_LEFT_CONTROL_PRESSED 0x00000008U
+#define EFI_RIGHT_ALT_PRESSED 0x00000010U
+#define EFI_LEFT_ALT_PRESSED 0x00000020U
+#define EFI_RIGHT_LOGO_PRESSED 0x00000040U
+#define EFI_LEFT_LOGO_PRESSED 0x00000080U
+#define EFI_MENU_KEY_PRESSED 0x00000100U
+#define EFI_SYS_REQ_PRESSED 0x00000200U
+
+#define EFI_TOGGLE_STATE_VALID 0x80U
+#define EFI_KEY_STATE_EXPOSED 0x40U
+#define EFI_SCROLL_LOCK_ACTIVE 0x01U
+#define EFI_NUM_LOCK_ACTIVE 0x02U
+#define EFI_CAPS_LOCK_ACTIVE 0x04U
+
+enum {
+ EFI_BLACK = 0x00,
+ EFI_BLUE = 0x01,
+ EFI_GREEN = 0x02,
+ EFI_CYAN = EFI_BLUE | EFI_GREEN,
+ EFI_RED = 0x04,
+ EFI_MAGENTA = EFI_BLUE | EFI_RED,
+ EFI_BROWN = EFI_GREEN | EFI_RED,
+ EFI_LIGHTGRAY = EFI_BLUE | EFI_GREEN | EFI_RED,
+ EFI_BRIGHT = 0x08,
+ EFI_DARKGRAY = EFI_BLACK | EFI_BRIGHT,
+ EFI_LIGHTBLUE = EFI_BLUE | EFI_BRIGHT,
+ EFI_LIGHTGREEN = EFI_GREEN | EFI_BRIGHT,
+ EFI_LIGHTCYAN = EFI_CYAN | EFI_BRIGHT,
+ EFI_LIGHTRED = EFI_RED | EFI_BRIGHT,
+ EFI_LIGHTMAGENTA = EFI_MAGENTA | EFI_BRIGHT,
+ EFI_YELLOW = EFI_BROWN | EFI_BRIGHT,
+ EFI_WHITE = EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT,
+};
+
+#define EFI_TEXT_ATTR(fg, bg) ((fg) | ((bg) << 4))
+#define EFI_TEXT_ATTR_SWAP(c) EFI_TEXT_ATTR(((c) & 0xF0U) >> 4, (c) & 0xFU)
+
+enum {
+ SCAN_NULL = 0x000,
+ SCAN_UP = 0x001,
+ SCAN_DOWN = 0x002,
+ SCAN_RIGHT = 0x003,
+ SCAN_LEFT = 0x004,
+ SCAN_HOME = 0x005,
+ SCAN_END = 0x006,
+ SCAN_INSERT = 0x007,
+ SCAN_DELETE = 0x008,
+ SCAN_PAGE_UP = 0x009,
+ SCAN_PAGE_DOWN = 0x00A,
+ SCAN_F1 = 0x00B,
+ SCAN_F2 = 0x00C,
+ SCAN_F3 = 0x00D,
+ SCAN_F4 = 0x00E,
+ SCAN_F5 = 0x00F,
+ SCAN_F6 = 0x010,
+ SCAN_F7 = 0x011,
+ SCAN_F8 = 0x012,
+ SCAN_F9 = 0x013,
+ SCAN_F10 = 0x014,
+ SCAN_F11 = 0x015,
+ SCAN_F12 = 0x016,
+ SCAN_ESC = 0x017,
+ SCAN_PAUSE = 0x048,
+ SCAN_F13 = 0x068,
+ SCAN_F14 = 0x069,
+ SCAN_F15 = 0x06A,
+ SCAN_F16 = 0x06B,
+ SCAN_F17 = 0x06C,
+ SCAN_F18 = 0x06D,
+ SCAN_F19 = 0x06E,
+ SCAN_F20 = 0x06F,
+ SCAN_F21 = 0x070,
+ SCAN_F22 = 0x071,
+ SCAN_F23 = 0x072,
+ SCAN_F24 = 0x073,
+ SCAN_MUTE = 0x07F,
+ SCAN_VOLUME_UP = 0x080,
+ SCAN_VOLUME_DOWN = 0x081,
+ SCAN_BRIGHTNESS_UP = 0x100,
+ SCAN_BRIGHTNESS_DOWN = 0x101,
+ SCAN_SUSPEND = 0x102,
+ SCAN_HIBERNATE = 0x103,
+ SCAN_TOGGLE_DISPLAY = 0x104,
+ SCAN_RECOVERY = 0x105,
+ SCAN_EJECT = 0x106,
+};
+
+typedef struct {
+ uint16_t ScanCode;
+ char16_t UnicodeChar;
+} EFI_INPUT_KEY;
+
+typedef struct {
+ uint32_t KeyShiftState;
+ uint8_t KeyToggleState;
+} EFI_KEY_STATE;
+
+typedef struct {
+ EFI_INPUT_KEY Key;
+ EFI_KEY_STATE KeyState;
+} EFI_KEY_DATA;
+
+struct EFI_SIMPLE_TEXT_INPUT_PROTOCOL {
+ EFI_STATUS (EFIAPI *Reset)(
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ bool ExtendedVerification);
+ EFI_STATUS (EFIAPI *ReadKeyStroke)(
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ EFI_INPUT_KEY *Key);
+ EFI_EVENT WaitForKey;
+};
+
+typedef struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
+struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL {
+ EFI_STATUS (EFIAPI *Reset)(
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ bool ExtendedVerification);
+ EFI_STATUS (EFIAPI *ReadKeyStrokeEx)(
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ EFI_KEY_DATA *KeyData);
+ EFI_EVENT WaitForKeyEx;
+ void *SetState;
+ void *RegisterKeyNotify;
+ void *UnregisterKeyNotify;
+};
+
+typedef struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
+struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL {
+ EFI_STATUS (EFIAPI *Reset)(
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ bool ExtendedVerification);
+ EFI_STATUS (EFIAPI *OutputString)(
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ char16_t *String);
+ EFI_STATUS (EFIAPI *TestString)(
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ char16_t *String);
+ EFI_STATUS (EFIAPI *QueryMode)(
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ size_t ModeNumber,
+ size_t *Columns,
+ size_t *Rows);
+ EFI_STATUS (EFIAPI *SetMode)(
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ size_t ModeNumber);
+ EFI_STATUS (EFIAPI *SetAttribute)(
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ size_t Attribute);
+ EFI_STATUS (EFIAPI *ClearScreen)(
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This);
+ EFI_STATUS (EFIAPI *SetCursorPosition)(
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ size_t Column,
+ size_t Row);
+ EFI_STATUS (EFIAPI *EnableCursor)(
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ bool Visible);
+ struct {
+ int32_t MaxMode;
+ int32_t Mode;
+ int32_t Attribute;
+ int32_t CursorColumn;
+ int32_t CursorRow;
+ bool CursorVisible;
+ } *Mode;
+};
diff --git a/src/boot/efi/proto/tcg.h b/src/boot/efi/proto/tcg.h
new file mode 100644
index 0000000..b4b8296
--- /dev/null
+++ b/src/boot/efi/proto/tcg.h
@@ -0,0 +1,117 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "efi.h"
+
+#define EFI_TCG_PROTOCOL_GUID \
+ GUID_DEF(0xf541796d, 0xa62e, 0x4954, 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd)
+#define EFI_TCG2_PROTOCOL_GUID \
+ GUID_DEF(0x607f766c, 0x7455, 0x42be, 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
+
+#define TCG_ALG_SHA 0x4
+#define EFI_TCG2_EVENT_HEADER_VERSION 1
+#define EV_IPL 13
+#define EV_EVENT_TAG UINT32_C(6)
+
+typedef struct {
+ uint8_t Major;
+ uint8_t Minor;
+ uint8_t RevMajor;
+ uint8_t RevMinor;
+} TCG_VERSION;
+
+typedef struct {
+ uint8_t Major;
+ uint8_t Minor;
+} EFI_TCG2_VERSION;
+
+typedef struct {
+ uint8_t Size;
+ TCG_VERSION StructureVersion;
+ TCG_VERSION ProtocolSpecVersion;
+ uint8_t HashAlgorithmBitmap;
+ bool TPMPresentFlag;
+ bool TPMDeactivatedFlag;
+} EFI_TCG_BOOT_SERVICE_CAPABILITY;
+
+typedef struct {
+ uint8_t Size;
+ EFI_TCG2_VERSION StructureVersion;
+ EFI_TCG2_VERSION ProtocolVersion;
+ uint32_t HashAlgorithmBitmap;
+ uint32_t SupportedEventLogs;
+ bool TPMPresentFlag;
+ uint16_t MaxCommandSize;
+ uint16_t MaxResponseSize;
+ uint32_t ManufacturerID;
+ uint32_t NumberOfPCRBanks;
+ uint32_t ActivePcrBanks;
+} EFI_TCG2_BOOT_SERVICE_CAPABILITY;
+
+typedef struct {
+ uint32_t PCRIndex;
+ uint32_t EventType;
+ struct {
+ uint8_t Digest[20];
+ } Digest;
+ uint32_t EventSize;
+ uint8_t Event[];
+} _packed_ TCG_PCR_EVENT;
+
+typedef struct {
+ uint32_t HeaderSize;
+ uint16_t HeaderVersion;
+ uint32_t PCRIndex;
+ uint32_t EventType;
+} _packed_ EFI_TCG2_EVENT_HEADER;
+
+typedef struct {
+ uint32_t Size;
+ EFI_TCG2_EVENT_HEADER Header;
+ uint8_t Event[];
+} _packed_ EFI_TCG2_EVENT;
+
+typedef struct {
+ uint32_t EventId;
+ uint32_t EventSize;
+ uint8_t Event[];
+} _packed_ EFI_TCG2_TAGGED_EVENT;
+
+typedef struct EFI_TCG_PROTOCOL EFI_TCG_PROTOCOL;
+struct EFI_TCG_PROTOCOL {
+ EFI_STATUS (EFIAPI *StatusCheck)(
+ EFI_TCG_PROTOCOL *This,
+ EFI_TCG_BOOT_SERVICE_CAPABILITY *ProtocolCapability,
+ uint32_t *TCGFeatureFlags,
+ EFI_PHYSICAL_ADDRESS *EventLogLocation,
+ EFI_PHYSICAL_ADDRESS *EventLogLastEntry);
+ void *HashAll;
+ void *LogEvent;
+ void *PassThroughToTpm;
+ EFI_STATUS (EFIAPI *HashLogExtendEvent)(
+ EFI_TCG_PROTOCOL *This,
+ EFI_PHYSICAL_ADDRESS HashData,
+ uint64_t HashDataLen,
+ uint32_t AlgorithmId,
+ TCG_PCR_EVENT *TCGLogData,
+ uint32_t *EventNumber,
+ EFI_PHYSICAL_ADDRESS *EventLogLastEntry);
+};
+
+typedef struct EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+struct EFI_TCG2_PROTOCOL {
+ EFI_STATUS (EFIAPI *GetCapability)(
+ EFI_TCG2_PROTOCOL *This,
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability);
+ void *GetEventLog;
+ EFI_STATUS (EFIAPI *HashLogExtendEvent)(
+ EFI_TCG2_PROTOCOL *This,
+ uint64_t Flags,
+ EFI_PHYSICAL_ADDRESS DataToHash,
+ uint64_t DataToHashLen,
+ EFI_TCG2_EVENT *EfiTcgEvent);
+ void *SubmitCommand;
+ void *GetActivePcrBanks;
+ void *SetActivePcrBanks;
+ void *GetResultOfSetActivePcrBanks;
+};