00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef IDE_H
00035 #define IDE_H
00036
00037 #include <const.h>
00038
00039 #define IDE_DEBUG 1 // 1=compila codice di debug 0=non compila codice di debug
00040
00041
00042
00043
00044
00045
00046 #define CC_PRIMARY 0
00047 #define CC_SECONDARY 1
00048
00049
00050 #define CC_DATA 0 // Data Register
00051 #define CC_ERR 1 // Error Register
00052 #define CC_FEAT 1 // Features Register
00053 #define CC_SECC 2 // Sector Count Register
00054 #define CC_SECN 3 // Sector Number Register
00055 #define CC_CYLL 4 // Cylinder Low Register
00056 #define CC_CYLH 5 // Cylinder High Register
00057 #define CC_DEVH 6 // Device/Head Register
00058 #define CC_STAT 7 // Status Register
00059 #define CC_CMD 7 // Command Register
00060 #define CC_ASTAT 8 // Alternate Status Register
00061 #define CC_DEVC 8 // Device Command Register
00062 #define CC_ADDR 9 // Address Register
00063
00064 #define CC_DEV0 0
00065 #define CC_DEV1 1
00066 #define CC_DEVTYPE_NONE 0
00067 #define CC_DEVTYPE_UNKN 1
00068 #define CC_DEVTYPE_ATA 2
00069 #define CC_DEVTYPE_ATAPI 3
00070
00071
00072
00073
00074
00075 #define GETBITB(Data,nBit) ( ((byte) Data >> nBit) & 0x01 )
00076 #define GETBITW(Data,nBit) ( ((word) Data >> nBit) & 0x0001 )
00077 #define GETBITD(Data,nBit) ( ((dword) Data >> nBit) & 0x00000001 )
00078 #define GETNIBBLEB(Data,nNibble) ( ((byte) Data >> (nNibble<<2)) & 0x0F)
00079 #define GETNIBBLEW(Data,nNibble) ( ((word) Data >> (nNibble<<2)) & 0x000F)
00080 #define GETNIBBLED(Data,nNibble) ( ((dword) Data >> (nNibble<<2)) & 0x0000000F)
00081 #define GETBYTEW(Data,nByte) ( ((word) Data >> (nByte<<3)) & 0x00FF )
00082 #define GETBYTED(Data,nByte) ( ((dword) Data >> (nByte<<3)) & 0x000000FF)
00083 #define GETWORDD(Data,nWord) ( ((dword) Data >> (nWord<<4)) & 0x0000FFFF )
00084 #define MAKEDWORDW(Word1,Word0) ( (((dword) Word1 << 16) | (word) Word0) )
00085 #define SWAPBYTEW(Data) ( (GETBYTEW(Data,0) << 8) | (GETBYTEW(Data,1)) )
00086
00087
00088 #define Bit2YesNo(Exp) ( (char *) (Exp ? "YES" : "NO ") )
00089
00090
00091 typedef struct BusMaster_Struct
00092 {
00093 int Config;
00094 dword BaseAddress;
00095 unsigned long * PrdBufPtr;
00096 dword DmaPciPrdAddr;
00097 byte PrdBuf[64];
00098 dword PrdBufPtrLow;
00099 dword PrdBufPtrHigh;
00100 byte StatReg;
00101 byte RWControl;
00102 } BusMaster_Struct;
00103
00104
00105 void ShowDeviceSubData(int Dev);
00106 void ShowIdeSubData();
00107 int ScanDevice(int UseInterrupt) ;
00108 int IdentifyDevice (int Dev) ;
00109 void ShowDeviceDataRowName(char * Name,int Col);
00110 void ShowDeviceDataRowValue(char * Name, int Col, char * Format, dword Value);
00111 void ShowDeviceDataRowString(char * Name, int Col, char * Value);
00112 void ShowDeviceDataRowSup(char * Name,int Col, byte Supported);
00113 void ShowDeviceDataRowSupEn(char * Name,int Col,byte Supported,byte Enabled);
00114 void ShowDeviceDataRowBitNum(word BitCode,byte StartFrom, byte EndTo, byte StartPrintNum);
00115 void ShowDeviceData(int Dev,int Col);
00116 void InitIde();
00117 int ReadSectorsLba(int Dev, uint64 Lba, int NumSect, word * Buffer,int UseInterrupt);
00118 int WriteSectorsLba(int Dev, uint64 Lba, int NumSect, word * Buffer,int UseInterrupt);
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 #define BMCR_IO_ADDR 0xFF00 // YOU MUST SUPPLY THIS VALUE
00140 #define BM_COMMAND_REG 0 // offset to command reg
00141 #define BM_CR_MASK_READ 0x00 // read from memory
00142 #define BM_CR_MASK_WRITE 0x08 // write to memory
00143 #define BM_CR_MASK_START 0x01 // start transfer
00144 #define BM_CR_MASK_STOP 0x00 // stop transfer
00145
00146 #define BM_STATUS_REG 2 // offset to status reg
00147 #define BM_SR_MASK_SIMPLEX 0x80 // simplex only
00148 #define BM_SR_MASK_DRV1 0x40 // drive 1 can do dma
00149 #define BM_SR_MASK_DRV0 0x20 // drive 0 can do dma
00150 #define BM_SR_MASK_INT 0x04 // INTRQ signal asserted
00151 #define BM_SR_MASK_ERR 0x02 // error
00152 #define BM_SR_MASK_ACT 0x01 // active
00153
00154 #define BM_PRD_ADDR_LOW 4 // offset to prd addr reg low 16 bits
00155 #define BM_PRD_ADDR_HIGH 6 // offset to prd addr reg high 16 bits
00156
00157
00158 #endif