Skip to content

Commit ed45f67

Browse files
supercomputer7awesomekling
authored andcommitted
Kernel: Enabling Text mode debugging (#696)
Also added an option to start Serenity with text mode in QEMU in the run script.
1 parent 014f8ca commit ed45f67

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed

Kernel/init.cpp

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ VFS* vfs;
6868
auto dev_random = make<RandomDevice>();
6969
auto dev_ptmx = make<PTYMultiplexer>();
7070

71+
bool textmode = !KParams::the().get("text_debug").is_null();
72+
7173
auto root = KParams::the().get("root");
7274
if (root.is_empty()) {
7375
root = "/dev/hda";
@@ -163,15 +165,23 @@ VFS* vfs;
163165
// SystemServer will start WindowServer, which will be doing graphics.
164166
// From this point on we don't want to touch the VGA text terminal or
165167
// accept keyboard input.
166-
tty0->set_graphical(true);
167-
168-
auto* system_server_process = Process::create_user_process("/bin/SystemServer", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0);
169-
if (error != 0) {
170-
kprintf("init_stage2: error spawning SystemServer: %d\n", error);
171-
hang();
168+
if (textmode) {
169+
tty0->set_graphical(false);
170+
auto* shell_process = Process::create_user_process("/bin/Shell", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0);
171+
if (error != 0) {
172+
kprintf("init_stage2: error spawning Shell: %d\n", error);
173+
hang();
174+
}
175+
shell_process->set_priority(Process::HighPriority);
176+
} else {
177+
tty0->set_graphical(true);
178+
auto* system_server_process = Process::create_user_process("/bin/SystemServer", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0);
179+
if (error != 0) {
180+
kprintf("init_stage2: error spawning SystemServer: %d\n", error);
181+
hang();
182+
}
183+
system_server_process->set_priority(Process::HighPriority);
172184
}
173-
system_server_process->set_priority(Process::HighPriority);
174-
175185
Process::create_kernel_process("NetworkTask", NetworkTask_main);
176186

177187
current->process().sys$exit(0);
@@ -212,6 +222,8 @@ extern "C" [[noreturn]] void init()
212222
// must come after kmalloc_init because we use AK_MAKE_ETERNAL in KParams
213223
new KParams(String(reinterpret_cast<const char*>(multiboot_info_ptr->cmdline)));
214224

225+
bool textmode = !KParams::the().get("text_debug").is_null();
226+
215227
vfs = new VFS;
216228
dev_debuglog = new DebugLogDevice;
217229

@@ -257,14 +269,18 @@ extern "C" [[noreturn]] void init()
257269
id.device_id);
258270
});
259271

260-
if (multiboot_info_ptr->framebuffer_type == 1) {
261-
new MBVGADevice(
262-
PhysicalAddress((u32)(multiboot_info_ptr->framebuffer_addr)),
263-
multiboot_info_ptr->framebuffer_pitch,
264-
multiboot_info_ptr->framebuffer_width,
265-
multiboot_info_ptr->framebuffer_height);
272+
if (textmode) {
273+
dbgprintf("Text mode enabled\n");
266274
} else {
267-
new BXVGADevice;
275+
if (multiboot_info_ptr->framebuffer_type == 1 || multiboot_info_ptr->framebuffer_type == 2) {
276+
new MBVGADevice(
277+
PhysicalAddress((u32)(multiboot_info_ptr->framebuffer_addr)),
278+
multiboot_info_ptr->framebuffer_pitch,
279+
multiboot_info_ptr->framebuffer_width,
280+
multiboot_info_ptr->framebuffer_height);
281+
} else {
282+
new BXVGADevice;
283+
}
268284
}
269285

270286
LoopbackAdapter::the();

Kernel/run

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ elif [ "$1" = "qgrub" ]; then
5151
-device e1000,netdev=breh \
5252
-hda _disk_image \
5353
-soundhw pcspk
54+
elif [ "$1" = "qtext" ]; then
55+
$SERENITY_QEMU_BIN -s -m ${SERENITY_RAM_SIZE:-128} \
56+
$SERENITY_EXTRA_QEMU_ARGS \
57+
-d cpu_reset,guest_errors \
58+
-device VGA,vgamem_mb=64 \
59+
-debugcon stdio \
60+
-device e1000 \
61+
-kernel kernel \
62+
-append "${SERENITY_KERNEL_CMDLINE} text_debug" \
63+
-hda _disk_image \
64+
-soundhw pcspk \
65+
-soundhw sb16
5466
else
5567
# ./run: qemu with user networking
5668
$SERENITY_QEMU_BIN -s -m ${SERENITY_RAM_SIZE:-128} \

0 commit comments

Comments
 (0)