Expand description
82077AA-compatible floppy disk controller and 1.44 MiB drive model.
The s9vm stub firmware services INT 13h from the host, so a guest never
talks to the controller. A real firmware (SeaBIOS) implements INT 13h
in its own 16-bit code and drives the FDC directly: DOR reset, command and
parameter bytes through the FIFO, an IRQ 6 completion, and a DMA transfer
through channel 2. This module models that command-level interface.
§Modelled command set
Only the commands SeaBIOS issues are implemented: SPECIFY,
RECALIBRATE, SENSE INTERRUPT, SEEK, READ ID, READ DATA, WRITE DATA and FORMAT TRACK (accepted, but formatting a read-only test image
does not mutate it). Unknown commands complete immediately with the invalid
opcode status 0x80, so a probe cannot hang.
§DMA
The controller does not touch memory. FloppyController::write returns an
FdcEvent; a transfer event names the starting LBA and sector count, and
the caller performs the channel-2 DMA through its own physical-memory view.
The controller already queued the seven result bytes and raised its IRQ
flag, so the completion is visible to the guest as soon as the transfer is
done.
§Geometry
The image is a standard 80 x 2 x 18 x 512 floppy: 1 474 560 bytes and 2 880 sectors. A CHS access outside that geometry returns a “sector not found” result instead of wrapping.
Re-exports§
Structs§
- FdcTransfer
- A DMA transfer requested by a completed read or write command.
- Floppy
Controller - State of the modelled controller and drive.
Enums§
- FdcEvent
- Outcome of a port write.
Constants§
- BASE_
PORT - Base of the floppy controller register window.
- CMD_
FORMAT_ TRACK FORMAT TRACK: 5 parameter bytes.- CMD_
READ_ DATA READ DATA: 8 parameter bytes.- CMD_
READ_ ID READ ID: 1 parameter, 7 result bytes.- CMD_
RECALIBRATE RECALIBRATE: 1 parameter byte.- CMD_
SEEK SEEK: 2 parameter bytes.- CMD_
SENSE_ INTERRUPT SENSE INTERRUPT STATUS: no parameter, 2 result bytes.- CMD_
SPECIFY SPECIFY: 2 parameter bytes.- CMD_
WRITE_ DATA WRITE DATA: 8 parameter bytes.- CYLINDERS
- Floppy geometry: cylinders.
- DATA_
PORT - FIFO data register (command, parameters and results).
- DIR_
PORT - Configuration control register / digital input register.
- DOR_
IRQ_ DMA - DOR bit 3: DMA and interrupt enable.
- DOR_
PORT - Digital output register (motor, DMA/IRQ enable, reset, drive select).
- DOR_
RESET - DOR bit 2: controller reset (0 = held in reset).
- HEADS
- Floppy geometry: heads.
- IRQ_
LINE - ISA interrupt line of the controller.
- MSR_DIO
- Main status register: data direction (1 = controller to host).
- MSR_
PORT - Main status register (read-only).
- MSR_RQM
- Main status register: ready for a byte.
- SECTORS_
PER_ TRACK - Floppy geometry: sectors per track.
- SECTOR_
SIZE - Size of one floppy sector.
- SIZE_
CODE_ 512 - Data-transfer size code for 512-byte sectors.
- TOTAL_
SECTORS - Total sectors of a 1.44 MiB image.
Functions§
- blank_
image - Builds a deterministic, zero-filled 1.44 MiB floppy image.
- handles_
port - True if
portbelongs to the controller window. - parameter_
count - Number of parameter bytes that follow
command.