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

📄 atadrvr.ug

📁 ATADRVR是DOS下的磁盘驱动程序,采用PIO传输 ,PCI DMA传输,ATA包,等非常全面代码示例... 内部有C与Asm描述. 编译环境:Borland C/C++ 4.52 与 Bo
💻 UG
📖 第 1 页 / 共 4 页
字号:
                    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 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.  See the
   contents of reg_cmd_info.


Functions And Data In ATAIOPCI.C
--------------------------------

These functions setup PCI bus DMA (ATA Multiword or Ultra DMA)
and perform ATA and ATAPI commands using DMA.  The function
dma_pci_config() MUST be called with no error before any of the
other functions will attempt to execute a command.

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

   Execute an ATA Read DMA (C8H) or ATA Write DMA (CAH) 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 dma_pci_lba28( 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

   Execute an ATA Read DMA (C8H) or ATA Write DMA (CAH) 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 dma_pci_lba48( int dev,                // device (0 or 1)
                   int cmd,                // command register
                   int fr,                 // feature register
                   int sc,                 // sector count
                   long lbahi,             // LBA upper 16-bits
                   long lbalo,             // LBA lower 32 bits
                   unsigned seg,           // buffer address
                   unsigned off );         // buffer address

   Execute an ATA Read DMA (C8H) or ATA Write DMA (CAH) 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 dma_pci_config( unsigned int regAddr );

   Configure ATADRVR to use PCI bus DMA (ATA Multiword or Ultra
   DMA) on a PCI Bus Mastering ATA controller.

int dma_pci_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 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.  See the
   contents of reg_cmd_info.

void dma_pci_set_max_xfer( unsigned int seg, unsigned int off,
                           long bufSize );

   This function uses the caller's I/O buffer description
   (seg;off and size) to compute if LARGE PRD lists can be
   supported.  See the variables:  dma_pci_prd_type,
   dma_pci_largeMaxB, dma_pci_largeMaxS, dma_pci_largePrdBufPtr
   and dma_pci_largeIoBufPtr.

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.

int dma_pci_prd_type;

   This variable determines the type of PRD list that will be
   used.  Choices are SIMPLE, COMPLEX and LARGE.  SIMPLE are the
   most common type.  COMPLEX lists are the same as SIMPLE but
   with more PRD entries that break the transfers into smaller
   memory areas.  LARGE PRD lists are built in the caller's I/O
   buffer and a 64K chunk of the same I/O buffer is used over and
   over for the data transfer.  LARGE PRD lists enable READ/WRITE
   DMA EXT transfers up to 65356 sectors.  Use the function
   dma_pci_set_max_xfer() to determine if LARGE PRD lists can be
   supported.

   Note that COMPLEX PRD lists may cause data corruption and/or
   system hang problems on some ATA host controllers.

unsigned long * dma_pci_prd_ptr;       // current BMCR PRD buffer 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_num_prd;                   // current number of PRD entries

   This value is READONLY -- DO NOT ALTER.

   This value is the number of PRD entries used for the last DMA
   command.

long dma_pci_largeMaxB;   // max LARGE dma transfer size in bytes
long dma_pci_largeMaxS;   // max LARGE dma transfer size in sectors
unsigned long far * dma_pci_largePrdBufPtr;  // LARGE PRD buffer ptr
unsigned char far * dma_pci_largeIoBufPtr;   // LARGE PRD I/O address

   These values are READONLY -- DO NOT ALTER.

   These values are set by calling the function
   dma_pci_set_max_xfer().  If dma_pci_set_max_xfer() sets these
   values to non-zero and non-NULL values then LARGE PRD lists
   can be supported.


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().

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 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().

int pio_memory_dt_opt;

   This value is used only in PCMCIA PC Card ATA Memory mode.
   The value controls how ATADRVR reads/write the ATA Data
   register.  It can be set to the following values (see
   ATAIO.H):

   PIO_MEMORY_DT_OPT0  -  use Data reg at offset 0H
   PIO_MEMORY_DT_OPT8  -  use Data reg at offset 8H
   PIO_MEMORY_DT_OPTB  -  use Data reg at offsets 400-7ffH
   PIO_MEMORY_DT_OPTR  -  randomly select these options

   The default is PIO_MEMORY_DT_OPT0.

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

   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.

⌨️ 快捷键说明

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