📄 atadrvr.ug
字号:
Note that ATADRVR is not able to determine the type of some
devices. However, after issuing some commands the calling
program may be able to determine the exact type of a device.
The calling program may change the values in this array but
this must be done very carefully:
a) DO NOT CHANGE the value REG_CONFIG_TYPE_NONE.
b) DO NOT CHANGE a value to REG_CONFIG_TYPE_NONE.
c) The value REG_CONFIG_TYPE_UNKN can be changed to either
REG_CONFIG_TYPE_ATA or REG_CONFIG_TYPE_ATAPI.
int reg_atapi_cp_size;
unsigned char reg_atapi_cp_data[16];
These values are READONLY -- DO NOT ALTER.
reg_atapi_cp_size is the size of the most recent ATAPI command
packet size (normally 12 or 16). reg_atapi_cp_data[16] is the
most recent ATAPI command packet (SCSI CDB) data.
int reg_non_data( int dev, // device (0 or 1)
int cmd, // command register
int fr, // feature register
int sc, // sector count
unsigned int cyl, // CHS cylinder high/low
int head, // CHS head
int sect ); // CHS sector
Execute an ATA Non-Data command using CHS sector addressing.
Returns 0 if no error or 1 if there is an error. See the
contents of reg_cmd_info.
int reg_non_data_lba( int dev, // device (0 or 1)
int cmd, // command register
int fr, // feature register
int sc, // sector count
long lba ); // LBA
Execute an ATA Non-Data command using LBA sector addressing.
Returns 0 if no error or 1 if there is an error. See the
contents of reg_cmd_info.
int reg_packet( int dev, // device (0 or 1)
unsigned int cpbc, // command packet size
unsigned int cpseg, // command packet buffer
unsigned int cpoff, // command packet buffer
int dir, // 0 for no data or read, 1 for write
unsigned int dpbc, // max data packet size
unsigned int dpseg, // data packet buffer
unsigned int dpoff ); // data packet buffer
Execute an ATAPI Packet (A0H) command in PIO mode. Note that
the first byte of the Commmand Packet buffer is the command
code of the "SCSI CDB" that is to be executed by the device.
Returns 0 if no error or 1 if there is an error. See the
contents of reg_cmd_info.
int reg_pio_data_in( int dev, // device (0 or 1)
int cmd, // command register
int fr, // feature register
int sc, // sector count
unsigned int cyl, // CHS cylinder high/low
int head, // CHS head
int sect, // CHS sector
unsigned seg, // buffer address
unsigned off, // buffer address
int numSect, // number of sectors to transfer
int multiCnt ); // current multiple count
Execute an ATA PIO Data Out command in CHS sector addressing
mode.
numSect is the actual number of sectors to be transfered.
This value may be different than the sc value.
If cmd is C4H (Read Multiple) then multiCnt MUST be set to the
current sectors per block.
Returns 0 if no error or 1 if there is an error. See the
contents of reg_cmd_info.
int reg_pio_data_in_lba( int dev, // device (0 or 1)
int cmd, // command register
int fr, // feature register
int sc, // sector count
long lba, // LBA
unsigned seg, // buffer address
unsigned off, // buffer address
int numSect, // number of sectors to transfer
int multiCnt ); // current multiple count
Execute an ATA PIO Data Out command in LBA sector addressing
mode.
numSect is the actual number of sectors to be transfered.
This value may be different than the sc value.
If cmd is C4H (Read Multiple) then multiCnt MUST be set to the
current sectors per block.
Returns 0 if no error or 1 if there is an error. See the
contents of reg_cmd_info.
int reg_pio_data_out( int dev, // device (0 or 1)
int cmd, // command register
int fr, // feature register
int sc, // sector count
unsigned int cyl, // CHS cylinder high/low
int head, // CHS head
int sect, // CHS sector
unsigned seg, // buffer address
unsigned off, // buffer address
int numSect, // number of sectors to transfer
int multiCnt ); // current multiple count
Execute an ATA PIO Data Out command in CHS sector addressing
mode.
numSect is the actual number of sectors to be transfered.
This value may be different than the sc value.
If cmd is C5H (Write Multiple) then multiCnt MUST be set to
the current sectors per block.
Returns 0 if no error or 1 if there is an error. See the
contents of reg_cmd_info.
int reg_pio_data_out_lba( int dev, // device (0 or 1)
int cmd, // command register
int fr, // feature register
int sc, // sector count
long lba, // LBA
unsigned seg, // buffer address
unsigned off, // buffer address
int numSect, // number of sectors to transfer
int multiCnt ); // current multiple count
Execute an ATA PIO Data Out command in LBA sector addressing
mode.
numSect is the actual number of sectors to be transfered.
This value may be different than the sc value.
If cmd is C5H (Write Multiple) then multiCnt MUST be set to
the current sectors per block.
Returns 0 if no error or 1 if there is an error. See the
contents of reg_cmd_info.
int reg_reset( int skipFlag, // skip flag
int devRtrn ); // device's data returned
Execute an ATA Soft Reset. Set skipFlag to a non-zero value
to bypass the setting of the SRST bit to 0 and then to 1 (used
in some diagnostic programs). Set devRtrn to 0 or 1 to
determine which device's register contents are returned in
reg_cmd_info.
int reg_slow_xfer_flag;
Set this word to a non-zero value to cause ATADRVR to insert a
0 to 55ms delay into ATA and ATAPI commands in PIO mode. This
simulates a very slow host system and is know to cause various
problems for devices (such as buffer overruns and or
underruns, firmware hangs, etc).
For ATA PIO commands, if the value is zero or greater than
numSect, no delay is inserted, else the delay is inserted when
the number of sector remaining to be transferred is less than
this value.
For ATAPI PIO commands, if the value is zero or greater than
the number of DRQ blocks transferred by the device, no delay
is inserted, else the delay is inserted prior to the DRQ block
number specified by this value.
Functions And Data In ATAIOTMR.C
--------------------------------
These functions provide the command timeout functions used by
ATADRVR. Normally these functions are called only by ATADRVR.
int tmr_chk_timeout( void );
Used by ATADRVR to check if a command or reset has timed out.
The function tmr_set_timeout() MUST be called before using
this function to time a command or reset.
long tmr_read_bios_timer( void );
Used by ATADRVR to read the current contents of the BIOS
timer. Normally this value increments every 55ms and is reset
to zero at midnight.
void tmr_set_timeout( void );
Used by ATADRVR to set the timeout time for a command or
reset. The value tmr_time_out is added to the current time
and this becomes the time that is checked whenever
tmr_chk_timeout() is called.
long tmr_time_out;
This value is the command timeout value in seconds. ATADRVR
assumes a device is hung if a command or reset requires more
than this number of seconds to complete. The default is 20
(20 seconds). Note that some ATA commands (such as power
management may require this value be set larger (perhaps to
40).
Functions And Data In ATAIOTRC.C
--------------------------------
These functions are the public interface to the command history
and low level trace facility or ATADRVR.
unsigned char * trc_get_cmd_name( unsigned char flg,
unsigned char cc );
Return a pointer to a character string that is the name of an
ATA command. flg MUST be one of the following values (as
defined in ATAIO.H): TRC_FLAG_SRST or TRC_FLAG_CMD. cc is the
ATA command code (the value is ignored if flg is
TRC_FLAG_SRST).
unsigned char * trc_get_er_bit_name( unsigned char er );
Return a pointer to a character string that is the list of
error bits that are 1 in the ATA Error register. er is assumed
to be a value read from the ATA Error register.
unsigned char * trc_get_err_name( int ec );
Return a pointer to a character string that describes the
ATADRVR error code (ec).
unsigned char * trc_get_st_bit_name( unsigned char st );
Return a pointer to a character string that is the list of
status bits that are 1 in the ATA Error register. st is
assumed to be a value read from the ATA Status or Alternate
Status register.
void trc_err_dump1( void );
unsigned char * trc_err_dump2( void );
Use these funcitons to return a set of character strings that
describe the results of the last command executed. See
EXAMPLE1.C or EXAMPLE2.C for details on how to call these
functions.
void trc_cht_dump0( void );
void trc_cht_dump1( void );
unsigned char * trc_cht_dump2( void );
Use these funcitons to return a set of character strings that
are the current contents of the command history trace buffer.
See EXAMPLE1.C or EXAMPLE2.C for details on how to call these
functions.
void trc_cht_types( int type );
The types of commands that are traced in the command history
can be restricted to the types specified in this function
call. type MUST be one of these values (as defined in
ATAIO.H): TRC_TYPE_ALL, TRC_TYPE_NONE, TRC_TYPE_ADMAI,
TRC_TYPE_ADMAO, TRC_TYPE_AND, TRC_TYPE_APDI, TRC_TYPE_APDO,
TRC_TYPE_ASR, TRC_TYPE_PDMAI, TRC_TYPE_PDMAO, TRC_TYPE_PND,
TRC_TYPE_PPDI, TRC_TYPE_PPDO.
void trc_llt_dump0( void );
void trc_llt_dump1( void );
unsigned char * trc_llt_dump2( void );
Use these funcitons to return a set of character strings that
are the current contents of the low level trace buffer. See
EXAMPLE1.C or EXAMPLE2.C for details on how to call these
functions.
QUESTIONS OR PROBLEMS?
----------------------
Send your question(s) or problem description(s) to Hale Landis
via email at this address:
hlandis@ata-atapi.com
Visit Hale's web site:
www.ata-atapi.com
/end/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -