setos

拙OS
Log | Files | Refs | LICENSE

commit c1a1b1f2336cdd783ace6ee34af7ff13a03b25a4
parent 09dcf5409ce00122ecb34954ff60b45b6d1a957a
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Tue, 26 Mar 2024 13:30:12 +0900

execute kernel code

Diffstat:
Mkernel.ld | 2+-
Mloader.c | 16+++++++++-------
Muefi.h | 30+++++++++++++++++++++---------
3 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/kernel.ld b/kernel.ld @@ -1,6 +1,6 @@ SECTIONS { - .text 0x10000 : { + .text 0x100000 : { *(.text) } .data : { diff --git a/loader.c b/loader.c @@ -65,24 +65,26 @@ EfiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *systab) efi_printf("get info of \"kernel.elf\": %d\n", stat); return stat; } - efi_printf("file size: %d\n", fileInfo->FileSize); - - UINTN kernel_size = 1024; + stat = kernel->SetPosition(kernel, 0x1000); + if (stat != EFI_SUCCESS) { + efi_printf("set position of \"kernel.elf\": %d\n", stat); + return stat; + } + UINTN kernel_size = 0x10; stat = kernel->Read(kernel, &kernel_size, (VOID *)kernel_base); if (stat != EFI_SUCCESS) { efi_printf("read file \"kernel.elf\": %d\n", stat); return stat; } - - typedef void (* Kernel) (void); - ((Kernel) kernel_base)(); - stat = kernel->Close(kernel); if (stat != EFI_SUCCESS) { efi_printf("close file: %d\n", stat); return stat; } + typedef void (* Kernel) (void); + ((Kernel) kernel_base)(); + EFI_INPUT_KEY Key; CHAR16 str[2] = {' ', '\0'}; while(1) { diff --git a/uefi.h b/uefi.h @@ -33,7 +33,6 @@ typedef struct EFI_GUID { ((EFI_GUID) {0x9576e92, 0x6d3f, 0x11d2, \ {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}}) - // EFI_STATUS enum { EFI_SUCCESS = 0, @@ -147,6 +146,18 @@ EFI_STATUS (EFIAPI *EFI_FILE_WRITE) ( ); typedef +EFI_STATUS (EFIAPI *EFI_FILE_SET_POSITION) ( + IN EFI_FILE_PROTOCOL *This, + IN UINT64 Position + ); + +typedef +EFI_STATUS (EFIAPI *EFI_FILE_GET_POSITION) ( + IN EFI_FILE_PROTOCOL *This, + OUT UINT64 *Position + ); + +typedef EFI_STATUS (EFIAPI *EFI_FILE_GET_INFO) ( IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, @@ -155,14 +166,15 @@ EFI_STATUS (EFIAPI *EFI_FILE_GET_INFO) ( ); 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[2]; - EFI_FILE_GET_INFO GetInfo; + UINT64 Revision; + EFI_FILE_OPEN Open; + EFI_FILE_CLOSE Close; + EFI_FILE_DELETE Delete; + EFI_FILE_READ Read; + EFI_FILE_WRITE Write; + EFI_FILE_GET_POSITION GetPosition; + EFI_FILE_SET_POSITION SetPosition; + EFI_FILE_GET_INFO GetInfo; void *dummy1[6]; };