Commit 4d4328f
debug(bios): instrument kmain + disk; isolates hang to trampoline
M1-16 progress — the BIOS boot chain is now diagnosed all the way
to the real culprit.
Observed serial output (`qemu-system-x86_64 -serial file:…`):
ZAMAK Stage 1
DL=80
Loading Stage 2...
ZPMD[]!01
Decoding the checkpoints (each byte is one `outb 0x3F8`):
Z = zamak-bios real-mode entry reached
P = 16→32-bit protected-mode switch succeeded
M = kmain entered
D = Disk::new returned
[ = call_bios_int dispatched
] = call_bios_int returned
! = BIOS signaled non-zero AH
01 = hex(AH) = 0x01 ("invalid function")
Same `INT 13h AH=0x42` (Extended Read) succeeds when issued from
stage1 directly in real mode, so the 32→real→32 trampoline in
`zamak-bios/src/entry.rs::call_bios_int` is leaving BIOS state
corrupted (IVT/A20/PIC/GDT/segment-descriptor-cache restore is
likely the culprit). Debugging the ~40-instruction trampoline is
non-trivial; see TODO.md for the two proposed paths forward.
Changes in this commit:
- `zamak-bios/src/main.rs`: added `mark(b: u8)` helper that
`outb`s a single byte to COM1 — a lightweight breadcrumb that
works in both real and protected mode without allocator or
panic-path involvement. Sprinkled markers through `kmain`:
entry (`M`), post-`Disk::new` (`D`), post-MBR-read (`m`),
post-partition-scan (`P`), pre-FS-probe (`F`), post-mount
(`f`), post-config-parse (`C`).
- `zamak-bios/src/main.rs`: kmain now reads sector 0, parses the
MBR partition table (types 0x01/04/06/0B/0C/83), and passes
the partition's starting LBA to `Fat32::parse` / `Ext2::mount`
instead of hard-coding LBA 0. The disk image built by
`build-images.sh` puts the FAT32 partition at LBA 4096 behind
the sfdisk-written partition entry, so this fixes "wrong LBA"
as a confounding variable.
- `zamak-bios/src/disk.rs`: `read_sectors_internal` emits `[` /
`]` around the `call_bios_int`, `.` on success, `!` + two
hex digits on BIOS error. Only visible during manual M1-16
bring-up (the test harness doesn't consume them).
- `TODO.md`: M1-16 note updated with the current symptom and
the two paths forward (debug trampoline vs. do all BIOS I/O
before leaving real mode, Limine-style).
Not affected: UEFI boot-smoke + asm-verification stay `[PASS]`
locally; clippy + fmt + the full workspace build remain clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 653eacd commit 4d4328f
3 files changed
Lines changed: 80 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
| |||
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
107 | 119 | | |
108 | | - | |
| 120 | + | |
109 | 121 | | |
110 | 122 | | |
111 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
190 | 211 | | |
191 | 212 | | |
| 213 | + | |
| 214 | + | |
192 | 215 | | |
193 | 216 | | |
194 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
195 | 251 | | |
196 | | - | |
| 252 | + | |
197 | 253 | | |
198 | 254 | | |
199 | 255 | | |
| |||
202 | 258 | | |
203 | 259 | | |
204 | 260 | | |
205 | | - | |
206 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
207 | 264 | | |
208 | 265 | | |
209 | 266 | | |
210 | | - | |
| 267 | + | |
211 | 268 | | |
212 | 269 | | |
213 | 270 | | |
214 | 271 | | |
| 272 | + | |
215 | 273 | | |
216 | 274 | | |
217 | 275 | | |
| |||
229 | 287 | | |
230 | 288 | | |
231 | 289 | | |
| 290 | + | |
232 | 291 | | |
233 | 292 | | |
234 | 293 | | |
| |||
0 commit comments