📄 mindrvr.h
字号:
#define CB_DH_LBA 0x40 // LBA bit
#define CB_DH_DEV0 0x00 // select device 0
#define CB_DH_DEV1 0x10 // select device 1
// #define CB_DH_DEV0 0xa0 // select device 0 (old definition)
// #define CB_DH_DEV1 0xb0 // select device 1 (old definition)
// status reg (CB_STAT and CB_ASTAT) bits
#define CB_STAT_BSY 0x80 // busy
#define CB_STAT_RDY 0x40 // ready
#define CB_STAT_DF 0x20 // device fault
#define CB_STAT_WFT 0x20 // write fault (old name)
#define CB_STAT_SKC 0x10 // seek complete (only SEEK command)
#define CB_STAT_SERV 0x10 // service (overlap/queued commands)
#define CB_STAT_DRQ 0x08 // data request
#define CB_STAT_CORR 0x04 // corrected (obsolete)
#define CB_STAT_IDX 0x02 // index (obsolete)
#define CB_STAT_ERR 0x01 // error (ATA)
#define CB_STAT_CHK 0x01 // check (ATAPI)
// device control reg (CB_DC) bits
#define CB_DC_HOB 0x80 // High Order Byte (48-bit LBA)
// #define CB_DC_HD15 0x00 // bit 3 is reserved
// #define CB_DC_HD15 0x08 // (old definition of bit 3)
#define CB_DC_SRST 0x04 // soft reset
#define CB_DC_NIEN 0x02 // disable interrupts
//**************************************************************
//
// Most mandtory and optional ATA commands
//
//**************************************************************
#define CMD_CFA_ERASE_SECTORS 0xC0
#define CMD_CFA_REQUEST_EXT_ERR_CODE 0x03
#define CMD_CFA_TRANSLATE_SECTOR 0x87
#define CMD_CFA_WRITE_MULTIPLE_WO_ERASE 0xCD
#define CMD_CFA_WRITE_SECTORS_WO_ERASE 0x38
#define CMD_CHECK_POWER_MODE1 0xE5
#define CMD_CHECK_POWER_MODE2 0x98
#define CMD_DEVICE_RESET 0x08
#define CMD_EXECUTE_DEVICE_DIAGNOSTIC 0x90
#define CMD_FLUSH_CACHE 0xE7
#define CMD_FLUSH_CACHE_EXT 0xEA
#define CMD_FORMAT_TRACK 0x50
#define CMD_IDENTIFY_DEVICE 0xEC
#define CMD_IDENTIFY_DEVICE_PACKET 0xA1
#define CMD_IDENTIFY_PACKET_DEVICE 0xA1
#define CMD_IDLE1 0xE3
#define CMD_IDLE2 0x97
#define CMD_IDLE_IMMEDIATE1 0xE1
#define CMD_IDLE_IMMEDIATE2 0x95
#define CMD_INITIALIZE_DRIVE_PARAMETERS 0x91
#define CMD_INITIALIZE_DEVICE_PARAMETERS 0x91
#define CMD_NOP 0x00
#define CMD_PACKET 0xA0
#define CMD_READ_BUFFER 0xE4
#define CMD_READ_DMA 0xC8
#define CMD_READ_DMA_EXT 0x25
#define CMD_READ_DMA_QUEUED 0xC7
#define CMD_READ_DMA_QUEUED_EXT 0x26
#define CMD_READ_MULTIPLE 0xC4
#define CMD_READ_MULTIPLE_EXT 0x29
#define CMD_READ_SECTORS 0x20
#define CMD_READ_SECTORS_EXT 0x24
#define CMD_READ_VERIFY_SECTORS 0x40
#define CMD_READ_VERIFY_SECTORS_EXT 0x42
#define CMD_RECALIBRATE 0x10
#define CMD_SEEK 0x70
#define CMD_SET_FEATURES 0xEF
#define CMD_SET_MULTIPLE_MODE 0xC6
#define CMD_SLEEP1 0xE6
#define CMD_SLEEP2 0x99
#define CMD_SMART 0xB0
#define CMD_STANDBY1 0xE2
#define CMD_STANDBY2 0x96
#define CMD_STANDBY_IMMEDIATE1 0xE0
#define CMD_STANDBY_IMMEDIATE2 0x94
#define CMD_WRITE_BUFFER 0xE8
#define CMD_WRITE_DMA 0xCA
#define CMD_WRITE_DMA_EXT 0x35
#define CMD_WRITE_DMA_QUEUED 0xCC
#define CMD_WRITE_DMA_QUEUED_EXT 0x36
#define CMD_WRITE_MULTIPLE 0xC5
#define CMD_WRITE_MULTIPLE_EXT 0x39
#define CMD_WRITE_SECTORS 0x30
#define CMD_WRITE_SECTORS_EXT 0x34
#define CMD_WRITE_VERIFY 0x3C
//**************************************************************
//
// ATA and ATAPI PIO support functions
//
//**************************************************************
// config and reset funcitons
extern int reg_config( void );
extern int reg_reset( unsigned char devRtrn );
// ATA Non-Data command funnctions (for LBA28 and LBA48)
extern int reg_non_data_lba28( unsigned char dev, unsigned char cmd,
unsigned int fr, unsigned int sc,
unsigned long lba );
extern int reg_non_data_lba48( unsigned char dev, unsigned char cmd,
unsigned int fr, unsigned int sc,
unsigned long lbahi, unsigned long lbalo );
// ATA PIO Data In command functions (for LBA28 and LBA48)
extern int reg_pio_data_in_lba28( unsigned char dev, unsigned char cmd,
unsigned int fr, unsigned int sc,
unsigned long lba,
unsigned char * bufAddr,
long numSect, int multiCnt );
extern int reg_pio_data_in_lba48( unsigned char dev, unsigned char cmd,
unsigned int fr, unsigned int sc,
unsigned long lbahi, unsigned long lbalo,
unsigned char * bufAddr,
long numSect, int multiCnt );
// ATA PIO Data Out command functions (for LBA28 and LBA48)
extern int reg_pio_data_out_lba28( unsigned char dev, unsigned char cmd,
unsigned int fr, unsigned int sc,
unsigned long lba,
unsigned char * bufAddr,
long numSect, int multiCnt );
extern int reg_pio_data_out_lba48( unsigned char dev, unsigned char cmd,
unsigned int fr, unsigned int sc,
unsigned long lbahi, unsigned long lbalo,
unsigned char * bufAddr,
long numSect, int multiCnt );
#if INCLUDE_ATAPI_PIO
// ATAPI Packet PIO function
extern int reg_packet( unsigned char dev,
unsigned int cpbc,
unsigned char * cdbBufAddr,
int dir,
long dpbc,
unsigned char * dataBufAddr );
#endif // INCLUDE_ATAPI_PIO
//**************************************************************
//
// ATA and ATAPI DMA support functions
//
//**************************************************************
#if INCLUDE_ATA_DMA || INCLUDE_ATAPI_DMA
// BMIDE registers and bits
#define BM_COMMAND_REG 0 // offset to BM command reg
#define BM_CR_MASK_READ 0x00 // read from memory
#define BM_CR_MASK_WRITE 0x08 // write to memory
#define BM_CR_MASK_START 0x01 // start transfer
#define BM_CR_MASK_STOP 0x00 // stop transfer
#define BM_STATUS_REG 2 // offset to BM status reg
#define BM_SR_MASK_SIMPLEX 0x80 // simplex only
#define BM_SR_MASK_DRV1 0x40 // drive 1 can do dma
#define BM_SR_MASK_DRV0 0x20 // drive 0 can do dma
#define BM_SR_MASK_INT 0x04 // INTRQ signal asserted
#define BM_SR_MASK_ERR 0x02 // error
#define BM_SR_MASK_ACT 0x01 // active
#define BM_PRD_ADDR_LOW 4 // offset to BM prd addr reg low 16 bits
#define BM_PRD_ADDR_HIGH 6 // offset to BM prd addr reg high 16 bits
// PCI DMA setup function (usually called once).
// !!! You may not need this function in your system - see the comments
// !!! for this function in MINDRVR.C.
extern int dma_pci_config( void );
// ATA DMA functions
extern int dma_pci_lba28( unsigned char dev, unsigned char cmd,
unsigned int fr, unsigned int sc,
unsigned long lba,
unsigned char * bufAddr,
long numSect );
extern int dma_pci_lba48( unsigned char dev, unsigned char cmd,
unsigned int fr, unsigned int sc,
unsigned long lbahi, unsigned long lbalo,
unsigned char * bufAddr,
long numSect );
#endif // INCLUDE_ATA_DMA or INCLUDE_ATAPI_DMA
#if INCLUDE_ATAPI_DMA
// ATA DMA function
extern int dma_pci_packet( unsigned char dev,
unsigned int cpbc,
unsigned char * cdbBufAddr,
int dir,
long dpbc,
unsigned char * dataBufAddr );
#endif // INCLUDE_ATAPI_DMA
// end mindrvr.h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -