The Big Picture: From "Read This" to Electrical Signals

Section 1 showed the whole stack. Now we zoom into the bottom three layers: the ones that finally talk to the real hardware. These are all drivers: programs that run in kernel mode and know how to control a device. (Drivers and IRPs are explained in Chapter 13.)

The bottom of the stack has a clever design: one standard top, one standard middle, and a small custom bottom.

┌───────────────────────────────────────────────┐
│ Disk class driver   disk.sys                  │  same for every disk
├───────────────────────────────────────────────┤
│ Storage port driver storport.sys              │  same for most controllers
├───────────────────────────────────────────────┤
│ Miniport driver     stornvme.sys / storahci.sys│  one per controller type
╞═══════════════════════════════════════════════╡
│ Hardware: NVMe SSD, SATA drive, USB bridge ...│
└───────────────────────────────────────────────┘

Why this design? Microsoft writes the hard, shared parts once (the queues, the timers, the error handling). A hardware maker, or Microsoft for common controllers, only writes a small miniport for the details of one chip. That makes drivers shorter and safer.

6.1 The Disk Class Driver (disk.sys)

What it is: A class driver handles everything that is the same for a whole class of devices. disk.sys is the class driver for disks. It does not care whether the disk is a spinning hard drive, a SATA SSD, an NVMe SSD, or a USB drive. To it, every disk is a long row of numbered blocks.

What it does:

JobExplanation
Turns file requests into disk commandsTakes an IRP such as "read 8 blocks from block 1,008,000" and builds a standard SCSI-style command. (SCSI is an old, very widely used command language for storage; Windows uses its shape even for disks that are not SCSI.)
Learns the disk's size and sector sizeAt startup it asks the device "how many blocks, and how big is each?"
Creates the \Device\Harddisk0\DR0 style namesThese are internal names; Windows shows them as Disk 0, Disk 1...
Passes up partitionsWorks with the partition manager (partmgr.sys) from Section 1 so each partition becomes a volume
Handles flush and cache commands"Write this out for real now" requests, used when a program says it must be saved safely
Shows health and size to toolsThe values Get-Disk and Disk Management show start here

Does one disk.sys serve every disk? One driver, many instances: Windows creates one device object per disk, all run by the same driver code.

6.2 Port and Miniport Drivers (storport)

What it is: The port driver (storport.sys) is the "shared engine" below the class driver. A miniport driver plugs into it and knows one hardware family.

Storport's jobs (common to all controllers):

JobPlain meaning
QueuesHolds many requests waiting for the controller, not just one at a time
TimeoutsStarts a timer for every request. If the disk never answers, storport tries to recover
ResetsIf a device is stuck, it can reset the device, or the whole controller bus, then retry
PowerHelps spin down or wake devices, with the power system from Chapter 4
Hot plugNotices a disk arriving or leaving and tells Plug and Play
Interrupts and DMASets up the memory areas the device uses and handles the finishing "I'm done" interrupt

The miniports you will meet:

MiniportControllerWhere you find it
storahci.sysAHCI (Advanced Host Controller Interface), the standard way an OS talks to SATA portsSATA SSDs and hard drives; shown as "Standard SATA AHCI Controller" in Device Manager
stornvme.sysNVMe (Non-Volatile Memory Express), the standard for SSDs connected straight to PCIeM.2 and PCIe SSDs; shown as "Standard NVM Express Controller"
usbstor.sys and UASP driversUSB storagePen drives, USB hard drives (these use a different route to reach the disk class driver)
Vendor miniportsRAID or special controllers (for example Intel RST)If Intel RST or a RAID card is in use

(usbstor.sys is not a storport miniport in the strict sense, but it fills the same "talk to the hardware" role for USB.)

Windows tip: Open Device Manager → Storage controllers and Disk drives. You will see "Standard NVM Express Controller" under controllers, and your SSD's brand name under Disk drives. Right-click one, choose Properties → Driver → Driver Details to see the real driver file names.

