From 416a41745f64607b790b94839c850b6e9f2d4eee Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 13 Jan 2023 14:41:29 +0200 Subject: [PATCH] Kernel: Kernel::Panic now checks that TTY is initialized instead of VESA --- kernel/arch/i386/VESA.cpp | 7 ------- kernel/include/kernel/Panic.h | 4 ++-- kernel/include/kernel/TTY.h | 1 + kernel/include/kernel/VESA.h | 1 - kernel/kernel/TTY.cpp | 5 +++++ 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/kernel/arch/i386/VESA.cpp b/kernel/arch/i386/VESA.cpp index f5f3b481e..1a68bb2ba 100644 --- a/kernel/arch/i386/VESA.cpp +++ b/kernel/arch/i386/VESA.cpp @@ -26,7 +26,6 @@ namespace VESA static uint32_t s_width = 0; static uint32_t s_height = 0; static uint8_t s_mode = 0; - static bool s_initialized = false; static uint32_t s_terminal_width = 0; static uint32_t s_terminal_height = 0; @@ -83,11 +82,6 @@ namespace VESA return s_terminal_height; } - bool IsInitialized() - { - return s_initialized; - } - bool Initialize() { if (!(g_multiboot_info->flags & MULTIBOOT_FLAGS_FRAMEBUFFER)) @@ -138,7 +132,6 @@ namespace VESA SetCursorPositionImpl(0, 0, Color::BRIGHT_WHITE); ClearImpl(Color::BLACK); - s_initialized = true; return true; } diff --git a/kernel/include/kernel/Panic.h b/kernel/include/kernel/Panic.h index 100912009..4acf727a9 100644 --- a/kernel/include/kernel/Panic.h +++ b/kernel/include/kernel/Panic.h @@ -2,7 +2,7 @@ #include #include -#include +#include #define Panic(...) PanicImpl(__FILE__, __LINE__, __VA_ARGS__) @@ -13,7 +13,7 @@ namespace Kernel __attribute__((__noreturn__)) static void PanicImpl(const char* file, int line, const char* message, Args... args) { - if (VESA::IsInitialized()) + if (TTY::IsInitialized()) { kprint("\e[31mKernel panic at {}:{}\n", file, line); kprint(message, args...); diff --git a/kernel/include/kernel/TTY.h b/kernel/include/kernel/TTY.h index d481c70fb..7ac372616 100644 --- a/kernel/include/kernel/TTY.h +++ b/kernel/include/kernel/TTY.h @@ -20,6 +20,7 @@ public: // for kprint static void PutCharCurrent(char ch); + static bool IsInitialized(); private: void ResetAnsiEscape(); diff --git a/kernel/include/kernel/VESA.h b/kernel/include/kernel/VESA.h index f6d13744f..32ae48688 100644 --- a/kernel/include/kernel/VESA.h +++ b/kernel/include/kernel/VESA.h @@ -26,7 +26,6 @@ namespace VESA }; bool Initialize(); - bool IsInitialized(); void PutBitmapAt(const uint8_t*, uint32_t, uint32_t, Color); void PutBitmapAt(const uint8_t*, uint32_t, uint32_t, Color, Color); void PutCharAt(uint16_t, uint32_t, uint32_t, Color, Color); diff --git a/kernel/kernel/TTY.cpp b/kernel/kernel/TTY.cpp index 6a74d940d..34e27dd0e 100644 --- a/kernel/kernel/TTY.cpp +++ b/kernel/kernel/TTY.cpp @@ -351,3 +351,8 @@ void TTY::PutCharCurrent(char ch) ASSERT(s_tty); s_tty->PutChar(ch); } + +bool TTY::IsInitialized() +{ + return s_tty != nullptr; +}