Skip to content

Commit

Permalink
Kernel: Simplify the way we check for "serial_debug" on command line
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Aug 13, 2020
1 parent b777640 commit 6d9b59f
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions Kernel/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,24 +362,13 @@ void init_stage2()

void setup_serial_debug()
{
// this is only used one time, directly below here. we can't use this part
// of libc at this point in the boot process, or we'd just pull strstr in
// from <string.h>.
auto bad_prefix_check = [](const char* str, const char* search) -> bool {
while (*search)
if (*search++ != *str++)
return false;

return true;
};

// serial_debug will output all the klog() and dbg() data to COM1 at
// 8-N-1 57600 baud. this is particularly useful for debugging the boot
// process on live hardware.
//
// note: it must be the first option in the boot cmdline.
u32 cmdline = low_physical_to_virtual(multiboot_info_ptr->cmdline);
if (cmdline && bad_prefix_check(reinterpret_cast<const char*>(cmdline), "serial_debug"))
if (cmdline && StringView(reinterpret_cast<const char*>(cmdline)).starts_with("serial_debug"))
set_serial_debug(true);
}

Expand Down

0 comments on commit 6d9b59f

Please sign in to comment.