Skip to main content

Module fdc

Module fdc 

Source
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§

use alloc::vec; 🔒
use alloc::vec; 🔒
use alloc::vec::Vec; 🔒

Structs§

FdcTransfer
A DMA transfer requested by a completed read or write command.
FloppyController
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 port belongs to the controller window.
parameter_count
Number of parameter bytes that follow command.