diff --git a/OVMFbin/OVMF_VARS-pure-efi.fd b/OVMFbin/OVMF_VARS-pure-efi.fd index 1ee8d61..80b9da2 100644 Binary files a/OVMFbin/OVMF_VARS-pure-efi.fd and b/OVMFbin/OVMF_VARS-pure-efi.fd differ diff --git a/gnu-efi/bootloader/main.c b/gnu-efi/bootloader/main.c index 566814e..8e10c2f 100644 --- a/gnu-efi/bootloader/main.c +++ b/gnu-efi/bootloader/main.c @@ -113,6 +113,14 @@ int memcmp(const void* aptr, const void* bptr, size_t n){ return 0; } +typedef struct { + Framebuffer* framebuffer; + PSF1_FONT* psf1_Font; + EFI_MEMORY_DESCRIPTOR* mMap; + UINTN mMapSize; + UINTN mMapDescriptorSize; +} BootInfo; + EFI_STATUS efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) { // sets up UEFI environment to be able to use @@ -190,9 +198,6 @@ EFI_STATUS efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) { Print(L"Kernel loaded!\n\r"); - // Run the kernel's main function! :D - void (*KernelStart)(Framebuffer*, PSF1_FONT*) = ((__attribute__((sysv_abi)) void (*)(Framebuffer*, PSF1_FONT*) ) header.e_entry); - PSF1_FONT* newFont = LoadPSF1Font(NULL, L"zap-light18.psf", ImageHandle, SystemTable); if (newFont == NULL) { Print(L"Font is invalid or wasn't found.\n\r"); @@ -208,7 +213,31 @@ EFI_STATUS efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) { newBuffer->Height, newBuffer->PixelsPerScanline); - KernelStart(newBuffer, newFont); + EFI_MEMORY_DESCRIPTOR* Map = NULL; + UINTN MapSize, MapKey; + UINTN DescriptorSize; + UINT32 DescriptorVersion; + { + + SystemTable->BootServices->GetMemoryMap(&MapSize, Map, &MapKey, &DescriptorSize, &DescriptorVersion); + SystemTable->BootServices->AllocatePool(EfiLoaderData, MapSize, (void**)&Map); + SystemTable->BootServices->GetMemoryMap(&MapSize, Map, &MapKey, &DescriptorSize, &DescriptorVersion); + + } + + // Run the kernel's main function! :D + void (*KernelStart)(BootInfo*) = ((__attribute__((sysv_abi)) void (*)(BootInfo*) ) header.e_entry); + + BootInfo bootInfo; + bootInfo.framebuffer = newBuffer; + bootInfo.psf1_Font = newFont; + bootInfo.mMap = Map; + bootInfo.mMapSize = MapSize; + bootInfo.mMapDescriptorSize = DescriptorSize; + + SystemTable->BootServices->ExitBootServices(ImageHandle, MapKey); + + KernelStart(&bootInfo); return EFI_SUCCESS; // Exit the UEFI application } diff --git a/gnu-efi/x86_64/bootloader/main.efi b/gnu-efi/x86_64/bootloader/main.efi index 7aa8acf..64b50f8 100755 Binary files a/gnu-efi/x86_64/bootloader/main.efi and b/gnu-efi/x86_64/bootloader/main.efi differ diff --git a/kernel/bin/CustomOS.img b/kernel/bin/CustomOS.img index d3e0d33..df8a151 100644 Binary files a/kernel/bin/CustomOS.img and b/kernel/bin/CustomOS.img differ diff --git a/kernel/bin/kernel.elf b/kernel/bin/kernel.elf index 18b8c79..f9af8cf 100755 Binary files a/kernel/bin/kernel.elf and b/kernel/bin/kernel.elf differ diff --git a/kernel/lib/kernel.o b/kernel/lib/kernel.o index d089ee4..c85e5ca 100644 Binary files a/kernel/lib/kernel.o and b/kernel/lib/kernel.o differ diff --git a/kernel/src/kernel.cpp b/kernel/src/kernel.cpp index 0d47bab..af5cf45 100644 --- a/kernel/src/kernel.cpp +++ b/kernel/src/kernel.cpp @@ -4,14 +4,22 @@ #include "cstr.h" +struct BootInfo { + Framebuffer* framebuffer; + PSF1_FONT* psf1_Font; + void* mMap; + uint64_t mMapSize; + uint64_t mMapDescriptorSize; +}; + // supposed to protect against stack smashing but we have no way to actually like // do anything when we detect it soooo... extern "C" void __stack_chk_fail(void) { return; } -extern "C" void _start(Framebuffer* framebuffer, PSF1_FONT* psf1_Font) { - BasicRenderer newRenderer = BasicRenderer(framebuffer, psf1_Font); +extern "C" void _start(BootInfo* bootInfo) { + BasicRenderer newRenderer = BasicRenderer(bootInfo->framebuffer, bootInfo->psf1_Font); newRenderer.Print(0xFFFFFF, to_string((uint64_t)1234976)); newRenderer.cursorPosition = {0, 18}; newRenderer.Print(0xFFFFFF, to_string((int64_t)-1234976));