diff options
| author | Ada Christine <adachristine18@gmail.com> | 2025-01-27 02:05:07 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2025-01-27 02:05:07 +0000 |
| commit | 0d2ddecc9aeb232746b76b4eebdb1381053a8951 (patch) | |
| tree | 31fe2fc38ead88a0d982b06b3783aae4f094b8ad /boot/efi | |
| parent | 6faeb8d3aed797ddfac66ecc21fc8a717d5e848a (diff) | |
checkpoint. we can fake syscall with the dummy gdt
Diffstat (limited to 'boot/efi')
| -rw-r--r-- | boot/efi/image.c | 48 | ||||
| -rw-r--r-- | boot/efi/start.c | 10 |
2 files changed, 42 insertions, 16 deletions
diff --git a/boot/efi/image.c b/boot/efi/image.c index 25e1911..b9b4891 100644 --- a/boot/efi/image.c +++ b/boot/efi/image.c @@ -14,12 +14,6 @@ #include <efi/error.h> -struct image_buffer -{ - char *base; - size_t length; -}; - static int create_image_buffer(int fd, struct image_buffer *buffer) { if ((buffer->length = elf64_size_fd(fd)) == 0) @@ -89,9 +83,9 @@ kjarna_image_entry_func *image_entry_addr(struct image_buffer *buffer) return (kjarna_image_entry_func *)(buffer->base + ehdr->e_entry); } -int image_start(void) +struct kjarna_interface get_boot_interface(void) { - struct kjarna_interface interface = + struct kjarna_interface result = { efi_open, efi_close, @@ -102,6 +96,30 @@ int image_start(void) efi_munmap }; + return result; +} + +struct kjarna_boot_image get_boot_image(void) +{ + struct kjarna_boot_image image = + { + { nullptr, 0 }, + nullptr + }; + + image.buffer = load_image(); + + if (image.buffer.base != nullptr) + { + image.entry = image_entry_addr(&image.buffer); + } + + return image; +} + +int image_start(void) +{ + struct kjarna_interface interface = get_boot_interface(); struct kjarna_entry_params params = { &interface, @@ -110,21 +128,19 @@ int image_start(void) nullptr }; - struct image_buffer buffer = load_image(); - - kjarna_image_entry_func *image_entry = nullptr; + struct kjarna_boot_image image = get_boot_image(); - if (buffer.base != nullptr) + if (image.buffer.base != nullptr) { - image_entry = image_entry_addr(&buffer); + image.entry = image_entry_addr(&image.buffer); } - if (image_entry != nullptr) + if (image.entry != nullptr) { - image_entry(¶ms); + image.entry(¶ms); } - if (munmap(buffer.base, buffer.length) == -1) + if (munmap(image.buffer.base, image.buffer.length) == -1) { write(STDOUT_FILENO, "failed unmap\r\n", -1); diff --git a/boot/efi/start.c b/boot/efi/start.c index f1f4ec7..fc44377 100644 --- a/boot/efi/start.c +++ b/boot/efi/start.c @@ -28,8 +28,18 @@ EFI_STATUS _start(EFI_HANDLE handle, EFI_SYSTEM_TABLE *system_table) EFI_GUID lip_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID; EFI_LOADED_IMAGE_PROTOCOL *lip = efi_get_protocol(efi_context->handle, &lip_guid); + uint64_t text_base; + uint64_t data_base; + printf("DEBUG: EFI_LOADED_IMAGE_PROTOCOL { .ImageBase = %p }\n", lip->ImageBase); __asm__ volatile ("movq %0, %%rax" :: "r"(lip->ImageBase) : "rax"); + __asm__ volatile ( + "lea .text, %0\n" + "lea .data, %1\n" + : "=r"(text_base), "=r"(data_base) + : + ); + printf("DEBUG: .text %p .data %p\n", text_base, data_base); bool wait = true; while(wait) |
