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

📄 advio.h

📁 pc机上经由pci连接的ata和atapi设备驱动
💻 H
📖 第 1 页 / 共 3 页
字号:
      #define ADVIO_DEV_TYPE_UNKN  1
      #define ADVIO_DEV_TYPE_ATA   2
      #define ADVIO_DEV_TYPE_ATAPI 3
   long reg_buffer_size;               // buffer size

   int incompat_flags;                 // flag bits for 'incompatible'
                                       // controllers and devices,
                                       // see #defines...
      #define REG_INCOMPAT_DMA_DELAY   0x0001   // set to 1 for delay before
                                                // and after stopping the
                                                // DMA engine
      #define REG_INCOMPAT_DMA_POLL    0x0002   // set to 1 for no polling
                                                // of Alt Status during
                                                // DMA transfers

   //--- IRQ/INT config data

   int irqActive;                      // != 0 if IRQ/INT active
   int irqNum;                         // IRQ number
   int intNum;                         // INT number
   int intOnOff;                       // INT on/off flag
   int intFlag;                        // interrupt flag
   unsigned char bmStatus;             // BMCR/BMIDE Status at last interupt
   unsigned char ataStatus;            // ATA Status at last interrupt

   //--- PCI DMA config data

   unsigned int bmcrBase;              // BMCR base i/o address
   unsigned char statReg;              // save BMCR status reg bits 6 and 5
   unsigned char rwControl;            // read/write control bit setting

   #define MAX_PRD 6                         // max PRD supported here,
                                             //    MUST BE AN EVEN NUMBER!
   #define PRD_BUF_SIZE (16+(2*MAX_PRD*8))   // size of PRD list buffer

   struct PRD prdBuf[PRD_BUF_SIZE];    // PRD buffer
   struct PRD far * prdBufPtr;         // pointer to PRD buffer
   unsigned int prdBufPtrHigh16;       // 32-bit prd ptr upper 16 bits
   unsigned int prdBufPtrLow16;        // 32-bit prd ptr lower 16 bits

   //--- values used only for PACKET commands

   // values used for the FR, SC, SN an DH registers when a PACKET
   // command is executed.
   unsigned char reg_atapi_reg_fr;     // feature reg
   unsigned char reg_atapi_reg_sc;     // sector count reg
   unsigned char reg_atapi_reg_sn;     // sector number reg
   unsigned char reg_atapi_reg_dh;     // drive/head reg (bits 3-0)

   //--- PIO Data In/Out data transfer call back function

   void ( * reg_drq_block_call_back ) ( struct ADVIO_DEVICE * );

   //--- START per command information

   //--- entry type, flag and command code
   unsigned char flg;         // see TRC_FLAG_xxx in advio.h
   unsigned char ct;          // see TRC_TYPE_xxx in advio.h
   unsigned char cmd;         // command code

   //--- before regs
   unsigned int  fr1;         // feature (8 or 16 bits)
   unsigned int  sc1;         // sec cnt (8 or 16 bits)
   unsigned char sn1;         // sec num
   unsigned char cl1;         // cyl low
   unsigned char ch1;         // cyl high
   unsigned char dh1;         // device head
   unsigned char dc1;         // device control

   //--- after regs
   unsigned char st2;         // status reg
   unsigned char as2;         // alt status reg
   unsigned char er2;         // error reg
   unsigned int  sc2;         // sec cnt (8 or 16 bits)
   unsigned char sn2;         // sec num
   unsigned char cl2;         // cyl low
   unsigned char ch2;         // cyl high
   unsigned char dh2;         // device head

   //--- driver error codes
   unsigned char ec;          // detailed error code
   unsigned char to;          // not zero if time out error

   //--- additional result info
   long totalBytesXfer;       // total bytes transfered
   long drqPackets;           // number of PIO DRQ packets
   long drqPacketSize;        // number of bytes in current DRQ block
   unsigned int failbits;     // failure bits (protocol errors)
      #define FAILBIT15 0x8000   // extra interrupts detected
      #define FAILBIT14 0x4000
      #define FAILBIT13 0x2000
      #define FAILBIT12 0x1000
      #define FAILBIT11 0x0800
      #define FAILBIT10 0x0400
      #define FAILBIT9  0x0200
      #define FAILBIT8  0x0100   // SC( CD/IO bits) wrong at end of cmd
      #define FAILBIT7  0x0080   // byte count odd at data packet xfer time
      #define FAILBIT6  0x0040   // byte count wrong at data packet xfer time
      #define FAILBIT5  0x0020   // SC (IO bit) wrong at data packet xfer time
      #define FAILBIT4  0x0010   // SC (CD bit) wrong at data packet xfer time
      #define FAILBIT3  0x0008   // byte count wrong at cmd packet xfer time
      #define FAILBIT2  0x0004   // SC wrong at cmd packet xfer time
      #define FAILBIT1  0x0002   // got interrupt before cmd packet xfer
      #define FAILBIT0  0x0001   // slow setting BSY=1 or DRQ=1 after AO cmd

   //--- sector count, multiple count, and CHS/LBA info
   long ns;                   // number of sectors (sector count)
   int mc;                    // multiple count
   unsigned char lbaSize;     // size of LBA used
      #define LBACHS 0           // last command used CHS
      #define LBA28  28          // last command used 28-bit LBA
      #define LBA32  32          // last command used 32-bit LBA (Packet)
      #define LBA48  48          // last command used 48-bit LBA
      #define LBA64  64          // future use?
   unsigned long lbaLow1;     // lower 32-bits of LBA before
   unsigned long lbaHigh1;    // upper 32-bits of LBA before
   unsigned long lbaLow2;     // lower 32-bits of LBA after
   unsigned long lbaHigh2;    // upper 32-bits of LBA after

   //--- last ATAPI command packet size and data
   int reg_atapi_cp_size;                 // 12 or 16
   unsigned char reg_atapi_cp_data[16];   // command packet (CDB) data

   //--- time values used to time the current command
   long tmr_time_out;            // command timeout in seconds
   long tmr_cmd_start_time;      // command start time

   //--- END per command information

   //--- Command History Trace buffer

   int chtSize;                  // number of trace entries
   int chtCur;                   // index of current entry
   struct CHT far * chtBuf;      // command history trace buffer

   //--- Low Level Trace buffer

   struct LLT lltMre;            // most recent entry's info
   int lltSize;                  // number of trace entries
   int lltCur;                   // index of current entry
   struct LLT far * lltBuf;      // low level trace buffer

} ;

