diff options
Diffstat (limited to '')
| -rw-r--r-- | CONTEXT.md | 41 |
1 files changed, 37 insertions, 4 deletions
| @@ -97,10 +97,18 @@ Single Rust crate (`x86_64-unknown-uefi` target). Module breakdown: | |||
| 97 | - `paging.rs` — identity page-table helpers (map/unmap/query, large-page split) | 97 | - `paging.rs` — identity page-table helpers (map/unmap/query, large-page split) |
| 98 | - `power.rs` — `ResetSystem`-based shutdown, hlt loop fallback | 98 | - `power.rs` — `ResetSystem`-based shutdown, hlt loop fallback |
| 99 | - `rtc.rs` — CMOS/RTC clock (ports 0x70/0x71), BCD/12h normalization | 99 | - `rtc.rs` — CMOS/RTC clock (ports 0x70/0x71), BCD/12h normalization |
| 100 | - `pci.rs` — legacy PCI config space (0xCF8/0xCFC), full enumeration | 100 | - `pci.rs` — legacy PCI config space (0xCF8/0xCFC), full enumeration; `config_write` |
| 101 | - 64-bit BAR reader for the AHCI driver | ||
| 102 | - `ahci.rs` — SATA AHCI host driver (polling, DMA, no interrupts): scans PCI for | ||
| 103 | class 1/subclass 6/prog-if 1, maps ABAR, starts port 0 (FRE/ST/DMAE), runs | ||
| 104 | IDENTIFY + READ/WRITE DMA EXT through a 4 KiB DMA buffer | ||
| 105 | - `fat.rs` — FAT32: BPB parse, whole-FAT cache in RAM with write-back to both FAT | ||
| 106 | copies, cluster chains, directory scan with checksum-validated LFN | ||
| 107 | reassembly, LFN + 8.3 writing, FSInfo free-count maintenance, mkdir/rm/read/write | ||
| 101 | - `fs.rs` — VFS: dirs, ramfs files, char devices (`/dev/mem`, `rtc`, `pci`, | 108 | - `fs.rs` — VFS: dirs, ramfs files, char devices (`/dev/mem`, `rtc`, `pci`, |
| 102 | `version`, `meminfo`, `null`, `zero`, `console`, `serial`; `/tmp` ramfs; | 109 | `version`, `meminfo`, `null`, `zero`, `console`, `serial`; `/tmp` ramfs; |
| 103 | `/etc/motd`) | 110 | `/etc/motd`); `/disk` mount node + 24-slot ephemeral node pool so shell |
| 111 | commands work on disk paths unchanged | ||
| 104 | - `gop.rs` — framebuffer rasteriser (glyph blits, pixel shifts); the text | 112 | - `gop.rs` — framebuffer rasteriser (glyph blits, pixel shifts); the text |
| 105 | surface itself lives in `vt` | 113 | surface itself lives in `vt` |
| 106 | - `vt.rs` — terminal emulator: cell grid, cursor, ANSI CSI parser (H/J/K, | 114 | - `vt.rs` — terminal emulator: cell grid, cursor, ANSI CSI parser (H/J/K, |
| @@ -159,6 +167,23 @@ Single Rust crate (`x86_64-unknown-uefi` target). Module breakdown: | |||
| 159 | `tty` raw mode, stdout → `vt`, `std::fs` → VFS, SIGWINCH → fixed | 167 | `tty` raw mode, stdout → `vt`, `std::fs` → VFS, SIGWINCH → fixed |
| 160 | geometry. Verified in QEMU: edit/type/navigate/insert/save/exit, exact | 168 | geometry. Verified in QEMU: edit/type/navigate/insert/save/exit, exact |
| 161 | bytes via `cat`/`hexdump`, syntax colours via framebuffer dump. | 169 | bytes via `cat`/`hexdump`, syntax colours via framebuffer dump. |
| 170 | ✅ **AHCI + FAT32 (persistent disk)** — a SATA AHCI driver (polling DMA, | ||
| 171 | no interrupts) plus a FAT32 filesystem, mounted as `/disk`; every shell | ||
| 172 | command works on disk paths: `ls`/`cat`/`hexdump`/`echo >`/`>>`/ | ||
| 173 | `mkdir`/`touch`/`rm`/`edit`. Whole-FAT cache with write-back to both | ||
| 174 | FAT copies, checksum-validated LFN read/write, multi-cluster files, | ||
| 175 | space-padded `.`/`..` dot entries (`..` → cluster 0 under the root), | ||
| 176 | FSInfo free-count maintenance (fsck-clean after a session, verified | ||
| 177 | with `fsck.fat -n`). **Files survive reboot** — verified by | ||
| 178 | poweroff → `mdir`/`mtype` on the image and by a fresh boot seeing the | ||
| 179 | prior session's files. | ||
| 180 | |||
| 181 | QEMU setup: `-drive id=disk,if=none,format=raw,file=disk.img` + | ||
| 182 | `-device ide-hd,drive=disk,bus=ide.0` puts the data disk on AHCI port | ||
| 183 | 0; the ESP gets `bus=ide.1`. (The implicit `-drive file=fat:rw:esp` | ||
| 184 | otherwise grabs port 0.) Make targets (`run`, `run-gui`, `debug`) | ||
| 185 | attach `$(DISK_IMG)` (default `/tmp/disk.img`). OVMF writes its | ||
| 186 | `NvVars` varstore file onto the first FAT volume — harmless. | ||
| 162 | 187 | ||
| 163 | ## Known issues / perf notes | 188 | ## Known issues / perf notes |
| 164 | 189 | ||
| @@ -181,8 +206,16 @@ Single Rust crate (`x86_64-unknown-uefi` target). Module breakdown: | |||
| 181 | the whole framebuffer at all. | 206 | the whole framebuffer at all. |
| 182 | - **Editor redraw** re-blits changed cells per keystroke (fine at 1280×800); | 207 | - **Editor redraw** re-blits changed cells per keystroke (fine at 1280×800); |
| 183 | the "optimize drawing someday" item. | 208 | the "optimize drawing someday" item. |
| 184 | - **ramfs only**: edited files live in memory, lost on reboot until disk | 209 | - **AHCI quirks learned (QEMU ground truth)**: the command header layout is |
| 185 | support (AHCI/FAT32) lands. | 210 | FIS length in DW0 bits 4:0 and PRDTL in bits 31:16 (not the classic |
| 211 | CFL-at-24 bit-fields); the H2D FIS sector count lives at bytes 12-13 with | ||
| 212 | the device register at byte 7 (byte 10 is LBA[47:40] — no separate | ||
| 213 | device byte); QEMU rejects H2D FISes with flags bits 6:4 set, so the | ||
| 214 | write direction is signalled purely by the header W bit (1<<6). | ||
| 215 | Real hardware follows the same FIS layout; the header layout matches | ||
| 216 | Linux libahci. | ||
| 217 | - **ramfs only for `/`**: the root filesystem is still the ramfs (lost on | ||
| 218 | reboot); persistent files live under `/disk` (AHCI/FAT32). | ||
| 186 | 219 | ||
| 187 | ## Target audience | 220 | ## Target audience |
| 188 | 221 | ||
