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.
This commit is contained in:
Sergey Bugaev 2020-05-27 00:37:27 +03:00 committed by Andreas Kling
parent f11270e7ce
commit df128821b2
Notes: sideshowbarker 2024-07-19 06:04:58 +09:00

View File

@ -168,7 +168,9 @@ void init_stage2()
PCI::initialize(); 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"; dbg() << "Text mode enabled";
} else { } else {
bool bxvga_found = false; bool bxvga_found = false;
@ -213,7 +215,6 @@ void init_stage2()
DMIDecoder::initialize(); DMIDecoder::initialize();
} }
bool text_debug = kernel_command_line().contains("text_debug");
bool force_pio = kernel_command_line().contains("force_pio"); bool force_pio = kernel_command_line().contains("force_pio");
auto root = kernel_command_line().lookup("root").value_or("/dev/hda"); auto root = kernel_command_line().lookup("root").value_or("/dev/hda");
@ -302,28 +303,16 @@ void init_stage2()
int error; int error;
// SystemServer will start WindowServer, which will be doing graphics. // FIXME: It would be nicer to set the mode from userspace.
// From this point on we don't want to touch the VGA text terminal or tty0->set_graphical(!text_mode);
// accept keyboard input. Thread* thread = nullptr;
if (text_debug) { auto userspace_init = kernel_command_line().lookup("init").value_or("/bin/SystemServer");
tty0->set_graphical(false); Process::create_user_process(thread, userspace_init, (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0);
Thread* thread = nullptr; if (error != 0) {
Process::create_user_process(thread, "/bin/Shell", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0); klog() << "init_stage2: error spawning SystemServer: " << error;
if (error != 0) { hang();
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);
} }
thread->set_priority(THREAD_PRIORITY_HIGH);
NetworkTask::spawn(); NetworkTask::spawn();