VxWorks Reference Manual : Libraries
ataDrv - ATA/IDE (LOCAL and PCMCIA) disk device driver
ataDrv( ) - initialize the ATA driver
ataDevCreate( ) - create a device for a ATA/IDE disk
ataRawio( ) - do raw I/O access
This is a driver for ATA/IDE devices on PCMCIA, ISA, and other buses. The driver can be customized via various macros to run on a variety of boards and both big-endian, and little endian CPUs.
Most of the routines in this driver are accessible only through the I/O system. However, two routines must be called directly: ataDrv( ) to initialize the driver and ataDevCreate( ) to create devices.
Before the driver can be used, it must be initialized by calling ataDrv( ). This routine must be called exactly once, before any reads, writes, or calls to ataDevCreate( ). Normally, it is called from usrRoot( ) in usrConfig.c.
The routine ataRawio( ) supports physical I/O access. The first argument is a drive number, 0 or 1; the second argument is a pointer to an ATA_RAW structure.
Format is not supported, because ATA/IDE disks are already formatted, and bad sectors are mapped.
The ataDrv( ) function requires a configuration flag as a parameter. The configuration flag is one of the following:
DMA transfer is not supported in this release. If ATA_PIO_AUTO or ATA_DMA_AUTO is specified, the driver automatically chooses the maximum mode supported by the device. If ATA_PIO_MULTI or ATA_DMA_MULTI is specified, and the device does not support it, the driver automatically chooses single sector or word mode. If ATA_BITS_32 is specified, the driver uses 32-bit transfer mode regardless of the capability of the drive.
Transfer mode ATA_PIO_DEF_0 PIO default mode ATA_PIO_DEF_1 PIO default mode, no IORDY ATA_PIO_0 PIO mode 0 ATA_PIO_1 PIO mode 1 ATA_PIO_2 PIO mode 2 ATA_PIO_3 PIO mode 3 ATA_PIO_4 PIO mode 4 ATA_PIO_AUTO PIO max supported mode ATA_DMA_0 DMA mode 0 ATA_DMA_1 DMA mode 1 ATA_DMA_2 DMA mode 2 ATA_DMA_AUTO DMA max supported mode Transfer bits ATA_BITS_16 RW bits size, 16 bits ATA_BITS_32 RW bits size, 32 bits Transfer unit ATA_PIO_SINGLE RW PIO single sector ATA_PIO_MULTI RW PIO multi sector ATA_DMA_SINGLE RW DMA single word ATA_DMA_MULTI RW DMA multi word Geometry parameters ATA_GEO_FORCE set geometry in the table ATA_GEO_PHYSICAL set physical geometry ATA_GEO_CURRENT set current geometry If ATA_GEO_PHYSICAL is specified, the driver uses the physical geometry parameters stored in the drive. If ATA_GEO_CURRENT is specified, the driver uses current geometry parameters initialized by BIOS. If ATA_GEO_FORCE is specified, the driver uses geometry parameters stored in sysLib.c.
The geometry parameters are stored in the structure table ataTypes[] in sysLib.c. That table has two entries, the first for drive 0, the second for drive 1. The members of the structure are:
int cylinders; /* number of cylinders */ int heads; /* number of heads */ int sectors; /* number of sectors per track */ int bytes; /* number of bytes per sector */ int precomp; /* precompensation cylinder */This driver does not access the PCI-chip-set IDE interface, but rather takes advantage of BIOS or VxWorks initialization. Thus, the BIOS setting should match the modes specified by the configuration flag.The BSP may provide a sysAtaInit( ) routine for situations where an ATA controller RESET (0x1f6 or 0x3f6, bit 2 is set) clears ATA specific functionality in a chipset that is not re-enabled per the ATA-2 spec.
This BSP routine should be declared in sysLib.c or sysAta.c as follows:
void sysAtaInit (BOOL ctrl) { /* BSP SPECIFIC CODE HERE */ }Then the BSP should perform the following operation before ataDrv( ) is called, in sysHwInit for example:
IMPORT VOIDFUNCPTR _func_sysAtaInit; /* setup during initialization */ _func_sysAtaInit = (VOIDFUNCPTR) sysAtaInit;It should contain chipset specific reset code, such as code which re-enables PCI write posting for an integrated PCI-IDE device, for example. This will be executed during every ataDrv( ), ataInit( ), and ataReset( ) or equivalent block device routine. If the sysAtaInit routine is not provided by the BSP it is ignored by the driver, therefore it is not a required BSP routine.
ataDrv, VxWorks Programmer's Guide: I/O System
ataDrv( ) - initialize the ATA driver
STATUS ataDrv ( int ctrl, /* controller no. */ int drives, /* number of drives */ int vector, /* interrupt vector */ int level, /* interrupt level */ BOOL configType, /* configuration type */ int semTimeout, /* timeout seconds for sync semaphore */ int wdgTimeout /* timeout seconds for watch dog */ )
This routine initializes the ATA/IDE driver, sets up interrupt vectors, and performs hardware initialization of the ATA/IDE chip.
This routine must be called exactly once, before any reads, writes, or calls to ataDevCreate( ). Normally, it is called by usrRoot( ) in usrConfig.c.
OK, or ERROR if initialization fails.
ataDrv, ataDevCreate( )
ataDevCreate( ) - create a device for a ATA/IDE disk
BLK_DEV *ataDevCreate ( int ctrl, int drive, int nBlocks, int blkOffset )
This routine creates a device for a specified ATA/IDE disk.
drive is a drive number for the hard drive; it must be 0 or 1.
The nBlocks parameter specifies the size of the device in blocks. If nBlocks is zero, the whole disk is used.
The blkOffset parameter specifies an offset, in blocks, from the start of the device to be used when writing or reading the hard disk. This offset is added to the block numbers passed by the file system during disk accesses. (VxWorks file systems always use block numbers beginning at zero for the start of a device.)
A pointer to a block device structure (BLK_DEV) or NULL if memory cannot be allocated for the device structure.
ataDrv, dosFsMkfs( ), dosFsDevInit( ), rt11FsDevInit( ), rt11FsMkfs( ), rawFsDevInit( )
ataRawio( ) - do raw I/O access
STATUS ataRawio ( int ctrl, int drive, ATA_RAW * pAtaRaw )
This routine is called to perform raw I/O access.
drive is a drive number for the hard drive: it must be 0 or 1.
The pAtaRaw is a pointer to the structure ATA_RAW which is defined in ataDrv.h.
OK, or ERROR if the parameters are not valid.