diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-02 01:52:10 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-02 01:52:10 +0200 |
| commit | 045c9ddf71b62dff538cd3ae1963166ab5c145a0 (patch) | |
| tree | fd99757329f7b770f067aa5f0204c87068fea681 /rsdos/src | |
| parent | gop: rustfmt collapse in init_shadow warning band (diff) | |
| download | rs-dos-045c9ddf71b62dff538cd3ae1963166ab5c145a0.tar.gz rs-dos-045c9ddf71b62dff538cd3ae1963166ab5c145a0.zip | |
v0.5.5: visible boot progress + panic-on-screen for real hardware
Real hardware has no serial console: a pre-shell panic was a silent
blank screen (the panic handler only wrote to serial, then cli;hlt).
v0.5.4's shadow change made this window reachable — if the fb-aware
page allocation or the heap fallback failed on hardware, the kernel
halted before the shell banner with zero screen output.
- gop::boot_marker(): every boot stage now draws straight to the
framebuffer (row 0, white-on-black). The last marker visible before
a hang identifies where the kernel died.
- Panic handler: pre-shell panics now draw a white-on-red
'*** PANIC *** <msg> at file:line' band via gop::dump_lines.
- init_shadow(): heap fallback is panic-proof (try_reserve_exact +
resize instead of vec![0; words] which aborts on OOM); page-alloc
result defensively re-checked against the fb region; any failure
degrades to no-shadow mode with a visible warning band.
- Verified: full chain (rsboot -> kernel) boots with markers, shell
banner renders, all 5 test suites pass.
Diffstat (limited to 'rsdos/src')
| -rw-r--r-- | rsdos/src/main.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/rsdos/src/main.rs b/rsdos/src/main.rs index 3153930..b6393ee 100644 --- a/rsdos/src/main.rs +++ b/rsdos/src/main.rs | |||
| @@ -45,6 +45,31 @@ fn panic(info: &PanicInfo) -> ! { | |||
| 45 | loc.line() | 45 | loc.line() |
| 46 | ); | 46 | ); |
| 47 | } | 47 | } |
| 48 | // Real hardware has no serial console — put the panic on the screen | ||
| 49 | // too (white-on-red band), so a pre-shell panic is not a silent | ||
| 50 | // blank screen. | ||
| 51 | let mut loc_buf = [0u8; 96]; | ||
| 52 | let mut msg_buf = [0u8; 128]; | ||
| 53 | let loc_n = { | ||
| 54 | let mut w = rsnix::strbuf::FmtBuf::new(&mut loc_buf); | ||
| 55 | if let Some(loc) = info.location() { | ||
| 56 | let _ = write!(&mut w, "at {}:{}", loc.file(), loc.line()); | ||
| 57 | } else { | ||
| 58 | let _ = write!(&mut w, "(no location)"); | ||
| 59 | } | ||
| 60 | w.len() | ||
| 61 | }; | ||
| 62 | let msg_n = { | ||
| 63 | let mut w = rsnix::strbuf::FmtBuf::new(&mut msg_buf); | ||
| 64 | let _ = write!(&mut w, "{}", info.message()); | ||
| 65 | w.len() | ||
| 66 | }; | ||
| 67 | let lines = [ | ||
| 68 | "*** PANIC ***", | ||
| 69 | core::str::from_utf8(&msg_buf[..msg_n]).unwrap_or("?"), | ||
| 70 | core::str::from_utf8(&loc_buf[..loc_n]).unwrap_or("?"), | ||
| 71 | ]; | ||
| 72 | rsnix::gop::dump_lines(&lines); | ||
| 48 | loop { | 73 | loop { |
| 49 | unsafe { | 74 | unsafe { |
| 50 | core::arch::asm!("cli; hlt"); | 75 | core::arch::asm!("cli; hlt"); |
| @@ -121,9 +146,11 @@ pub unsafe extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut | |||
| 121 | } else { | 146 | } else { |
| 122 | rsnix::serial_println!("gop: not found (0x{:x})", gop_result); | 147 | rsnix::serial_println!("gop: not found (0x{:x})", gop_result); |
| 123 | } | 148 | } |
| 149 | rsnix::gop::boot_marker("rsnix v0.5.5 booting.."); | ||
| 124 | rsnix::vt::init(); | 150 | rsnix::vt::init(); |
| 125 | let (rows, cols) = rsnix::vt::size(); | 151 | let (rows, cols) = rsnix::vt::size(); |
| 126 | rsnix::serial_println!("vt: terminal ready ({}x{})", rows, cols); | 152 | rsnix::serial_println!("vt: terminal ready ({}x{})", rows, cols); |
| 153 | rsnix::gop::boot_marker("rsnix: gop+vt ok"); | ||
| 127 | 154 | ||
| 128 | // ExitBootServices — we now own the machine | 155 | // ExitBootServices — we now own the machine |
| 129 | if unsafe { (bs.exit_boot_services)(image_handle, map_key) } != EFI_SUCCESS { | 156 | if unsafe { (bs.exit_boot_services)(image_handle, map_key) } != EFI_SUCCESS { |
| @@ -158,6 +185,7 @@ pub unsafe extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut | |||
| 158 | } | 185 | } |
| 159 | rsnix::interrupts::init(); | 186 | rsnix::interrupts::init(); |
| 160 | rsnix::serial_println!("intr: IDT loaded, PIC remapped, timer ~100 Hz"); | 187 | rsnix::serial_println!("intr: IDT loaded, PIC remapped, timer ~100 Hz"); |
| 188 | rsnix::gop::boot_marker("rsnix: serial+ps2+gdt+intr ok"); | ||
| 161 | 189 | ||
| 162 | dump_memory_summary(); | 190 | dump_memory_summary(); |
| 163 | 191 | ||
| @@ -173,6 +201,7 @@ pub unsafe extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut | |||
| 173 | rsnix::serial_println!("pages: init FAILED"); | 201 | rsnix::serial_println!("pages: init FAILED"); |
| 174 | } | 202 | } |
| 175 | rsnix::gop::init_shadow(); | 203 | rsnix::gop::init_shadow(); |
| 204 | rsnix::gop::boot_marker("rsnix: shadow ok"); | ||
| 176 | if rsnix::memory::page_self_test() { | 205 | if rsnix::memory::page_self_test() { |
| 177 | rsnix::serial_println!("pages: self-test OK (alloc/free/runs)"); | 206 | rsnix::serial_println!("pages: self-test OK (alloc/free/runs)"); |
| 178 | } else { | 207 | } else { |
| @@ -228,6 +257,7 @@ pub unsafe extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut | |||
| 228 | } | 257 | } |
| 229 | 258 | ||
| 230 | rsnix::serial_println!("boot: entering shell"); | 259 | rsnix::serial_println!("boot: entering shell"); |
| 260 | rsnix::gop::boot_marker("rsnix: boot done — shell"); | ||
| 231 | if rsnix::ps2::mouse_present() { | 261 | if rsnix::ps2::mouse_present() { |
| 232 | rsnix::cursor::spawn(); | 262 | rsnix::cursor::spawn(); |
| 233 | } else { | 263 | } else { |
