commit 091b5ebb01235e3ac673167c041f29762839404c
parent 990e3f256078c75d2032d1846f71af7ec99fdafe
Author: Matsuda Kenji <info@mtkn.jp>
Date: Tue, 19 Mar 2024 15:39:19 +0900
wip: open root directory
Diffstat:
3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -16,6 +16,7 @@ disk.img: loader.efi kernel.elf
doas mount disk.img image
doas mkdir -p image/EFI/BOOT
doas cp loader.efi image/EFI/BOOT/BOOTX64.EFI
+ doas cp kernel.elf image/EFI/BOOT/kernel.elf
doas umount image
loader.dll: $(SRC) $(HDR)
diff --git a/loader.c b/loader.c
@@ -1,6 +1,8 @@
#include "uefi.h"
#include "utils.h"
+#define NULL 0L
+
EFI_SYSTEM_TABLE *SystemTable;
EFI_STATUS
@@ -49,3 +51,16 @@ EfiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *systab)
return EFI_SUCCESS;
}
+
+EFI_STATUS
+open_root(EFI_HANDLE ImageHandle, EFI_FILE_PROTOCOL **root)
+{
+ EFI_STATUS stat;
+
+ stat = SystemTable->BootServices->OpenProtocol(
+ ImageHandle, &(EFI_GUID) EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
+ NULL, ImageHandle, ImageHandle, 0
+ );
+
+ return stat;
+}
+\ No newline at end of file
diff --git a/uefi.h b/uefi.h
@@ -6,6 +6,7 @@
typedef unsigned short CHAR16;
typedef unsigned long long UINTN;
+typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned UINT32;
typedef unsigned long long UINT64;
@@ -13,6 +14,16 @@ typedef UINTN EFI_STATUS;
typedef void *EFI_HANDLE;
typedef UINT64 EFI_PHYSICAL_ADDRESS;
typedef UINT64 EFI_VIRTUAL_ADDRESS;
+typedef void VOID;
+typedef struct EFI_GUID {
+ UINT32 Data1;
+ UINT16 Data2;
+ UINT16 Data3;
+ UINT8 Data4[8];
+} EFI_GUID;
+
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
+ {0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}}
// EFI_STATUS
enum {
@@ -85,6 +96,10 @@ typedef struct {
UINT64 Attribute;
} EFI_MEMORY_DESCRIPTOR;
+typedef struct _EFI_FILE_PROTOCOL {
+
+} EFI_FILE_PROTOCOL;
+
typedef
EFI_STATUS (EFIAPI *EFI_GET_MEMORY_MAP)(
IN OUT UINTN *MemoryMapSize,
@@ -98,6 +113,16 @@ typedef
EFI_STATUS (EFIAPI *EFI_EXIT_BOOT_SERVICES)(
);
+typedef
+EFI_STATUS (EFIAPI *EFI_OPEN_PROTOCOL)(
+ IN EFI_HANDLE Handle,
+ IN EFI_GUID *Protocol,
+ OUT VOID **Interface OPTIONAL,
+ IN EFI_HANDLE AgentHandle,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINT32 Attributes
+ );
+
typedef struct {
} EFI_RUNTIME_SERVICES;
@@ -124,7 +149,13 @@ typedef struct {
// image services
void *image_services0[4];
EFI_EXIT_BOOT_SERVICES ExitBootServices;
- void *dummy[17];
+ void *miscellaneus_services[3];
+ void *driversupport_services[2];
+ EFI_OPEN_PROTOCOL OpenProtocol;
+ void *open_and_close_protocol_services[2];
+ void *library_servies[5];
+ void *crc_services[1];
+ void *miscellaneus_services1[3];
} EFI_BOOT_SERVICES;
typedef struct {