extern struct ADVIO_DEVICE * ADP;   // CALLER MUST SUPPLY THIS POINTER !

//--------------------------------------------------------------
// ADVIOINT.C
//--------------------------------------------------------------

// Public data/functions in ADVIOINT.C

extern int  int_config( int shared, int irqNum, int chanNum, int devNum );
extern void int_enable( void );
extern void int_disable( void );

//--------------------------------------------------------------
// ADVIOPCI.C
//--------------------------------------------------------------

// Public data/functions in ADVIOPCI.C

extern void dma_pci_config( unsigned int regAddr );

extern int dma_pci_chs( int cmd,
                        unsigned int fr, unsigned int sc,
                        unsigned int cyl, unsigned int head, unsigned int sect,
                        unsigned int seg, unsigned int off,
                        long numSect );

extern int dma_pci_lba28( int cmd,
                          unsigned int fr, unsigned int sc,
                          unsigned long lba,
                          unsigned int seg, unsigned int off,
                          long numSect );

extern int dma_pci_lba48( int cmd,
                          unsigned int fr, unsigned int sc,
                          unsigned long lbahi, unsigned long lbalo,
                          unsigned int seg, unsigned int off,
                          long numSect );

extern int dma_pci_packet(
                           unsigned int cpbc,
                           unsigned int cpseg, unsigned int cpoff,
                           int dir,
                           long dpbc,
                           unsigned int dpseg, unsigned int dpoff,
                           unsigned long lba );

//--------------------------------------------------------------
// ADVIOPIO.C
//--------------------------------------------------------------

// Public data/functions in ADVIOPIO.C

// configuration functions

extern void pio_set_iobase_addr( unsigned int base1,
                                 unsigned int base2,
                                 unsigned int base3 );

// normal register read/write functions

extern unsigned char pio_inbyte( unsigned int addr );

extern void pio_outbyte( unsigned int addr, unsigned char data );

extern unsigned int pio_inword( unsigned int addr );

extern void pio_outword( unsigned int addr, unsigned int data );

// Normal PIO DRQ block transfer functions. These functions
// handle both PCMCIA memory mode and all I/O mode transfers.

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

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

// These functions can be called directly but are normally
// called by the pio_drq_block_in() and pio_drq_block_out()
// functions. These functions handle only I/O mode transfers.

extern void pio_rep_inbyte( unsigned int addrDataReg,
                            unsigned int bufSeg, unsigned int bufOff,
                            long byteCnt );

extern void pio_rep_outbyte( unsigned int addrDataReg,
                             unsigned int bufSeg, unsigned int bufOff,
                             long byteCnt );

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

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

extern void pio_rep_indword( unsigned int addrDataReg,
                             unsigned int bufSeg, unsigned int bufOff,
                             long dwordCnt );

extern void pio_rep_outdword( unsigned int addrDataReg,
                              unsigned int bufSeg, unsigned int bufOff,
                              long dwordCnt );

//--------------------------------------------------------------
// ADVIOREG.C
//--------------------------------------------------------------

// Public data/functions in ADVIOREG.C

⌨️ 快捷键说明

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