MS-DOS 6.22 IDE Controller and ATA Command Interaction
MS-DOS 6.22 does not communicate with IDE hard drive controllers directly through native operating system device drivers; instead, it relies on an abstraction layer provided by the system ROM BIOS. When an application or the MS-DOS kernel initiates a disk read or write operation, the request travels from the file system through standard interrupt services down to the BIOS INT 13h interface. The BIOS then issues direct low-level ATA (Advanced Technology Attachment) commands to the IDE controller's hardware registers using Programmed Input/Output (PIO) mode. This article details the structural pipeline, register mapping, and execution cycle of how MS-DOS 6.22 facilitates disk operations on IDE storage devices.
The Storage Architecture Pipeline
The path from an MS-DOS command to physical media follows a strict hierarchy:
- Application/Command Level: A program or command
(such as
COPYorTYPE) requests file operations through DOS API interrupts (specificallyINT 21h). - DOS Kernel (
MSDOS.SYS/IO.SYS): The kernel translates high-level file system tasks into raw logical sector numbers based on the FAT16 file system layout. - ROM BIOS (
INT 13h): The DOS BIOS driver (IO.SYS) issues a software interruptINT 13hto the motherboard ROM BIOS, specifying parameters such as function code (AH=02h for Read, AH=03h for Write), drive number, sector count, and Cylinder-Head-Sector (CHS) geometry. - IDE/ATA Hardware Controller: The BIOS INT 13h
handler executes the low-level I/O instructions (
INandOUT) directed at the IDE controller's Task File registers to issue ATA commands.
IDE Controller Task File Registers
IBM PC-compatible architectures map the primary IDE controller to
specific x86 I/O port addresses (typically 0x1F0 through
0x1F7 for the primary channel, and 0x170
through 0x177 for the secondary channel).
The BIOS communicates with the drive controller through the following primary task file registers:
- 0x1F0 (Data Port): Transmits and receives raw 16-bit sector data.
- 0x1F1 (Error / Features): Reports read error details or sets command features.
- 0x1F2 (Sector Count): Defines the number of 512-byte sectors to process.
- 0x1F3 (Sector Number / LBA Low): Specifies the starting sector index (1-based under CHS).
- 0x1F4 (Cylinder Low / LBA Mid): Contains the lower 8 bits of the cylinder address.
- 0x1F5 (Cylinder High / LBA High): Contains the upper bits of the cylinder address.
- 0x1F6 (Drive / Head): Selects master/slave drive and the target drive head number.
- 0x1F7 (Command / Status): Accepts command bytes on write; exposes status flags (BSY, DRDY, DRQ, ERR) on read.
Execution of ATA Commands via Programmed Input/Output (PIO)
Because MS-DOS 6.22 systems typically operate without DMA (Direct Memory Access) bus mastering for hard disks, data transfers occur in 16-bit PIO mode driven by the CPU.
1. Sector Read Cycle (ATA Command 20h)
When MS-DOS 6.22 needs to read data:
- The BIOS polls the Status Register (
0x1F7) until the Busy (BSY) bit is cleared and the Drive Ready (DRDY) bit is set. - The target CHS values are written into ports
0x1F2through0x1F6. - The command byte
20h(Read Sectors with Retry) is written to the Command Register (0x1F7). - The controller asserts an interrupt (IRQ 14 for the primary channel) once the requested sector is loaded from the magnetic platter into the drive's onboard buffer.
- The BIOS verifies that the Data Request (
DRQ) bit in the Status Register is set. - The CPU reads 256 words (512 bytes) from the Data Port
(
0x1F0) using assembly instructions such asREP INSW(Repeat Input String Word), transferring the data directly into conventional or upper memory allocated by MS-DOS.
2. Sector Write Cycle (ATA Command 30h)
When writing data:
- The BIOS prepares the Task File registers with the destination CHS address and sector count.
- The command byte
30h(Write Sectors with Retry) is written to port0x1F7. - The BIOS polls until the
DRQbit is set, indicating the drive's internal buffer is ready to accept data. - The CPU transfers 512 bytes per sector to the Data Port
(
0x1F0) usingREP OUTSW. - The controller clears
DRQ, setsBSY, writes the buffer to the magnetic disk surface, and issues an IRQ 14 to signal that the write cycle has completed.
Geometry Translation and Hardware Limits
MS-DOS 6.22 relies on standard CHS addressing, which introduces the classical 504 MiB (528 MB) barrier when interfacing standard BIOS limits with ATA specifications:
- ATA Task File Limits: 16 bits for Cylinder (65,536), 4 bits for Head (16), 8 bits for Sector (255).
- BIOS INT 13h Limits: 10 bits for Cylinder (1,024), 8 bits for Head (256), 6 bits for Sector (63).
Because the BIOS INT 13h interface and the IDE task file share execution duties, the lowest common denominator constrained systems to 1,024 cylinders, 16 heads, and 63 sectors (\(1024 \times 16 \times 63 \times 512\text{ bytes} \approx 528\text{ MB}\)).
To support drives larger than 528 MB up to MS-DOS 6.22's maximum
practical partition ceiling (2 GB per FAT16 volume), motherboard BIOSes
implemented CHS-to-LBA (Logical Block Addressing) translation. In this
scenario, MS-DOS 6.22 still communicates with INT 13h using
translated CHS parameters, but the BIOS recalculates those parameters
and sets bit 6 of register 0x1F6 to signal LBA mode
directly to the ATA controller.
Exceptions: Direct ATA Access in MS-DOS
While typical file operations are mediated by the BIOS, certain
MS-DOS software bypasses INT 13h:
- ATAPI CD-ROM Drivers: Standard BIOS implementations
in the MS-DOS 6.22 era lacked CD-ROM support. Real-mode drivers loaded
in
CONFIG.SYS(such asOAKCDROM.SYS) directly control IDE ports and utilize ATA packet commands (commandA0h) to manage optical drives. - Disk Utilities: Low-level diagnostic,
drive-cloning, and disk-partitioning tools sometimes write directly to
ports
0x1F0–0x1F7to identify drive parameters (via ATA commandECh-IDENTIFY DRIVE) without relying on BIOS reporting.