storage: NVMe, so a laptop's SSD is a disk SchOS can boot from

A native driver written from the NVMe 1.4 base specification. It resets
the controller the firmware left running, then sets up an admin queue and
one I/O queue pair. Completion is polled, with interrupts disabled at the
queue, for the same reason AHCI polls: without AML, interrupt routing on
real hardware cannot be trusted. Each active namespace with 512-byte to
4 KB sectors and no metadata is registered as nvme<C>n<N>, the name
Linux uses, and its GPT is read like any other disk's.

Tested under QEMU q35: disk.img on NVMe as the only disk boots through
OVMF, roots on nvme0n1p2, and writes read back after sync. A
4 KB-sector namespace registers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
Nexoniarz 2026-10-22 15:48:11 +02:00
commit efb6446f47
5 changed files with 484 additions and 8 deletions

View file

@ -454,8 +454,9 @@ what makes a loop over candidates legal at all.
The **registered** devices are the ones found at probe time rather than known
at build time, numbered from 4 (`include/blkdev.h`): a SATA disk behind AHCI
(`sata0`), the USB stick seen a second time (`usb0`), and every partition on
either (`sata0p2`, `usb0p2`). When a disk registers, its GPT is read, or its MBR
(`sata0`), an NVMe namespace (`nvme0n1`), each USB stick (`usb0`..`usb3`, the
first of them also seen as device 3), and every partition on any of them
(`sata0p2`, `nvme0n1p2`, `usb0p2`). When a disk registers, its GPT is read, or its MBR
if it has no GPT. Each partition then becomes a device whose block 0 is the
partition's first sector, so SchFS in a partition and SchFS on a whole disk are
the same bytes. The ESP is skipped because it is FAT.
@ -606,10 +607,10 @@ in the one process that runs first.
stall, which is the wrong order for finding out.
- **`/proc/bootmode` is read once, at start.** A program that wants to be
quieter or louder later has nowhere to say so, and nothing re-reads it.
- **One USB disk, found at boot.** The mass-storage driver drives the first
stick and no other, and a stick plugged in later is not seen. See
[usb.md](usb.md).
- **No NVMe yet.** SATA (AHCI) and IDE are the only fixed disks.
- **The root is chosen once, at boot.** A stick plugged in later is registered
with its partitions, but nothing mounts it. See [usb.md](usb.md).
- **NVMe and AHCI poll for completion**, one command at a time per disk. That
is enough to boot and run from them, not to be fast.
- **`make ramroot` is the only way to boot with no data disk.** It links a
filesystem image into the kernel binary, which costs boot time and carries a
licensing constraint — see [../licensing.md](../licensing.md) §4.

View file

@ -19,8 +19,11 @@ root is chosen at boot from what is present (`rootdev_mount()` in
`kernel/proc/proc.c`), and `make disk` builds a GPT image with an ESP and a SchFS
partition that a PC boots from a stick or a disk.
**Next: NVMe**, through the same block registry, and an installer that writes
that layout to a disk.
NVMe (`kernel/drivers/storage/nvme/`) registers with the same block registry,
so an NVMe SSD boots the same way.
**Next:** an installer that writes that layout to a disk, and interrupt-driven,
queued I/O for AHCI and NVMe.
## 2. Graphics