[feat] BootLoader -> Kernel
This commit is contained in:
+9
-9
@@ -1,5 +1,4 @@
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
#include <graphics/context.h>
|
||||
#include <graphics/draw.h>
|
||||
#include <fonts/pixel_font.h>
|
||||
@@ -8,12 +7,14 @@
|
||||
#include <memory/pmm.h>
|
||||
#include <memory/heap.h>
|
||||
|
||||
extern EFI_SYSTEM_TABLE *ST;
|
||||
|
||||
inline void init_gop() {
|
||||
// 初始化 GOP
|
||||
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP;
|
||||
uefi_call_wrapper((void*)ST->BootServices->SetWatchdogTimer, 4, 0, 0, 0, NULL);
|
||||
uefi_call_wrapper((void*)ST->BootServices->LocateProtocol, 3, &gop_guid, NULL, (void **)&GOP);
|
||||
uefi_call_wrapper(ST->BootServices->SetWatchdogTimer, 4, 0, 0, 0, NULL);
|
||||
uefi_call_wrapper(ST->BootServices->LocateProtocol, 3, &gop_guid, NULL, (void **)&GOP);
|
||||
gfx_init(GOP);
|
||||
}
|
||||
|
||||
@@ -23,7 +24,7 @@ inline void init_serial() {
|
||||
EFI_GUID gEfiSerialIoProtocolGuid = EFI_SERIAL_IO_PROTOCOL_GUID;
|
||||
EFI_HANDLE *SerialHandles = NULL;
|
||||
UINTN NumSerials = 0;
|
||||
EFI_STATUS status = uefi_call_wrapper((void*)ST->BootServices->LocateHandleBuffer, 5,
|
||||
EFI_STATUS status = uefi_call_wrapper(ST->BootServices->LocateHandleBuffer, 5,
|
||||
ByProtocol,
|
||||
&gEfiSerialIoProtocolGuid,
|
||||
NULL,
|
||||
@@ -31,7 +32,7 @@ inline void init_serial() {
|
||||
&SerialHandles
|
||||
);
|
||||
if (status == EFI_SUCCESS && NumSerials > 0) {
|
||||
status = uefi_call_wrapper((void*)ST->BootServices->HandleProtocol, 3,
|
||||
status = uefi_call_wrapper(ST->BootServices->HandleProtocol, 3,
|
||||
SerialHandles[0], &gEfiSerialIoProtocolGuid, (void **)&SerialIo);
|
||||
if (status == EFI_SUCCESS) {
|
||||
serial_init(SerialIo);
|
||||
@@ -46,11 +47,10 @@ extern "C" void kernel_main() {
|
||||
init_gop();
|
||||
init_serial();
|
||||
|
||||
// 都用uefi_call_wrapper,不用会PF,不知道为什么
|
||||
uefi_call_wrapper((void*)ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, 5);
|
||||
uefi_call_wrapper((void*)ST->ConOut->OutputString, 2, ST->ConOut, L"Kernel is running!\n");
|
||||
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, 5);
|
||||
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*)L"Kernel is running!\n");
|
||||
|
||||
uefi_call_wrapper((void*)ST->ConOut->ClearScreen, 1, ST->ConOut);
|
||||
uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
|
||||
serial_write("\n\n"); // 防止和前面串了serial.log看不清
|
||||
|
||||
// init memory managers
|
||||
|
||||
Reference in New Issue
Block a user