From 9c31790359dde27fc4fbce5092181f3a912cce98 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 25 Jan 2023 21:44:09 +0200 Subject: [PATCH] Kernel: Add option to disable Serial output This makes all debug output to appear on the TTY --- iso.sh | 6 ++++++ kernel/kernel/kernel.cpp | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/iso.sh b/iso.sh index 99f6bfbca6..521c6e60a1 100755 --- a/iso.sh +++ b/iso.sh @@ -11,8 +11,14 @@ cat > isodir/boot/grub/grub.cfg << EOF menuentry "banan-os" { multiboot /boot/banan-os.kernel } +menuentry "banan-os (no serial)" { + multiboot /boot/banan-os.kernel noserial +} menuentry "banan-os (no apic)" { multiboot /boot/banan-os.kernel noapic } +menuentry "banan-os (no apic, no serial)" { + multiboot /boot/banan-os.kernel noapic noserial +} EOF grub-mkrescue -o banan-os.iso isodir diff --git a/kernel/kernel/kernel.cpp b/kernel/kernel/kernel.cpp index 4f0cd24c26..467864bf8b 100644 --- a/kernel/kernel/kernel.cpp +++ b/kernel/kernel/kernel.cpp @@ -22,7 +22,8 @@ using namespace BAN; struct ParsedCommandLine { - bool force_pic = false; + bool force_pic = false; + bool disable_serial = false; }; ParsedCommandLine ParseCommandLine() @@ -41,6 +42,9 @@ ParsedCommandLine ParseCommandLine() if (current - start == 6 && memcmp(start, "noapic", 6) == 0) result.force_pic = true; + if (current - start == 8 && memcmp(start, "noserial", 8) == 0) + result.disable_serial = true; + if (!*current) break; start = current + 1; @@ -55,7 +59,10 @@ extern "C" void kernel_main() { DISABLE_INTERRUPTS(); - Serial::initialize(); + auto cmdline = ParseCommandLine(); + + if (!cmdline.disable_serial) + Serial::Initialize(); if (g_multiboot_magic != 0x2BADB002) { dprintln("Invalid multiboot magic number"); @@ -63,8 +70,6 @@ extern "C" void kernel_main() } dprintln("Serial output initialized"); - auto cmdline = ParseCommandLine(); - kmalloc_initialize(); dprintln("kmalloc initialized");