Skip to content

Commit

Permalink
Kernel: Allow to disable early boot console
Browse files Browse the repository at this point in the history
This aid debugging on bare metal when we suspect that the boot console
does something wrong that interferes with other kernel components.
  • Loading branch information
supercomputer7 authored and linusg committed Mar 18, 2022
1 parent 0ef1137 commit eca8f29
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Base/usr/share/man/man7/boot_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ List of options:

* **`disable_virtio`** - If present on the command line, virtio devices will not be detected, and initialized on boot.

* **`early_boot_console`** - This parameter expects **`on`** or **`off`** and is by default set to **`on`**.
When set to **`off`**, the kernel will not initialize any early console to show kernel dmesg output.
When set to **`on`**, the kernel will try to initialize either a text mode console (if VGA text mode was detected)
or framebuffer console, based on what the Multiboot bootloader specified on the physical address, width, height
and bit color depth.

* **`enable_ioapic`** - This parameter expects **`on`** or **`off`** and is by default set to **`on`**.
When set to **`off`**, the kernel will initialize the two i8259 PICs.
When set to **`on`**, the kernel will try to initialize the IOAPIC (or IOAPICs if there's more than one),
Expand Down
10 changes: 10 additions & 0 deletions Kernel/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ UNMAP_AFTER_INIT bool CommandLine::is_ioapic_enabled() const
PANIC("Unknown enable_ioapic setting: {}", value);
}

UNMAP_AFTER_INIT bool CommandLine::is_early_boot_console_disabled() const
{
auto value = lookup("early_boot_console"sv).value_or("on"sv);
if (value == "on"sv)
return false;
if (value == "off"sv)
return true;
PANIC("Unknown early_boot_console setting: {}", value);
}

UNMAP_AFTER_INIT bool CommandLine::is_vmmouse_enabled() const
{
return lookup("vmmouse"sv).value_or("on"sv) == "on"sv;
Expand Down
1 change: 1 addition & 0 deletions Kernel/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class CommandLine {
[[nodiscard]] bool disable_uhci_controller() const;
[[nodiscard]] bool disable_usb() const;
[[nodiscard]] bool disable_virtio() const;
[[nodiscard]] bool is_early_boot_console_disabled() const;
[[nodiscard]] AHCIResetMode ahci_reset_mode() const;
[[nodiscard]] StringView userspace_init() const;
[[nodiscard]] NonnullOwnPtrVector<KString> userspace_init_args() const;
Expand Down
10 changes: 6 additions & 4 deletions Kernel/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ extern "C" [[noreturn]] UNMAP_AFTER_INIT void init(BootInfo const& boot_info)
// NOTE: If the bootloader provided a framebuffer, then set up an initial console.
// If the bootloader didn't provide a framebuffer, then set up an initial text console.
// We do so we can see the output on the screen as soon as possible.
if (!multiboot_framebuffer_addr.is_null()) {
g_boot_console = &try_make_ref_counted<Graphics::BootFramebufferConsole>(multiboot_framebuffer_addr, multiboot_framebuffer_width, multiboot_framebuffer_height, multiboot_framebuffer_pitch).value().leak_ref();
} else {
g_boot_console = &Graphics::TextModeConsole::initialize().leak_ref();
if (!kernel_command_line().is_early_boot_console_disabled()) {
if (!multiboot_framebuffer_addr.is_null()) {
g_boot_console = &try_make_ref_counted<Graphics::BootFramebufferConsole>(multiboot_framebuffer_addr, multiboot_framebuffer_width, multiboot_framebuffer_height, multiboot_framebuffer_pitch).value().leak_ref();
} else {
g_boot_console = &Graphics::TextModeConsole::initialize().leak_ref();
}
}
dmesgln("Starting SerenityOS...");

Expand Down

0 comments on commit eca8f29

Please sign in to comment.