Kernel: Add temporary terminal output before controlling terminal

Starting work on getting this boot on real hardware.
This commit is contained in:
Bananymous 2023-10-13 03:31:36 +03:00
parent 773dcdd3a2
commit 39be6ab099
2 changed files with 40 additions and 5 deletions

View File

@ -6,6 +6,10 @@
#include <kernel/Terminal/TTY.h> #include <kernel/Terminal/TTY.h>
#include <kernel/Timer/Timer.h> #include <kernel/Timer/Timer.h>
#include <ctype.h>
extern TerminalDriver* g_terminal_driver;
namespace Debug namespace Debug
{ {
@ -64,6 +68,35 @@ namespace Debug
return Kernel::Serial::putchar_any(ch); return Kernel::Serial::putchar_any(ch);
if (Kernel::TTY::is_initialized()) if (Kernel::TTY::is_initialized())
return Kernel::TTY::putchar_current(ch); return Kernel::TTY::putchar_current(ch);
if (g_terminal_driver)
{
static uint32_t col = 0;
static uint32_t row = 0;
if (ch == '\n')
{
row++;
col = 0;
}
else if (ch == '\r')
{
col = 0;
}
else
{
if (!isprint(ch))
ch = '?';
g_terminal_driver->putchar_at(ch, col, row, TerminalColor::BRIGHT_WHITE, TerminalColor::BLACK);
col++;
if (col >= g_terminal_driver->width())
{
row++;
col = 0;
}
}
}
} }
void print_prefix(const char* file, int line) void print_prefix(const char* file, int line)

View File

@ -82,6 +82,8 @@ static void parse_command_line()
extern "C" uint8_t g_userspace_start[]; extern "C" uint8_t g_userspace_start[];
extern "C" uint8_t g_userspace_end[]; extern "C" uint8_t g_userspace_end[];
TerminalDriver* g_terminal_driver = nullptr;
static void init2(void*); static void init2(void*);
extern "C" void kernel_main() extern "C" void kernel_main()
@ -114,6 +116,10 @@ extern "C" void kernel_main()
PageTable::initialize(); PageTable::initialize();
dprintln("PageTable initialized"); dprintln("PageTable initialized");
g_terminal_driver = VesaTerminalDriver::create();
ASSERT(g_terminal_driver);
dprintln("VESA initialized");
Heap::initialize(); Heap::initialize();
dprintln("Heap initialzed"); dprintln("Heap initialzed");
@ -141,11 +147,7 @@ extern "C" void kernel_main()
dprintln("Serial devices initialized"); dprintln("Serial devices initialized");
} }
TerminalDriver* terminal_driver = VesaTerminalDriver::create(); auto vtty = MUST(VirtualTTY::create(g_terminal_driver));
ASSERT(terminal_driver);
dprintln("VESA initialized");
auto vtty = MUST(VirtualTTY::create(terminal_driver));
dprintln("Virtual TTY initialized"); dprintln("Virtual TTY initialized");
MUST(Scheduler::initialize()); MUST(Scheduler::initialize());