倒塌了~~~4种IO战法全读出为0,看来要改变战术了~~~
谢谢各位!!!
请明白人看俺哪里出错了...
谢谢!!!
#define HDC_FIXED 0x3F6 #define HDC_FIXED_IRQ 0x02
#define HDC_SDH 0x1F6 #define HDC_STATUS 0x1F7 #define HDC_COMMAND 0x1F7 #define HDC_DATA 0x1F0 #define HDC_COMMAND_READPAR 0xEC #define HDC_STATUS_BUSY 0x80
int al; int i; WORD pw[256]; //方法0 outp(HDC_FIXED, HDC_FIXED_IRQ); outp(HDC_SDH, 0xA0); outp(HDC_COMMAND, HDC_COMMAND_READPAR); while(inp(HDC_STATUS) & HDC_STATUS_BUSY); for (i=0; i< 256; i++) { pw = inpw(0x1F0); } /*方法1 while (inp (0x1F7) >= 0x80);//读取ATA设备的命令 outp(0x1F6, 0x0A0); outp(0x1F7, 0x10); while(inp (0x1F7) >= 0x80); if(inp (0x1F7) == 0x50) { outp(0x1F6, 0xA0);//读取ATAPI设备的命令 outp(0x1F7, 0xEC);//读取ATA设备的命令 while (inp (0x1F7) != 0x58); for (i=0; i< 256; i++) { pw = inpw(0x1F0); } __result = S_OK; } */ /*方法2 // wait controller ready // 0x1F7 status register ( READ ) // bit:0=1 command execute error // 1=1 index // 2=1 error exist, but corrected by ECC // 3=1 data request // 4=1 seek end // 5=1 write error // 6=1 driver ready // 7=1 busy // while ((al = inp (0x1F7)) >= 0x80);//读取ATA设备的命令 while (((al = inp (0x1F7)) & 0x50) != 0x50);//读取ATA设备的命令 // if ((al & 0x50) == 0x50) { // select fixed disk 0 or 1 // 0x1F6 Sector size/Driver header select register (WRITE) // bit:0-3 header select // 4=0 first disk, 1 second disk // 5-7 must be 101 outp(0x1F6, 0xA0);//读取ATAPI设备的命令 // 0x1F7 IDE command (WRITE) // 0001xxxx header to track 0 // 001000LR sector read // 001100LR sector write // 0100000R read verify // 01010000 format track // 0111xxxx seek // 10010000 diagnose // 10010001 parameter set // 11101100 read disk parameters (UNDOCUMENTED) // NOTE: L = 0 : normal, normal ECC, L = 1 : long status // R = 0 : error retry, R = 1 : no error retry outp(0x1F7, 0xEC);//读取ATA设备的命令(read disk parameters) } while (((al = inp (0x1F7)) & 0x58) != 0x58);//读取ATA设备的命令 // while ((al = inp (0x1F7)) >= 0x80);//读取ATA设备的命令 // if ((al & 0x58) == 0x58) { for (i=0; i< 256; i++) { pw = inpw(0x1F0); } __result = S_OK; } */ /*方法3 // while ((al = inp (0x1F7)) >= 0x80);//读取ATA设备的命令 // outp(0x1F6,0xA0); while ((al = inp (0x1F7)) >= 0x80);//读取ATA设备的命令 if ((al & 0x50) == 0x50) { outp(0x1F6, 0xA0);//读取ATAPI设备的命令 outp(0x1F7, 0xEC);//读取ATA设备的命令 while ((al = inp (0x1F7)) >= 0x80); if ((al & 0x58) == 0x58) { for (i=0; i< 256; i++) { pw = inpw(0x1F0); } } } */ |
|