pass memory map to kernel and exit boot services
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user