From df128821b2ca675a47a86439f1fd0ad33bed737e Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Wed, 27 May 2020 00:37:27 +0300 Subject: [PATCH] Kernel: Introduce "boot_mode" and "init" cmdline options Together, they replace the old text_debug option. * boot_mode should be either "graphical" (the default) or "text". We could potentially support other values here in the future. * init specifies which userspace process the kernel should spawn to bootstrap userspace. By default, this is SystemServer, but you can specify e.g. init=/bin/Shell to run system diagnostics. --- Kernel/init.cpp | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 68f60bcf5b..9909b20ec2 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -168,7 +168,9 @@ void init_stage2() PCI::initialize(); - if (kernel_command_line().contains("text_debug")) { + bool text_mode = kernel_command_line().lookup("boot_mode").value_or("graphical") == "text"; + + if (text_mode) { dbg() << "Text mode enabled"; } else { bool bxvga_found = false; @@ -213,7 +215,6 @@ void init_stage2() DMIDecoder::initialize(); } - bool text_debug = kernel_command_line().contains("text_debug"); bool force_pio = kernel_command_line().contains("force_pio"); auto root = kernel_command_line().lookup("root").value_or("/dev/hda"); @@ -302,28 +303,16 @@ void init_stage2() int error; - // SystemServer will start WindowServer, which will be doing graphics. - // From this point on we don't want to touch the VGA text terminal or - // accept keyboard input. - if (text_debug) { - tty0->set_graphical(false); - Thread* thread = nullptr; - Process::create_user_process(thread, "/bin/Shell", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0); - if (error != 0) { - klog() << "init_stage2: error spawning Shell: " << error; - hang(); - } - thread->set_priority(THREAD_PRIORITY_HIGH); - } else { - tty0->set_graphical(true); - Thread* thread = nullptr; - Process::create_user_process(thread, "/bin/SystemServer", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0); - if (error != 0) { - klog() << "init_stage2: error spawning SystemServer: " << error; - hang(); - } - thread->set_priority(THREAD_PRIORITY_HIGH); + // FIXME: It would be nicer to set the mode from userspace. + tty0->set_graphical(!text_mode); + Thread* thread = nullptr; + auto userspace_init = kernel_command_line().lookup("init").value_or("/bin/SystemServer"); + Process::create_user_process(thread, userspace_init, (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0); + if (error != 0) { + klog() << "init_stage2: error spawning SystemServer: " << error; + hang(); } + thread->set_priority(THREAD_PRIORITY_HIGH); NetworkTask::spawn();