diff options
author | Nick Miller <nick.miller.83@gmail.com> | 2021-05-31 09:59:48 -0700 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-31 19:06:13 +0100 |
commit | 10ba6f254cfe40d2da6d811c4094f597bf0a959a (patch) | |
tree | 6b04ca00d6819c6b5f309f9a249a3fc402d7cbb3 | |
parent | 971523621cfdd18855e6c57c77fafcc3c23d2a12 (diff) | |
download | serenity-10ba6f254cfe40d2da6d811c4094f597bf0a959a.zip |
Kernel: Rename instances of IO port 0xe9 to BOCHS_DEBUG_PORT
-rw-r--r-- | Kernel/ConsoleDevice.cpp | 9 | ||||
-rw-r--r-- | Kernel/IO.h | 4 | ||||
-rw-r--r-- | Kernel/Syscalls/debug.cpp | 4 | ||||
-rw-r--r-- | Kernel/kprintf.cpp | 6 | ||||
-rw-r--r-- | Meta/CMake/all_the_debug_macros.cmake | 4 |
5 files changed, 17 insertions, 10 deletions
diff --git a/Kernel/ConsoleDevice.cpp b/Kernel/ConsoleDevice.cpp index a0f43654ea..dc4529047e 100644 --- a/Kernel/ConsoleDevice.cpp +++ b/Kernel/ConsoleDevice.cpp @@ -10,8 +10,8 @@ #include <Kernel/SpinLock.h> #include <Kernel/kstdio.h> -// Bytes output to 0xE9 end up on the Bochs console. It's very handy. -#define CONSOLE_OUT_TO_E9 +// Output bytes to kernel debug port 0xE9 (Bochs console). It's very handy. +#define CONSOLE_OUT_TO_BOCHS_DEBUG_PORT static AK::Singleton<ConsoleDevice> s_the; static Kernel::SpinLock g_console_lock; @@ -67,9 +67,8 @@ Kernel::KResultOr<size_t> ConsoleDevice::write(FileDescription&, u64, const Kern void ConsoleDevice::put_char(char ch) { Kernel::ScopedSpinLock lock(g_console_lock); -#ifdef CONSOLE_OUT_TO_E9 - //if (ch != 27) - IO::out8(0xe9, ch); +#ifdef CONSOLE_OUT_TO_BOCHS_DEBUG_PORT + IO::out8(IO::BOCHS_DEBUG_PORT, ch); #endif m_logbuffer.enqueue(ch); } diff --git a/Kernel/IO.h b/Kernel/IO.h index 3800d3fcfe..ae4bcd8e7c 100644 --- a/Kernel/IO.h +++ b/Kernel/IO.h @@ -13,6 +13,10 @@ namespace IO { +// Every character written to this IO port is written to the Bochs console +// (e.g. the console where Qemu is running). +static constexpr u16 BOCHS_DEBUG_PORT = 0xE9; + inline u8 in8(u16 port) { u8 value; diff --git a/Kernel/Syscalls/debug.cpp b/Kernel/Syscalls/debug.cpp index 5d2ddf24a6..7f864e5da2 100644 --- a/Kernel/Syscalls/debug.cpp +++ b/Kernel/Syscalls/debug.cpp @@ -19,7 +19,7 @@ KResultOr<int> Process::sys$dump_backtrace() KResultOr<int> Process::sys$dbgputch(u8 ch) { - IO::out8(0xe9, ch); + IO::out8(IO::BOCHS_DEBUG_PORT, ch); return 0; } @@ -33,7 +33,7 @@ KResultOr<size_t> Process::sys$dbgputstr(Userspace<const u8*> characters, int le return EFAULT; return buffer.value().read_buffered<1024>(length, [&](u8 const* buffer, size_t buffer_size) { for (size_t i = 0; i < buffer_size; ++i) - IO::out8(0xe9, buffer[i]); + IO::out8(IO::BOCHS_DEBUG_PORT, buffer[i]); return buffer_size; }); } diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp index 7765707957..9e3e3e0cc5 100644 --- a/Kernel/kprintf.cpp +++ b/Kernel/kprintf.cpp @@ -73,7 +73,7 @@ static void critical_console_out(char ch) serial_putch(ch); // No need to output things to the real ConsoleDevice as no one is likely // to read it (because we are in a fatal situation, so only print things and halt) - IO::out8(0xe9, ch); + IO::out8(IO::BOCHS_DEBUG_PORT, ch); // We emit chars directly to the string. this is necessary in few cases, // especially when we want to avoid any memory allocations... if (GraphicsManagement::is_initialized() && GraphicsManagement::the().console()) { @@ -91,7 +91,7 @@ static void console_out(char ch) if (ConsoleDevice::is_initialized()) { ConsoleDevice::the().put_char(ch); } else { - IO::out8(0xe9, ch); + IO::out8(IO::BOCHS_DEBUG_PORT, ch); } if (ConsoleManagement::is_initialized()) { ConsoleManagement::the().debug_tty()->emit_char(ch); @@ -149,7 +149,7 @@ static void debugger_out(char ch) { if (serial_debug) serial_putch(ch); - IO::out8(0xe9, ch); + IO::out8(IO::BOCHS_DEBUG_PORT, ch); } extern "C" void dbgputstr(const char* characters, size_t length) diff --git a/Meta/CMake/all_the_debug_macros.cmake b/Meta/CMake/all_the_debug_macros.cmake index 63d6fe1f1c..67217d23eb 100644 --- a/Meta/CMake/all_the_debug_macros.cmake +++ b/Meta/CMake/all_the_debug_macros.cmake @@ -209,3 +209,7 @@ set(WEBSERVER_DEBUG ON) # set(WRAPPER_GENERATOR_DEBUG ON) # Immediately finds violations during boot, shouldn't be discoverable by people who aren't working on fixing. # set(KMALLOC_VERIFY_NO_SPINLOCK_HELD ON) +# False positive: CONSOLE_OUT_TO_BOCHS_DEBUG_PORT is a flag for ConsoleDevice, not a feature. +# set(CONSOLE_OUT_TO_BOCHS_DEBUG_PORT) +# False positive: BOCHS_DEBUG_PORT represents an IO port constant +# set(BOCHS_DEBUG_PORT) |