Yeah thanks...Combuster wrote:BMW wrote:Does anyone have anything helpful to say relating to my original question?I did point out a bug there...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).
ATA driver
Re: ATA driver
Currently developing Lithium OS (LiOS).
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Re: ATA driver
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
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,
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.
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);
}
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.