⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 advdrvr.ug

📁 pc机上经由pci连接的ata和atapi设备驱动
💻 UG
📖 第 1 页 / 共 3 页
字号:
                    unsigned int dpseg,      // data packet buffer
                    unsigned int dpoff );    // data packet buffer

   Execute an ATAPI Packet (A0H) command in DMA 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.

unsigned int dma_pci_prd_addr;        // BMCR PRD address

   This value is READONLY -- DO NOT ALTER.

   This value is the segment address of the BMCR PRD buffer.
   This value is determined by dma_pci_config().

int dma_pci_prd_size;

   This value is READONLY -- DO NOT ALTER.

   This value is the size (in bytes) of the PRD buffer.

unsigned int dma_pci_bmcr_reg_addr;    // BMCR reg base i/o address

   This value is READONLY -- DO NOT ALTER.

   This value is the base I/O address of the BMCR 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 base I/O address of the BMCR registers.


Functions And Data In ADVIOPIO.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 ADVDRVR.  However, normal usage of ADVDRVR 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().

void pio_drq_block_in( unsigned int addrDataReg,
                       unsigned int bufSeg, unsigned int bufOff,
                       long wordCnt );

   This function calls one of the reg_rep_in*() functions
   based on the value of reg_xfer_width.

void pio_drq_block_out( unsigned int addrDataReg,
                        unsigned int bufSeg, unsigned int bufOff,
                        long wordCnt )

   This function calls one of the reg_rep_out*() functions
   based on the value of reg_xfer_width.

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 ADVIO.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 ADVIO.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: ADVDRVR does not use this function.

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 ADVIO.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 ADVIO.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: ADVDRVR 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

   NOTE: Normally this function is not called directly but
   is called by the pio_drq_block_in() function!

   Use the REP INS instruction to read the ATA Data Register
   during PIO data transfer.

void pio_rep_indword( unsigned int addrDataReg,    // register address
                      unsigned int bufSeg,         // buffer address
                      unsigned int bufOff,         // buffer address
                      unsigned int dwordCnt );     // dword count

   NOTE: Normally this function is not called directly but
   is called by the pio_drq_block_in() function!

   Use the REP INSD instruction to read the ATA Data Register
   during PIO data transfer.  Note that this function is called
   by pio_drq_block_in() 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

   NOTE: Normally this function is not called directly but
   is called by the pio_drq_block_in() function!

   Use the REP INSW instruction to read the ATA Data Register
   during PIO data transfer.

void pio_rep_outbyte( unsigned int addrDataReg,   // register address
                      unsigned int bufSeg,        // buffer address
                      unsigned int bufOff,        // buffer address
                      unsigned int bytedCnt );    // byte count

   NOTE: Normally this function is not called directly but
   is called by the pio_drq_block_out() function!

   Use the REP OUTS instruction to write the ATA Data Register
   during PIO data transfer.

void pio_rep_outdword( unsigned int addrDataReg,   // register address
                       unsigned int bufSeg,        // buffer address
                       unsigned int bufOff,        // buffer address
                       unsigned int dwordCnt );    // dword count

   NOTE: Normally this function is not called directly but
   is called by the pio_drq_block_out() function!

   Use the REP OUTSD instruction to write the ATA Data Register
   during PIO data transfer.  Note that this function is called
   by pio_drq_block_out() 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

   NOTE: Normally this function is not called directly but
   is called by the pio_drq_block_out() function!

   Use the REP OUTSW instruction to write the ATA Data Register
   during PIO data transfer.

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 ADVDRVR 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 ADVDRVR 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:

   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.

   See the pio_rep_*() functions above.

   Use this ADVDRVR feature with great care and read the
   documentation file PIO.UG!


Functions And Data In ADVIOREG.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 ADVDRVR to operate
incorrectly.

unsigned char reg_atapi_cp_data[16];
int reg_atapi_cp_size;

   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.

unsigned char reg_atapi_reg_fr;  // 0x01 OR'ed in for DMA
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(),
   dma_isa_packet() and dma_pci_packet() functions before the A0H
   command is started.  These values are then set to zero before
   reg_packet() returns.

long reg_buffer_size;

   This must be set to the size in bytes of the data buffer
   provided by the caller.

int reg_config( void );

   This function MUST be called so that ADVDRVR can correctly
   configure itself. reg_config() sets the values into
   reg_config_info[2].

void ( * reg_drq_block_call_back ) ( struct ADVIO_DEVICE * )

When this value is not NULL the PIO Data In/Out functions place
the data for each DRQ block at the beginning of the data buffer.
This function is called after each DRQ data block is read from
the device or before each DRQ data block is written to the
device.  The call back function receives a pointer to a
ADVIO_DEVICE structure.  To determine what is happening the call
back function should use these variables in the structure:  flg,
ct, cmd, drqPackets and drqPacketSize.  The call back function
must not modify the contents of the ADVIO_DEVICE structure.

   This value is set back to NULL before the PIO Data In/Out
   functions return.

int reg_non_data_chs( 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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -