|
|
|
|
|
|
|
||
|
||
|
|
||
May 1999 |
Revision 1.02 |
|
Persistor Instruments Inc. |
© 1998 All rights reserved. |
|
The ATA collection of BIOS functions provide the lowest level I/O access to block oriented storage devices like disk drives and flash cards. The ATA tag comes from "AT Attachment" which refers to IDE interface (Integrated Disk Electronics) made universally popular by the IBM AT computer. The CF1's onboard CompactFlash works through these ATA drivers, as does the 2GB hard drive used in the Persistor GB2 and as will the full sized PCMCIA flash cards on one of the future RecipeCards.

Most CF1 users can safely skip this section and perform all of their disk/flash I/O operations using the standard C library which work through these drivers but provide a much simpler and more abstract programming interface. You will need to understand these driver level functions if you're coding something like the following:
typedef short (*ATADvr)(void *);
All of the functions in this group make use of an anonymous structure pointer of type ATADvr (declared in <cf1bios.h> ) to translate from generic ATA operations to actual device I/O. Each physical ATA device driver in turn must provide an accessor function that returns that devices ATADvr, similar to the "void *CFGetDriver(void)" call for the built-in CompactFlash card. Only developers that are actually adding new ATA devices need to know the hairy details of ATADvr mechanics and these can be obtained by contacting Persistor Instruments Inc.. Everybody else just needs to know that this first parameter to all of the ATA functions must contain a valid ATADvr pointer from at least one call to an XXGetDriver() function.
#define ATA_SECTOR_SIZE 512 // bytes per sector
All of the ATA block I/O functions operate on chunks of data that are an even multiple of 512 bytes and all of the functions that specify a buffer pointer parameter expect that variable to point to valid RAM memory to hold the results of the requested operation. Some ATA functions also specify a count parameter, and that in turn refers to the number of 512 byte sectors to be read or written.
All of the CF1 ATA functions work with LBA (Logical Block Addressing) sector numbers as opposed to head/cylinder/sector numbers used by some older ATA devices. The first sector is always zero and the last is the number of sectors minus one. Translation between the two numbering schemes is seldom, if ever, necessary and requires knowledge beyond the scope of this manual
For all of the ATA functions, actual timing varies (a lot) from device to device, and can be affected by the time between successive I/O calls as well as by the relative offsets between I/O sector requests. For ATA flash cards, multi-sector requests can be much faster (twice as fast writing, three or four times faster reading) than an equivalent number of individual sequential requests. If you need deterministic timing, you must setup test code to exercise and report with the specific media, and repeat these tests any time the media changes.
All of the ATA functions return zero to indicate success, or a nonzero value to indicate some type of failure. The exact interpretation of the failure code varies depending on the physical device, but for the CompactFlash, the bits in the lower byte identify one or more of the following errors, and the upper byte may contain extended error codes that are not documented here, but can be found in the card or disk manufacturers ATA technical manuals.
card busy
0x80
card not ready
0x40
data request failure
0x20
extended error request failed
0x10
no media present
0x04
operation failed to complete
0x0F
invalid arguments
0x03
This function returns the drive or media capacity as well as additional information about the number of heads and sectors per track for LBA translation. It also optionally returns card or drive information table which has both generic and manufacturer specific fields. Refer to the device/media manuals for exact interpretation.
|
Prototype: |
short ATACapacity(ATADvr iodvr, ulong *sectors, ushort *spt, ushort *heads, void **info); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
iodvr pointer to the physical device driver |
|
Returns: |
Returns-zero for success or ATA error bits |
|
Notes: |
pass zeros for everything except *sectors to just quickly determine capacity |
|
Timing: |
Timing - TBD |
This function performs low level formatting on one or more 512 byte sectors of the card or disk. This is seldom, if ever, necessary, and should only be used to repair damaged sectors or tracks. To pre-fill cards with know patterns, use the ATAWriteSectors() function. Hard disk drives may be permanently damaged by low level formatting under the wrong conditions. Contact Persistor Instruments Inc. for special instructions if you feel you must use this function.
|
Prototype: |
short ATAFormatSectors(ATADvr iodvr, ulong sector, void *buffer, short count); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
iodvr pointer to the physical device driver |
|
Returns: |
Returns-zero for success or ATA error bits |
|
Notes: |
Do not use this function unless you truly know what you're doing! |
|
Timing: |
Timing-device/media dependent |
This function reads one or more 512 byte sectors from the card or disk into a memory buffer.
|
Prototype: |
short ATAReadSectors(ATADvr iodvr, ulong sector, void *buffer, short count); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
iodvr pointer to the physical device driver |
|
Returns: |
Returns-zero for success or ATA error bits |
|
Notes: |
Use multi-sector reads for best performance |
|
Timing: |
Timing-device/media dependent |
This function returns media specific information about card usage. Refer to the device/media manuals for exact interpretation.
|
Prototype: |
short ATASectorInfo(ATADvr iodvr, ulong sector, void *buffer); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
iodvr pointer to the physical device driver |
|
Returns: |
Returns-zero for success or ATA error bits |
|
Notes: |
only works with certain CompactFlash and PCMCIA flash cards |
|
Timing: |
Timing-device/media dependent |
This function allows you to choose between maximum read/write performance and maximum power drain for some CompactFlash and PCMCIA flash cards. The reqPwr parameter specifies the maximum current the card should use in milliamps with a nominal 5 volt supply. Running at the CF1's 3.3 volts, the actual power usage will typically be about 30% lower than the parameter values.
The actual range of values typically varies from about 30mA to 100mA and these limits are returned in the high and low bytes of the maxMinPwr parameter. To operate at minimum current, simply set the reqPwr to 1. To operate at maximum performance, set the reqPwr to 255. At initialization, the BIOS sets any inserted CompactFlash card to run at minimum power.
|
Prototype: |
short ATASetPower(ATADvr iodvr, short reqPwr, ushort *maxMinPwr); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
iodvr pointer to the physical device driver |
|
Returns: |
Returns-zero for success or ATA error bits |
|
Notes: |
current values are about 30% lower for the 3.3 volt CF1 |
|
Timing: |
Timing - TBD |
This is a generic wrapper function that should provide access to device/media specific lower level ATA functions not included in the standard function set. Both the ATASectorInfo() and ATAFormatSectors() work through this function.
|
Prototype: |
short ATASpecial(ATADvr iodvr, ulong sector, void *buffer, short count, short cmd, short iswrite, short feature); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
iodvr pointer to the physical device driver |
|
Returns: |
Returns-zero for success or ATA error bits |
|
Notes: |
|
|
Timing: |
Timing-request/device/media dependent |
This function writes one or more 512 byte sectors from a memory buffer onto the card or disk.
|
Prototype: |
short ATAWriteSectors(ATADvr iodvr, ulong sector, void *buffer, short count); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
iodvr pointer to the physical device driver |
|
Returns: |
Returns-zero for success or ATA error bits |
|
Notes: |
Use multi-sector writes for best performance |
|
Timing: |
Timing-device/media dependent |
This function returns true if it can access a CompactFlash card.
|
Prototype: |
bool ATAMediaCheck(ATADvr iodvr); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
iodvr pointer to the physical device driver |
|
Returns: |
Returns true if a card is found |
|
Notes: |
|
|
Timing: |
tbd |
|
|
|
|
|
|
Tel: 508-759-6434 |
|
Fax: 508-759-6436 |
|
|
||