ATA driver

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: ATA driver

Post 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...
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: ATA driver

Post 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. :wink:
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: ATA driver

Post 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.
Post Reply