Menu

Disk Controller

Disk Controller


The Disk Controller class is an abstract class that aims to simplify access to disks, including access to USB Mass Storage devices.

The Disk Controller is extended by the following classes:

ATA


ATA PIO mode

The ATA PIO driver is probably the simplest driver to write, but it uses a huge amount of CPU resources, because all data is transferred over the CPU instead of being placed directly in memory.
It is, however, the best choice for the early environment, as the ATA-specification states that PIO mode must be supported by all ATA-compliant drives, so it is independent of it's actual type (PATA/SATA).

Their ports are standardized and are located at 0x1F0 through 0x1F7 (for the first ATA controller) and 0x170 through 0x177 (for the secondary ATA controller), if they are not found at these addresses, the only way to find them is by enumerating the [PCI] bus for class 0x01 subclass 0x01 (IDE), 0x05 (ATA) and 0x06 (SATA).

The eight ports are (partially) defined as follows:

Port Offset Function R/W Description
0 DATA R/W Read/Write data.
1 ERROR R Contains an error code if an error has occurred.
1 FEAT W Set Feature Flags used by the controller.
2 COUNT W Number of sectors to read/write.
3 LBA L W Lowest 8 bits of the LBA.
4 LBA M W Next 8 bits of the LBA.
5 LBA H W Next 8 bits of the LBA.
6 DRIVE W Used to select the drive (or'd with 0xE0)
7 CMD W Used to send a command.
7 STATUS R The current status.