pass memory map to kernel and exit boot services
This commit is contained in:
Binary file not shown.
@@ -113,6 +113,14 @@ int memcmp(const void* aptr, const void* bptr, size_t n){
|
|||||||
return 0;
|
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) {
|
EFI_STATUS efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
||||||
|
|
||||||
// sets up UEFI environment to be able to use
|
// 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");
|
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);
|
PSF1_FONT* newFont = LoadPSF1Font(NULL, L"zap-light18.psf", ImageHandle, SystemTable);
|
||||||
if (newFont == NULL) {
|
if (newFont == NULL) {
|
||||||
Print(L"Font is invalid or wasn't found.\n\r");
|
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->Height,
|
||||||
newBuffer->PixelsPerScanline);
|
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
|
return EFI_SUCCESS; // Exit the UEFI application
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,14 +4,22 @@
|
|||||||
#include "cstr.h"
|
#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
|
// supposed to protect against stack smashing but we have no way to actually like
|
||||||
// do anything when we detect it soooo...
|
// do anything when we detect it soooo...
|
||||||
extern "C" void __stack_chk_fail(void) {
|
extern "C" void __stack_chk_fail(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void _start(Framebuffer* framebuffer, PSF1_FONT* psf1_Font) {
|
extern "C" void _start(BootInfo* bootInfo) {
|
||||||
BasicRenderer newRenderer = BasicRenderer(framebuffer, psf1_Font);
|
BasicRenderer newRenderer = BasicRenderer(bootInfo->framebuffer, bootInfo->psf1_Font);
|
||||||
newRenderer.Print(0xFFFFFF, to_string((uint64_t)1234976));
|
newRenderer.Print(0xFFFFFF, to_string((uint64_t)1234976));
|
||||||
newRenderer.cursorPosition = {0, 18};
|
newRenderer.cursorPosition = {0, 18};
|
||||||
newRenderer.Print(0xFFFFFF, to_string((int64_t)-1234976));
|
newRenderer.Print(0xFFFFFF, to_string((int64_t)-1234976));
|
||||||
|
|||||||
Reference in New Issue
Block a user