summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorSkye Sprung <skye.sprung@gmail.com>2022-08-24 23:49:23 +0200
committerSam Atkins <atkinssj@gmail.com>2022-08-27 19:42:52 +0100
commiteca85f205020b23af0f4a68b3431d2574b2824c8 (patch)
tree95733857126e55f04f58ed6f9b7bb86607c1cb3c /Kernel
parentcd763de28085b9b5cbbd97fc4a7906aaa2dd89b7 (diff)
downloadserenity-eca85f205020b23af0f4a68b3431d2574b2824c8.zip
Kernel: Changed serial debug functions and variables for readability
Change the name of set_serial_debug(bool on_or_off) to set_serial_debug_enabled(bool desired_state). This is to make the names more expressive and less unclear as to what the function does, as it only sets the enabled state. Likewise, change the name of get_serial_debug() to is_serial_debug_enabled() in order to make clear from the name that this is simply the state of s_serial_debug_enabled. Change the name of serial_debug to s_serial_debug_enabled since this is a static bool describing this state. Finally, change the signature of set_serial_debug_enabled to return a bool, as this is more logical and understandable.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/init.cpp4
-rw-r--r--Kernel/kprintf.cpp16
-rw-r--r--Kernel/kstdio.h4
3 files changed, 12 insertions, 12 deletions
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 67292fdfa3..c8c82f8d4b 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -319,7 +319,7 @@ void init_stage2(void*)
VirtualFileSystem::initialize();
- if (!get_serial_debug())
+ if (!is_serial_debug_enabled())
(void)SerialDevice::must_create(0).leak_ref();
(void)SerialDevice::must_create(1).leak_ref();
(void)SerialDevice::must_create(2).leak_ref();
@@ -409,7 +409,7 @@ UNMAP_AFTER_INIT void setup_serial_debug()
// 8-N-1 57600 baud. this is particularly useful for debugging the boot
// process on live hardware.
if (StringView { kernel_cmdline, strlen(kernel_cmdline) }.contains("serial_debug"sv)) {
- set_serial_debug(true);
+ set_serial_debug_enabled(true);
}
}
diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp
index b42888e19e..94fb169e90 100644
--- a/Kernel/kprintf.cpp
+++ b/Kernel/kprintf.cpp
@@ -23,19 +23,19 @@ namespace Kernel {
extern Atomic<Graphics::Console*> g_boot_console;
}
-static bool serial_debug;
+static bool s_serial_debug_enabled;
// A recursive spinlock allows us to keep writing in the case where a
// page fault happens in the middle of a dbgln(), etc
static RecursiveSpinlock s_log_lock { LockRank::None };
-void set_serial_debug(bool on_or_off)
+void set_serial_debug_enabled(bool desired_state)
{
- serial_debug = on_or_off;
+ s_serial_debug_enabled = desired_state;
}
-int get_serial_debug()
+bool is_serial_debug_enabled()
{
- return serial_debug;
+ return s_serial_debug_enabled;
}
static void serial_putch(char ch)
@@ -71,7 +71,7 @@ static void serial_putch(char ch)
static void critical_console_out(char ch)
{
- if (serial_debug)
+ if (s_serial_debug_enabled)
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)
@@ -87,7 +87,7 @@ static void critical_console_out(char ch)
static void console_out(char ch)
{
- if (serial_debug)
+ if (s_serial_debug_enabled)
serial_putch(ch);
// It would be bad to reach the assert in ConsoleDevice()::the() and do a stack overflow
@@ -151,7 +151,7 @@ int snprintf(char* buffer, size_t size, char const* fmt, ...)
static inline void internal_dbgputch(char ch)
{
- if (serial_debug)
+ if (s_serial_debug_enabled)
serial_putch(ch);
IO::out8(IO::BOCHS_DEBUG_PORT, ch);
}
diff --git a/Kernel/kstdio.h b/Kernel/kstdio.h
index d560b4b8c0..1006e607b8 100644
--- a/Kernel/kstdio.h
+++ b/Kernel/kstdio.h
@@ -15,8 +15,8 @@ void kernelputstr(char const*, size_t);
void kernelcriticalputstr(char const*, size_t);
void kernelearlyputstr(char const*, size_t);
int snprintf(char* buf, size_t, char const* fmt, ...) __attribute__((format(printf, 3, 4)));
-void set_serial_debug(bool on_or_off);
-int get_serial_debug();
+void set_serial_debug_enabled(bool desired_state);
+bool is_serial_debug_enabled();
}
void dbgputstr(StringView view);