Skip to content

Commit c4ced8f

Browse files
committed
wip: get debug terminal working
1 parent 7902d7f commit c4ced8f

4 files changed

Lines changed: 254 additions & 184 deletions

File tree

goldboot/flake.nix

Lines changed: 71 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
#!/bin/busybox sh
7878
7979
set -e
80-
set -x
8180
8281
# Create busybox symlinks (but don't overwrite kmod's modprobe/insmod)
8382
/bin/busybox --install -s /bin
@@ -94,38 +93,89 @@
9493
mkdir -p /dev/shm
9594
mount -t tmpfs tmpfs /dev/shm
9695
96+
# Mount /dev/pts for pseudo-terminals (required by debug shell)
97+
mkdir -p /dev/pts
98+
mount -t devpts devpts /dev/pts
99+
97100
# Redirect all output to a log
98101
exec >/init.log 2>&1
102+
set -x
99103
100104
# Create necessary directories
101-
mkdir -p /tmp /run /var
105+
mkdir -p /tmp /run /var /etc
102106
107+
# Create minimal passwd for PTY allocation
108+
echo "root:x:0:0:root:/:/bin/sh" > /etc/passwd
109+
110+
# Load all kernel modules upfront
103111
modprobe virtio_pci
104112
modprobe virtio_blk
113+
modprobe virtio_gpu
114+
modprobe virtio_input
115+
# Storage drivers
116+
modprobe ahci || true
117+
modprobe sd_mod || true
118+
modprobe nvme || true
119+
modprobe usb_storage || true
120+
# Filesystems
105121
modprobe nls_cp437
106122
modprobe nls_iso8859_1
107123
modprobe vfat
108-
mkdir -p /var/lib/goldboot/images
124+
modprobe ext4
125+
modprobe btrfs || true
126+
modprobe xfs || true
127+
modprobe ntfs3 || true
128+
modprobe iso9660 || true
129+
# USB host controllers
130+
modprobe xhci_pci
131+
modprobe ehci_pci
132+
# USB HID
133+
modprobe hid
134+
modprobe usbhid
135+
modprobe hid_generic
136+
# PS/2 keyboard (most laptop integrated keyboards)
137+
modprobe i8042 || true
138+
modprobe atkbd || true
139+
# I2C HID (newer laptops)
140+
modprobe i2c_hid || true
141+
modprobe i2c_hid_acpi || true
142+
# Input event interface
143+
modprobe evdev
144+
# Graphics
145+
modprobe drm
146+
modprobe drm_kms_helper
147+
# Networking
148+
modprobe r8169 || true
149+
150+
# Set up udev directories
151+
mkdir -p /run/udev
152+
153+
# Compile the udev hardware database (required for input device detection)
154+
udevadm hwdb --update
155+
156+
# Start udev daemon
157+
udevd --daemon
158+
159+
# Trigger udev to process devices and wait for them to settle
160+
udevadm trigger --action=add
161+
sleep 2
162+
udevadm settle --timeout=30
109163
110164
# Mount goldboot images to /var/lib/goldboot/images
165+
mkdir -p /var/lib/goldboot/images
166+
ls /dev
111167
for dev in /dev/sd?* /dev/vd?* /dev/hd?* /dev/nvme*; do
112168
[ -e "$dev" ] || continue
113-
TMP_MNT=$(mktemp -d)
114-
if mount -o ro "$dev" "$TMP_MNT" 2>/dev/null; then
169+
if mount -o ro "$dev" /var/lib/goldboot/images; then
115170
# Check for .gb files at root
116-
if ls "$TMP_MNT"/*.gb >/dev/null 2>&1; then
117-
umount "$TMP_MNT"
118-
rmdir "$TMP_MNT"
119-
mount -o ro "$dev" /var/lib/goldboot/images
171+
if ls /var/lib/goldboot/images/*.gb; then
120172
break
121173
fi
122-
umount "$TMP_MNT"
174+
umount /var/lib/goldboot/images
123175
fi
124-
rmdir "$TMP_MNT"
125176
done
126177
127178
# Set up networking
128-
modprobe r8169
129179
ip link set lo up
130180
# Find the first ethernet interface (not lo)
131181
for iface in /sys/class/net/*; do
@@ -136,31 +186,6 @@
136186
break
137187
done
138188
139-
# Set up udev directories
140-
# /etc/udev/rules.d is a symlink from the initramfs, don't overwrite it
141-
mkdir -p /run/udev
142-
143-
# Compile the udev hardware database (required for input device detection)
144-
# This creates /etc/udev/hwdb.bin from the hwdb.d directories
145-
udevadm hwdb --update
146-
147-
# Start udev daemon BEFORE loading modules so it can create device nodes
148-
udevd --daemon
149-
150-
# Load GPU and input kernel modules
151-
modprobe virtio_pci
152-
modprobe virtio_gpu
153-
modprobe virtio_input
154-
modprobe xhci_pci
155-
modprobe ehci_pci
156-
modprobe usbhid
157-
modprobe hid_generic
158-
modprobe evdev
159-
160-
# Trigger udev to process existing devices and wait for them
161-
udevadm trigger --action=add
162-
udevadm settle --timeout=10
163-
164189
export XDG_RUNTIME_DIR=/tmp/xdg-runtime
165190
mkdir -p "$XDG_RUNTIME_DIR"
166191
chmod 0700 "$XDG_RUNTIME_DIR"
@@ -218,10 +243,18 @@
218243
"virtio_input"
219244
"drm"
220245
"drm_kms_helper"
246+
# USB HID
221247
"usbhid"
222248
"hid_generic"
223249
"ehci_pci"
224250
"xhci_pci"
251+
# PS/2 keyboard (most laptop integrated keyboards)
252+
"atkbd"
253+
"i8042"
254+
# I2C HID (newer laptops, ultrabooks)
255+
"i2c_hid"
256+
"i2c_hid_acpi"
257+
"hid"
225258
"r8169"
226259
"virtio_blk"
227260
"vfat"
@@ -401,7 +434,7 @@
401434
--os-release='NAME="Goldboot"
402435
ID=goldboot
403436
VERSION="0.1.0"' \
404-
--cmdline="console=ttyS0 console=tty0" \
437+
--cmdline="quiet loglevel=0 rd.systemd.show_status=false rd.udev.log_level=0 vt.global_cursor_default=0" \
405438
--output=$out/goldboot.efi
406439
407440
echo "UKI created at $out/goldboot.efi"

goldboot/src/gui/app.rs

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,21 @@ impl GuiApp {
3131
}
3232

3333
impl eframe::App for GuiApp {
34-
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
35-
// Hide the mouse cursor (keyboard-only UI)
36-
ctx.set_cursor_icon(egui::CursorIcon::None);
34+
fn raw_input_hook(&mut self, _ctx: &egui::Context, raw_input: &mut egui::RawInput) {
35+
// When debug shell is active, inject a synthetic pointer position so
36+
// egui_term's contains_pointer() check passes. Otherwise filter all
37+
// pointer events for keyboard-only UI.
38+
#[cfg(feature = "uki")]
39+
let debug_shell_active = self.state.debug_shell.is_some();
40+
#[cfg(not(feature = "uki"))]
41+
let debug_shell_active = false;
3742

38-
// Disable all pointer/mouse input
39-
ctx.input_mut(|i| {
40-
i.pointer = Default::default();
41-
i.events.retain(|e| {
43+
if debug_shell_active {
44+
if let Some(screen_rect) = raw_input.screen_rect {
45+
raw_input.events.push(egui::Event::PointerMoved(screen_rect.center()));
46+
}
47+
} else {
48+
raw_input.events.retain(|e| {
4249
!matches!(
4350
e,
4451
egui::Event::PointerMoved(_)
@@ -48,17 +55,18 @@ impl eframe::App for GuiApp {
4855
| egui::Event::MouseMoved(_)
4956
)
5057
});
51-
});
58+
}
59+
}
5260

53-
// Render grid background
54-
self.theme.render_background(ctx);
61+
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
62+
ctx.set_cursor_icon(egui::CursorIcon::None);
5563

56-
// Handle global hotkeys
64+
self.theme.render_background(ctx);
5765
self.handle_hotkeys(ctx);
5866

5967
// Main panel
6068
egui::CentralPanel::default()
61-
.frame(egui::Frame::none())
69+
.frame(egui::Frame::NONE)
6270
.show(ctx, |ui| {
6371
self.screen
6472
.render(ui, &mut self.state, &self.textures, &self.theme);
@@ -72,11 +80,27 @@ impl eframe::App for GuiApp {
7280
impl GuiApp {
7381
fn handle_hotkeys(&mut self, ctx: &egui::Context) {
7482
ctx.input(|i| {
75-
// Esc - Quit application (only on SelectImage; other screens handle Esc themselves)
83+
// Esc - Quit/Reboot (only on SelectImage, not if any dialog is open)
84+
#[cfg(feature = "uki")]
85+
let debug_shell_active = self.state.debug_shell.is_some();
86+
#[cfg(not(feature = "uki"))]
87+
let debug_shell_active = false;
88+
7689
if i.key_pressed(egui::Key::Escape)
7790
&& !self.state.show_registry_dialog
91+
&& !debug_shell_active
92+
&& self.state.error_message.is_none()
7893
&& self.screen == Screen::SelectImage
7994
{
95+
#[cfg(feature = "uki")]
96+
{
97+
// In UKI mode, we're PID 1 so we need to use reboot syscall
98+
unsafe {
99+
libc::sync();
100+
libc::reboot(libc::RB_AUTOBOOT);
101+
}
102+
}
103+
#[cfg(not(feature = "uki"))]
80104
std::process::exit(0);
81105
}
82106

0 commit comments

Comments
 (0)