Page 2 of 2
Re: ATA driver
Posted: Wed Feb 06, 2013 1:14 pm
by BMW
Combuster wrote:BMW wrote:Does anyone have anything helpful to say relating to my original question?
Eric S Raymond wrote:Most flames are best ignored — after you've checked whether they are really flames, not pointers to the ways in which you have screwed up, and not cleverly ciphered answers to your real question (this happens as well).
I did point out a bug there...
Yeah thanks...
Re: ATA driver
Posted: Wed Feb 13, 2013 1:18 pm
by bubach
I don't really have a problem with GOTO's - but couldn't help to notice how easily you could have solved this by just extracting parts of that code to a dataReady() function instead.
Re: ATA driver
Posted: Tue Feb 19, 2013 12:45 pm
by bewing
The main bug that I am seeing is how you are handling port 0x1f6.
You may have discovered already that you were not setting the (LBA28 mode = 0xe) top 3 bits of the port 0x1f6 byte.
Also,
Code: Select all
outportb(0x1F6, (LBA >> 24) & 0x0F); //bits 24-28 of LBA
ata_select_drive(0);
void ata_select_drive(uint8_t drive)
{
uint8_t buf = inportb(0x1F6);
if(drive)
buf |= 0x10; //set bit 4
buf = 0;
outportb(0x1F6, buf);
}
That last "buf = 0;" statement means that the last byte sent to port 0x1f6 is always 0, which is not what you want.
Also, if you fix that buf = 0; problem, your ata_select_drive command is depending on reading information back out of port 0x1f6. AFAIK, this will work (my memory is fuzzy on whether that is a fully functional read/write port), but it is always very slow. You already know what that byte should be set to, so you really don't need to read it back in.