This is my code:
Code: Select all
int HDD_find_drives(){
outb(0x1F3, 0x88);//Write some data to see if there are any drive
unsigned short status = inb(0x1F3);//Read the data
if(status & 0x88){//Compare with the data we write
printf("Drives detected");
outb(0x1F6, 0xA0);//Find primary Master
sleep(1);//Wait the device to be ready
unsigned short word = inb(0x1F7);//Read the data
if(word & 0x40){//If drive is present
printf("Primary Master detected\n");
}
outb(0x176, 0xB0);//Find primary Slave
sleep(1);//Whait the device to be ready
word = inb(0x177);//Read the data
if(word & 0x40){//If drive is present
printf("Primary Slave detected\n");
}
printf("LBA test completed\n");
}else{//No drives detected
printf("No drives detected\n");
}
return 1;
}