Kernel: Enabling Text mode debugging (#696)

Also added an option to start Serenity with text mode in QEMU
in the run script.
This commit is contained in:
Liav A 2019-10-29 17:41:40 +02:00 committed by Andreas Kling
parent 014f8ca8c4
commit ed45f67c00
Notes: sideshowbarker 2024-07-19 11:30:19 +09:00
2 changed files with 43 additions and 15 deletions

View file

@ -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.
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);
}
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,7 +269,10 @@ extern "C" [[noreturn]] void init()
id.device_id);
});
if (multiboot_info_ptr->framebuffer_type == 1) {
if (textmode) {
dbgprintf("Text mode enabled\n");
} else {
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,
@ -266,6 +281,7 @@ extern "C" [[noreturn]] void init()
} else {
new BXVGADevice;
}
}
LoopbackAdapter::the();
auto e1000 = E1000NetworkAdapter::autodetect();

View file

@ -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} \