[chore] EVERYTHING!
This commit is contained in:
+9
-6
@@ -4,8 +4,10 @@
|
||||
#include <graphics/draw.h>
|
||||
#include <fonts/pixel_font.h>
|
||||
#include <serial.h>
|
||||
#include <common.h>
|
||||
|
||||
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);
|
||||
@@ -14,6 +16,7 @@ inline void init_gop() {
|
||||
}
|
||||
|
||||
inline void init_serial() {
|
||||
// 初始化串行驱动
|
||||
EFI_SERIAL_IO_PROTOCOL *SerialIo = NULL;
|
||||
EFI_GUID gEfiSerialIoProtocolGuid = EFI_SERIAL_IO_PROTOCOL_GUID;
|
||||
EFI_HANDLE *SerialHandles = NULL;
|
||||
@@ -41,15 +44,15 @@ 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((void*)ST->ConOut->ClearScreen, 1, ST->ConOut);
|
||||
serial_write("\n\n"); // 防止和前面串了
|
||||
serial_write("\n\n"); // 防止和前面串了serial.log看不清
|
||||
|
||||
// pf_print_char('k', 10, 10);
|
||||
pf_print("Welcome to Sylva OS!", 10, 10);
|
||||
serial_write("Hello from serial!\n");
|
||||
serial_write("Hello from serial line 2!");
|
||||
while (1);
|
||||
pf_print("Welcome to Sylva OS!\n");
|
||||
serial_write(" Kernel prepared well, start loop.\n");
|
||||
|
||||
while (1) ASM ("hlt"); // 《30天》看多了 (doge
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <serial.h>
|
||||
#include <efilib.h>
|
||||
#include <fonts/pixel_font.h>
|
||||
#include <BUILD_INFOS.h>
|
||||
|
||||
serial_context g_serial;
|
||||
|
||||
@@ -9,12 +11,14 @@ void serial_init(EFI_SERIAL_IO_PROTOCOL *SerialIo) {
|
||||
}
|
||||
|
||||
void serial_write_char(char c) {
|
||||
// 不要直接调用,ENABLE_SERIAL_PRINTS有问题,因此不会打印DEBUG
|
||||
if (!g_serial.SerialIo) {
|
||||
uefi_call_wrapper((void*)ST->ConOut->OutputString, 2, ST->ConOut, L"serial: null io\n");
|
||||
return;
|
||||
}
|
||||
UINTN size = 1;
|
||||
EFI_STATUS status = uefi_call_wrapper((void*)g_serial.SerialIo->Write, 3, g_serial.SerialIo, &size, &c);
|
||||
// if (ENABLE_SERIAL_PRINTS) pf_print((const char*) c);
|
||||
if (status != EFI_SUCCESS) {
|
||||
uefi_call_wrapper((void*)ST->ConOut->OutputString, 2, ST->ConOut, L"serial: write failed\n");
|
||||
}
|
||||
@@ -25,12 +29,14 @@ void serial_write(const char *str) {
|
||||
uefi_call_wrapper((void*)ST->ConOut->OutputString, 2, ST->ConOut, L"serial: null io\n");
|
||||
return;
|
||||
}
|
||||
if (ENABLE_SERIAL_PRINTS) pf_print(str);
|
||||
while (*str) {
|
||||
serial_write_char(*str++);
|
||||
}
|
||||
}
|
||||
|
||||
char serial_read_char() {
|
||||
// 后面可能用的上,比如远程调试?
|
||||
if (!g_serial.SerialIo) return 0;
|
||||
char c = 0;
|
||||
UINTN size = 1;
|
||||
|
||||
Reference in New Issue
Block a user