ソースを参照

Kernel: Enabling Text mode debugging (#696)

Also added an option to start Serenity with text mode in QEMU
in the run script.
Liav A 5 年 前
コミット
ed45f67c00
2 ファイル変更43 行追加15 行削除
  1. 31 15
      Kernel/init.cpp
  2. 12 0
      Kernel/run

+ 31 - 15
Kernel/init.cpp

@@ -68,6 +68,8 @@ VFS* vfs;
     auto dev_random = make<RandomDevice>();
     auto dev_ptmx = make<PTYMultiplexer>();
 
+    bool textmode = !KParams::the().get("text_debug").is_null();
+
     auto root = KParams::the().get("root");
     if (root.is_empty()) {
         root = "/dev/hda";
@@ -163,15 +165,23 @@ VFS* vfs;
     // 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.
-    tty0->set_graphical(true);
-
-    auto* system_server_process = Process::create_user_process("/bin/SystemServer", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0);
-    if (error != 0) {
-        kprintf("init_stage2: error spawning SystemServer: %d\n", error);
-        hang();
+    if (textmode) {
+        tty0->set_graphical(false);
+        auto* shell_process = Process::create_user_process("/bin/Shell", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0);
+        if (error != 0) {
+            kprintf("init_stage2: error spawning Shell: %d\n", error);
+            hang();
+        }
+        shell_process->set_priority(Process::HighPriority);
+    } else {
+        tty0->set_graphical(true);
+        auto* system_server_process = Process::create_user_process("/bin/SystemServer", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0);
+        if (error != 0) {
+            kprintf("init_stage2: error spawning SystemServer: %d\n", error);
+            hang();
+        }
+        system_server_process->set_priority(Process::HighPriority);
     }
-    system_server_process->set_priority(Process::HighPriority);
-
     Process::create_kernel_process("NetworkTask", NetworkTask_main);
 
     current->process().sys$exit(0);
@@ -212,6 +222,8 @@ extern "C" [[noreturn]] void init()
     // must come after kmalloc_init because we use AK_MAKE_ETERNAL in KParams
     new KParams(String(reinterpret_cast<const char*>(multiboot_info_ptr->cmdline)));
 
+    bool textmode = !KParams::the().get("text_debug").is_null();
+
     vfs = new VFS;
     dev_debuglog = new DebugLogDevice;
 
@@ -257,14 +269,18 @@ extern "C" [[noreturn]] void init()
             id.device_id);
     });
 
-    if (multiboot_info_ptr->framebuffer_type == 1) {
-        new MBVGADevice(
-            PhysicalAddress((u32)(multiboot_info_ptr->framebuffer_addr)),
-            multiboot_info_ptr->framebuffer_pitch,
-            multiboot_info_ptr->framebuffer_width,
-            multiboot_info_ptr->framebuffer_height);
+    if (textmode) {
+        dbgprintf("Text mode enabled\n");
     } else {
-        new BXVGADevice;
+        if (multiboot_info_ptr->framebuffer_type == 1 || multiboot_info_ptr->framebuffer_type == 2) {
+            new MBVGADevice(
+                PhysicalAddress((u32)(multiboot_info_ptr->framebuffer_addr)),
+                multiboot_info_ptr->framebuffer_pitch,
+                multiboot_info_ptr->framebuffer_width,
+                multiboot_info_ptr->framebuffer_height);
+        } else {
+            new BXVGADevice;
+        }
     }
 
     LoopbackAdapter::the();

+ 12 - 0
Kernel/run

@@ -51,6 +51,18 @@ elif [ "$1" = "qgrub" ]; then
         -device e1000,netdev=breh \
         -hda _disk_image \
         -soundhw pcspk
+elif [ "$1" = "qtext" ]; then
+    $SERENITY_QEMU_BIN -s -m ${SERENITY_RAM_SIZE:-128} \
+        $SERENITY_EXTRA_QEMU_ARGS \
+        -d cpu_reset,guest_errors \
+        -device VGA,vgamem_mb=64 \
+        -debugcon stdio \
+        -device e1000 \
+        -kernel kernel \
+        -append "${SERENITY_KERNEL_CMDLINE} text_debug" \
+        -hda _disk_image \
+        -soundhw pcspk \
+        -soundhw sb16
 else
     # ./run: qemu with user networking
     $SERENITY_QEMU_BIN -s -m ${SERENITY_RAM_SIZE:-128} \