6.3 Talking to AHCI and NVMe Controllers

Both are controllers: small chips (or parts of a chip) that sit between the CPU and the storage device. The miniport does not move wires; it writes numbers into the controller's registers and into queues in RAM.

AHCI (SATA):

  • A device-side chip called the HBA (Host Bus Adapter) sits in the chipset (the PCH from Chapter 4).
  • It supports one command queue per port with up to 32 commands waiting (called NCQ, Native Command Queuing).
  • This design was made when hard drives were slow, and it becomes a bottleneck for very fast SSDs.

NVMe (PCIe SSD):

  • Built for flash memory and the PCIe bus.
  • It supports up to 65,535 queues, each up to 65,536 commands deep (the maximum the specification allows; real SSDs use far fewer). Typically Windows uses one pair of queues per CPU core, so cores do not fight for a lock.
  • Each queue pair has a submission queue (requests going to the SSD) and a completion queue (answers coming back).
AHCI (SATA)NVMe (PCIe)
Queues1Up to 65,535
Commands per queue32Up to 65,536
LinkSATA cable, about 600 MB/s at bestPCIe lanes, several GB/s
Interrupt styleUsually oneMSI-X, one per queue
Miniportstorahci.sysstornvme.sys

What happens for one command (NVMe style):

1. Miniport writes the command into a submission queue in RAM
2. Miniport "rings the doorbell": writes the new queue position into
   a register on the SSD (MMIO, from Chapter 4)
3. The SSD fetches the command from RAM by itself (DMA)
4. The SSD reads the flash and writes the data into the buffer in RAM (DMA)
5. The SSD writes a "done" note into the completion queue
6. The SSD sends an interrupt (MSI-X) to the CPU core that asked
7. The driver's interrupt handler marks the request complete;
   the IRP travels back up

This is the DMA and interrupt story from Chapter 4 in action. The CPU does not copy a single byte of the file: it only sends the order and receives the "done" tap.

Here is a real NVMe SSD, the kind of hardware these drivers talk to:

Samsung 980 PRO NVMe SSD in M.2 form with its label on top

Figure 20.4 — A Samsung 980 PRO NVMe SSD (M.2 stick). stornvme.sys talks to the controller chip on this board over PCIe, using queues in RAM and DMA. Photo: D-Kuru, CC BY-SA 4.0, via Wikimedia Commons.

(More about the SSD itself is in Chapter 18.)

6.4 When Things Go Wrong: Resets and Timeouts

Drivers are also the place where hardware trouble shows up.

SymptomWhat probably happened
Whole PC freezes for seconds, then continuesA request timed out and storport reset the device
Event Viewer shows disk event "The device, \Device\Harddisk1\DR1, did not respond within the timeout period"Disk or cable not answering; try another cable or port
Event Viewer shows "reset to device, \Device\RaidPort0, was issued"Storport reset the controller (a "RaidPort" is the name storport uses for its ports)
Disk disappears and returnsHot-unplug or power glitch noticed by Plug and Play
Blue screen mentioning storport.sysA miniport or filter driver misbehaved; update the vendor driver

Tip: Press Win + X, choose Event Viewer, then open Windows Logs → System and filter by source disk, storahci or stornvme. Repeated entries are an early warning that a drive or cable is failing. Back up first.

Summary

TermPlain meaning
Class driver (disk.sys)Treats every disk as numbered blocks; builds standard commands
Port driver (storport.sys)Shared engine: queues, timeouts, resets, power
Miniport driverSmall driver for one controller type
storahci.sys / AHCISATA driver; 1 queue, 32 commands
stornvme.sys / NVMePCIe SSD driver; many queues, very deep
Submission / completion queueOrders going in / answers coming out
DoorbellRegister write that says "new work is waiting"
DMA + MSI-XDevice moves data itself, then interrupts the right core