Sample ATADISK Driver

In addition to the standard stream device driver functions, the ATADISK driver also exports a PC Card Plug and Play detection function, DetectATADisk. The detection function only reads the attribute space of the PC card; no other data is read, and no write operations are performed on the PC card. The function looks for disk device type 4 in the PC Card’s CISTPL_FUNCID tuple and for ATA device type 1 in the type 1 CISTPL_FUNCE tuple.

The presence of the \Drivers\PCMCIA\ATADisk\ key causes the Device Manager to call the driver’s DetectATADisk function when a PC Card is inserted and there is no driver associated with the card’s Plug and Play ID. The following example shows how this takes place.

HKEY_LOCAL_MACHINE
    [Drivers]
        [PCMCIA]
            [Detect]
                [50]
                    SZ: Dll = ATADisk.DLL
                    SZ: Entry = DetectATADisk

When DetectATADisk detects an ATA-compatible PC Card, it causes the Device Manager to load the driver listed in the \Drivers\PCMCIA\AtaDisk\ registry key. The following example shows how this done.

HKEY_LOCAL_MACHINE
    [Drivers]
        [PCMCIA]
            [ATADISK]
                SZ: Prefix = DSK
                SZ: Dll = AtaDisk.DLL
                SZ: IOCTL = (DWORD)4
                SZ: FSD = FATFS.DLL

The four values shown are required.

The following values within the ATADISK key are optional. If present, these values affect all devices that the ATADISK driver operates on. Some of the following values are supported so that the ATADISK driver can work with some older ATA disk devices.

Folder
“Storage Card” causes ATADISK to report a default volume name of “Storage Card” in response to a DISK_IOCTL_GETNAME DeviceIOControl. You can use a different name than “Storage Card”, if desired.
Cylinders
xxx causes the ATADISK driver to not rely on the number of cylinders reported by the ATA device in response to the ATA IDENTIFY command. The number specified by the Cylinders registry value is used instead.
Heads
hh causes the ATADISK driver to not rely on the number of heads reported by the ATA device in response to the ATA IDENTIFY command. The number specified by the Heads registry value is used instead.
Sectors
ss causes the ATADISK driver to not rely on the number of sectors per track reported by the ATA device in response to the ATA IDENTIFY command. The number specified by the Sectors registry value is used instead.
CHSMode
1 forces the ATADISK driver to use Cylinder/Head/Sector (CHS) addressing mode. If the CHSMode value is 0 or the value is not present, the ATADISK driver uses the addressing mode reported by the ATA device in response to the ATA IDENTIFY command. The ATADISK driver uses Logical Block Address (LBA) mode, when available.