79549547

Date: 2025-04-02 02:42:11
Score: 0.5
Natty:
Report link

buddy! I am also developing an OS, its work is in progress. You can check it out in my github repo CodeVIP123. I can see your code is completely wrong. First, you have to reset the ATA by performing a soft reset:

outb(ATA_REG_CTRL, 0x06); // Write the soft reset bit onto the CTRL register (0x06)
for (int i = 0; i < 5; i++) {
    ata_wait_busy(); // Wait for the BSY bit to clear
    ata_wait_drq(); // Wait for DRQ bit to be set to 1
}

outb(ATA_REG_CTRL, 0x00); // Write the clear bit onto the CTRL register (0x3F6)


Then, in your IDENTIFY DEVICE logic, the specs are correct but where you have selected the drive? If you are using a primary device (Master) add this line:

outb(io + 6, 0xA0); // Write Master bit (0xA0) to the drive head (0x1F6)

If you are using a secondary device (Slave) add this line:

outb(io + 6, 0xB0); // Write the Slave bit (0xB0) to the drive head (0x1F6)

Then after it, you gotta wait for the BSY bit and the DRQ bit to be set. Use your wait function for that. After every operation, that is necessary.

Fell free to ask any other doubts.

Reasons:
  • Blacklisted phrase (0.5): check it out
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Ankur Cena