📄 atadrvr.ug
字号:
This value is READONLY -- DO NOT ALTER.
This value is the segment address of the SFF-8038 PRD buffer.
This value is determined by dma_pci_config().
unsigned int dma_pci_sff_reg_addr; // SFF-8038 reg address
This value is READONLY -- DO NOT ALTER.
This value is the segment address of the SFF-8038 I/O
registers. The value is set by dma_pci_config().
Note that in order to use PCI DMA the calling program must
determine the current address of the SFF-8038 I/O registers.
Functions And Data In ATAIOPIO.C
--------------------------------
These functions setup the ATA host adapter I/O port address (or
in PCMCIA PC Card ATA Memory mode, the host adapter memory
address). The function pio_set_iobase_addr() (or
pio_set_memory_addr()) MUST be the first function called in order
to initialize ATADRVR. However, normal usage of ATADRVR does NOT
require calling any of the other pio functions. But if you
needed to create you own unique command protocol, these functions
can be used directly.
unsigned int pio_base_addr1;
This value is READONLY -- DO NOT ALTER.
This is the base I/O address of the ATA Command Block
registers. This value is set by pio_set_iobase_addr().
unsigned int pio_base_addr2;
This value is READONLY -- DO NOT ALTER.
This is the base I/O address of the ATA Control Block
registers. This value is set by pio_set_iobase_addr().
unsigned char pio_inbyte( unsigned int addr );
Read one ATA command or control block register. addr MUST be
one of the following values (as defined in ATAIO.H): CB_DATA,
CB_ERR, CB_FR, CB_SC, CB_SN, CB_CL, CB_CH, CB_DH, CB_STAT,
CB_CMD, CB_ASTA, CB_DC, CB_DA.
unsigned int pio_inword( unsigned int addr );
Read two ATA command or control block registers. addr MUST be
one of the following values (as defined in ATAIO.H): CB_DATA,
CB_ERR, CB_FR, CB_SC, CB_SN, CB_CL, CB_CH, CB_DH, CB_STAT,
CB_CMD, CB_ASTA, CB_DC, CB_DA.
Note: ATADRVR does not use this function.
unsigned char pio_last_read[10];
This value is READONLY -- DO NOT ALTER.
This array contains the last data read from each of the ATA
command or control block registers. Index into this array
using the values (as defined in ATAIO.H): CB_DATA, CB_ERR,
CB_FR, CB_SC, CB_SN, CB_CL, CB_CH, CB_DH, CB_STAT, CB_CMD,
CB_ASTA, CB_DC, CB_DA.
unsigned char pio_last_write[10];
This value is READONLY -- DO NOT ALTER.
This array contains the last data written to each of the ATA
command or control block registers. Index into this array
using the values (as defined in ATAIO.H): CB_DATA, CB_ERR,
CB_FR, CB_SC, CB_SN, CB_CL, CB_CH, CB_DH, CB_STAT, CB_CMD,
CB_ASTA, CB_DC, CB_DA.
unsigned int pio_memory_seg;
This value is READONLY -- DO NOT ALTER.
This is the base memory address of the ATA Command and Control
Block registers in PCMCIA PC Card ATA Memory mode. This value
is set by pio_set_memory_addr().
void pio_outbyte( unsigned int addr,
unsigned char data );
Write one ATA command or control block register. addr MUST be
one of the following values (as defined in ATAIO.H): CB_DATA,
CB_ERR, CB_FR, CB_SC, CB_SN, CB_CL, CB_CH, CB_DH, CB_STAT,
CB_CMD, CB_ASTA, CB_DC, CB_DA.
void pio_outword( unsigned int addr,
unsigned int data );
Write two ATA command or control block registers. addr MUST be
one of the following values (as defined in ATAIO.H): CB_DATA,
CB_ERR, CB_FR, CB_SC, CB_SN, CB_CL, CB_CH, CB_DH, CB_STAT,
CB_CMD, CB_ASTA, CB_DC, CB_DA.
Note: ATADRVR does not use this function.
unsigned int pio_reg_addrs[10];
This value is READONLY -- DO NOT ALTER.
This array provides the actually I/O addresses for the ATA
Command and Control Block registers. This array is not
useful in PCMCIA PC Card ATA Memory mode.
void pio_rep_inbyte( unsigned int addrDataReg, // register address
unsigned int bufSeg, // buffer address
unsigned int bufOff, // buffer address
unsigned int byteCnt ); // byte count
Use the REP INS instruction to read the ATA Data Register
during PIO data transfer. Note that this function is called
by pio_rep_inword() but only if pio_xfer_width is 8.
void pio_rep_indword( unsigned int addrDataReg, // register address
unsigned int bufSeg, // buffer address
unsigned int bufOff, // buffer address
unsigned int dwordCnt ); // dword count
Use the REP INSD instruction to read the ATA Data Register
during PIO data transfer. Note that this function is called
by pio_rep_inword() but only if: 1) pio_xfer_width is 32
and 2) the number of bytes to be read is a multiple of 4.
void pio_rep_inword( unsigned int addrDataReg, // register address
unsigned int bufSeg, // buffer address
unsigned int bufOff, // buffer address
unsigned int wordCnt ); // word count
Use the REP INSW instruction to read the ATA Data Register
during PIO data transfer. This function may call pio_rep_inbyte()
or pio_rep_indword() if pio_xfer_width is not 16.
void pio_rep_outbyte( unsigned int addrDataReg, // register address
unsigned int bufSeg, // buffer address
unsigned int bufOff, // buffer address
unsigned int bytedCnt ); // byte count
Use the REP OUTS instruction to write the ATA Data Register
during PIO data transfer. Note that this function is called
by pio_rep_outword() but only if pio_xfer_width is 8.
void pio_rep_outdword( unsigned int addrDataReg, // register address
unsigned int bufSeg, // buffer address
unsigned int bufOff, // buffer address
unsigned int dwordCnt ); // dword count
Use the REP OUTSD instruction to write the ATA Data Register
during PIO data transfer. Note that this function is called
by pio_rep_outword() but only if: 1) pio_xfer_width is 32
and 2) the number of bytes to be written is a multiple of 4.
void pio_rep_outword( unsigned int addrDataReg, // register address
unsigned int bufSeg, // buffer address
unsigned int bufOff, // buffer address
unsigned int wordCnt ); // word count
Use the REP OUTSW instruction to write the ATA Data Register
during PIO data transfer. This function may call pio_rep_outbyte()
or pio_rep_outdword() if pio_xfer_width is not 16.
void pio_set_iobase_addr( unsigned int base1,
unsigned int base2 );
Either pio_set_iobase_addr() or pio_set_memory_addr() must be
called before any other ATADRVR functions can be used!
Configure the ATA host adapter's I/O port addresses. Normal
calls to this function are:
pio_set_iobase_addr( 0x1f0, 0x3f0 ) // primary
pio_set_iobase_addr( 0x170, 0x370 ) // secondary
For PCMCIA PC Card ATA Contiguous I/O mode use:
pio_set_iobase_addr( addr, addr+8 )
where the least significant 4 bits of addr are zero. Note
that the calling program must find a contiguous set of 16 I/O
port addresses that are not in use in order to use this PCMCIA
I/O mode. See the documentation file PCC.UG!
void pio_set_memory_addr( unsigned int seg );
Either pio_set_iobase_addr() or pio_set_memory_addr() must be
called before any other ATADRVR functions can be used!
Configure the ATA host adapter's memory address in PCMCIA PC
Card ATA Memory mode. Note that the calling program must find
a 4K block of memory that is not in use in order to use this
PCMCIA mode. See the documentation file PCC.UG!
int pio_use_dword;
NOTE: pio_use_dword has been replaced by pio_xfer_width !
int pio_xfer_width;
This variable controls the width of PIO data transfers.
This variable can have the following values:
8 = 8-bits. PIO transfers will use REP INS and REP OUTS
or 8-bit memory write/read in PCMCIA Memory mode.
16 = 16-bits. PIO transfers will use REP INSW and REP OUTSW
or 16-bit memory write/read in PCMCIA Memory mode.
32 = 32-bits. PIO transfers will use REP INSD and REP OUTSD.
Any other value is treated the same as 16.
The default value is 16.
See the pio_rep_*() functions above.
Use this ATADRVR feature with great care and read the
documentation file PIO.UG!
Functions And Data In ATAIOREG.C
--------------------------------
These functions provide the basic ATA and ATAPI command protocol
functions. The function reg_config() MUST be called after
calling pio_set_iobase_addr() (or pio_set_memory_addr()).
Failure to call reg_config() will cause ATADRVR to operate
incorrectly.
int reg_atapi_delay_flag;
Many ATAPI devices are very poorly designed and do not follow
the ATA or ATAPI protocols as defined by SFF-8020 or by the
ATA/ATAPI-4 standard. Setting this word to a non-zero value
causes ATADRVR to insert an approximately 100ms delay into the
ATA and/or ATAPI command protocols. This delay seems to allow
enough time for these non-conforming devices to operate
correctly.
long reg_atapi_max_bytes;
Many ATAPI devices have a "run away" data transfer problem.
This value sets the upper limit for the amount of data can be
transfered by an ATAPI Packet command in PIO mode. This value
is reset to 32768 at the end of every ATAPI Packet command.
The calling program may set this value to a smaller value (for
example, if an ATAPI Request Sense command is about to be
executed). This prevents the calling program's data buffer
from being overrun.
unsigned char reg_atapi_reg_fr;
unsigned char reg_atapi_reg_sc;
unsigned char reg_atapi_reg_sn;
unsigned char reg_atapi_reg_dh; // only bits 3,2,1,0 are used
These values are placed into the Feature, Sector Count, Sector
Number and Device/Head register by the reg_packet() function
before the A0H command is started. These values are then set
to zero before reg_packet() returns.
struct REG_CMD_INFO
{
unsigned char flg; // see TRC_FLAG_xxx in ATAIO.H
unsigned char ct; // see TRC_TYPE_xxx in ATAIO.H
unsigned char cmd; // command code
unsigned char fr1; // feature reg before
... See ATAIO.H ...
unsigned char dc1; // device control before
unsigned char ec; // ATADRVR error code
unsigned char to; // not zero if time out error
unsigned char st2; // status reg after
... See ATAIO.H ...
unsigned char dh2; // device head after
long totalBytesXfer; // total bytes transfered
unsigned int failbits; // failure bits (protocol violation bits)
long drqPackets; // number of PIO DRQ data packets
} ;
struct REG_CMD_INFO reg_cmd_info;
This data structure contains all the "before" and "after"
information for the last command or reset executed.
int reg_config( void );
This function MUST be called so that ATADRVR can correctly
configure itself. reg_config() sets the values into
reg_config_info[2].
int reg_config_info[2];
This array is set by calling reg_config(). reg_config_info[0]
describes device 0 and reg_config_info[1] describes device 1.
The possible values in these words are (see ATAIO.H):
REG_CONFIG_TYPE_NONE, REG_CONFIG_TYPE_UNKN,
REG_CONFIG_TYPE_ATA, REG_CONFIG_TYPE_ATAPI.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -