setos

拙OS
Log | Files | Refs | LICENSE

commit ccb76c2a8da8ee339c38fa41a443fb92568360d7
parent f2ea84ec00be847a393feb278064e9c521fb5dbe
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Tue, 26 Mar 2024 08:00:21 +0900

open kernel.elf from uefi

Diffstat:
MMakefile | 2+-
Mloader.c | 19++++++-------------
2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile @@ -16,7 +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 cp kernel.elf image/kernel.elf doas umount image loader.dll: $(SRC) $(HDR) diff --git a/loader.c b/loader.c @@ -43,32 +43,25 @@ EfiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *systab) mmap->PhysicalStart, mmap->NumberOfPages, mmap->Attribute); } - EFI_FILE_PROTOCOL *root, *test; + EFI_FILE_PROTOCOL *root, *kernel; stat = open_root(ImageHandle, &root); if (stat != EFI_SUCCESS) { efi_printf("open_root: %d\n", stat); return stat; } - stat = root->Open(root, &test, L"test", - EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); + stat = root->Open(root, &kernel, L"kernel.elf", + EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0); if (stat != EFI_SUCCESS) { - efi_printf("open file \"test\": %d\n", stat); + efi_printf("open file \"kernel.elf\": %d\n", stat); return stat; } - char buf[10] = "01234567"; - UINTN bufsize = 10; - stat = test->Write(test, &bufsize, buf); - if (stat != EFI_SUCCESS) { - efi_printf("write to file: %d\n", stat); - return stat; - } - stat = test->Close(test); + + stat = kernel->Close(kernel); if (stat != EFI_SUCCESS) { efi_printf("close file: %d\n", stat); return stat; } - // Echo back user input. EFI_INPUT_KEY Key; CHAR16 str[2] = {' ', '\0'}; while(1) {