commit 632937475fcc4fa80c4d5d364d87ab3c59756243
parent 091b5ebb01235e3ac673167c041f29762839404c
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 20 Mar 2024 19:14:25 +0900
add EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
Diffstat:
M | loader.c | | | 3 | ++- |
M | uefi.h | | | 66 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ |
2 files changed, 62 insertions(+), 7 deletions(-)
diff --git a/loader.c b/loader.c
@@ -56,9 +56,10 @@ EFI_STATUS
open_root(EFI_HANDLE ImageHandle, EFI_FILE_PROTOCOL **root)
{
EFI_STATUS stat;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs;
stat = SystemTable->BootServices->OpenProtocol(
- ImageHandle, &(EFI_GUID) EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
+ ImageHandle, &EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
NULL, ImageHandle, ImageHandle, 0
);
diff --git a/uefi.h b/uefi.h
@@ -23,7 +23,7 @@ typedef struct EFI_GUID {
} EFI_GUID;
#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
- {0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}}
+ ((EFI_GUID) {0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}})
// EFI_STATUS
enum {
@@ -35,10 +35,11 @@ typedef struct {
CHAR16 UnicodeChar;
} EFI_INPUT_KEY;
-struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
+typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
+
typedef
EFI_STATUS (EFIAPI *EFI_INPUT_READ_KEY)(
- IN struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
OUT EFI_INPUT_KEY *Key
);
@@ -49,7 +50,6 @@ typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL {
typedef struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
-struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
typedef
EFI_STATUS (EFIAPI *EFI_TEXT_STRING)(
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
@@ -96,9 +96,63 @@ typedef struct {
UINT64 Attribute;
} EFI_MEMORY_DESCRIPTOR;
-typedef struct _EFI_FILE_PROTOCOL {
+typedef struct _EFI_FILE_PROTOCOL EFI_FILE_PROTOCOL;
+
+typedef
+EFI_STATUS (EFIAPI *EFI_FILE_OPEN) (
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
+ );
+
+typedef
+EFI_STATUS (EFIAPI *EFI_FILE_CLOSE) (
+ IN EFI_FILE_PROTOCOL *This
+ );
+
+typedef
+EFI_STATUS (EFIAPI *EFI_FILE_DELETE) (
+ IN EFI_FILE_PROTOCOL *This
+ );
-} EFI_FILE_PROTOCOL;
+typedef
+EFI_STATUS (EFIAPI *EFI_FILE_READ) (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
+ );
+
+typedef
+EFI_STATUS (EFIAPI *EFI_FILE_WRITE) (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
+ );
+
+struct _EFI_FILE_PROTOCOL {
+ UINT64 Revision;
+ EFI_FILE_OPEN Open;
+ EFI_FILE_CLOSE Close;
+ EFI_FILE_DELETE Delete;
+ EFI_FILE_READ Read;
+ EFI_FILE_WRITE Write;
+ void *dummy[9];
+};
+
+typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
+
+typedef
+EFI_STATUS (EFIAPI *EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME)(
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **Root
+ );
+
+struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {
+ UINT64 Revision;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME OpenVolume;
+};
typedef
EFI_STATUS (EFIAPI *EFI_GET_MEMORY_MAP)(