diff options
| author | Ada Christine <adachristine18@gmail.com> | 2021-12-26 18:16:23 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2021-12-26 18:16:23 +0000 |
| commit | be8b55dbde1b2ac31d24a1cd30191549592c6868 (patch) | |
| tree | e5596c2b63935cf43a58de6624e17f682ea5bf54 /kc/boot/kc_main.c | |
| parent | 563286b7de047ffa2a2dd27f62c2b33ef03578ab (diff) | |
now possible to enter the kernel in physical address mode!
Diffstat (limited to 'kc/boot/kc_main.c')
| -rw-r--r-- | kc/boot/kc_main.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/kc/boot/kc_main.c b/kc/boot/kc_main.c index 744ced7..9829efd 100644 --- a/kc/boot/kc_main.c +++ b/kc/boot/kc_main.c @@ -1,4 +1,5 @@ #include <loader/efi/shim.h> +#include <kernel/entry.h> #include <kernel/memory/range.h> #include <stdbool.h> @@ -43,26 +44,36 @@ static struct efi_boot_data boot_data; static void collect_boot_data(void) { EFI_BOOT_SERVICES *ebs = loader_interface->system_table->BootServices; + SIMPLE_TEXT_OUTPUT_INTERFACE *eto = loader_interface->system_table-> + ConOut; EFI_STATUS status; - + boot_data.memory_map.size = 0; status = ebs->GetMemoryMap(&boot_data.memory_map.size, NULL, - NULL, + &boot_data.memory_map.key, NULL, NULL); if (EFI_BUFFER_TOO_SMALL == status) { - boot_data.memory_map.size += EFI_PAGE_SIZE; + eto->OutputString(eto, L"getting memory map size\r\n"); + boot_data.memory_map.buffer.size = boot_data.memory_map.size += + EFI_PAGE_SIZE; status = loader_interface->page_alloc(SystemMemoryType, - boot_data.memory_map.size, + boot_data.memory_map.buffer.size, (EFI_PHYSICAL_ADDRESS *)&boot_data.memory_map.buffer.base); } + if (EFI_ERROR(status)) + { + eto->OutputString(eto, L"failed allocating pages for memory map\r\n"); + } + if (!EFI_ERROR(status)) { + eto->OutputString(eto, L"got the memory map size\r\n"); boot_data.memory_map.size = boot_data.memory_map.buffer.size; status = ebs->GetMemoryMap(&boot_data.memory_map.size, @@ -74,6 +85,7 @@ static void collect_boot_data(void) if (EFI_ERROR(status)) { + eto->OutputString(eto, L"failed getting memory map\r\n"); __asm__ volatile ( "cli\n\t" @@ -109,6 +121,10 @@ EFI_STATUS kc_main(struct efi_loader_interface *interface) !EFI_ERROR((status = interface->image_load(&kernel_image)))) { collect_boot_data(); + Elf64_Ehdr *ehdr = (Elf64_Ehdr *)kernel_image.buffer_base; + kc_entry_func kernel_entry = (kc_entry_func) + (kernel_image.buffer_base + ehdr->e_entry); + kernel_entry(NULL); } __asm__ volatile ( |
