ATA PIO? [solved, sort of]
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
ATA PIO? [solved, sort of]
I looked at the LBA addressing/reading/writing tutorial at osedver.net and implemented it into my kernel. The only problem is, it doesn't write anything, or read. My main question is, what does it mean when I need to say what drive to read? Is that 0xA0/0xB0 or is it an actual drive indicator that I need to ask the hardware for?
Edit: never mind, I figured it out... My only question now is, why can't I write to a sparse image in Bochs and then view it in a hex-editor to test my read/write functions? I currently have to use a flat image and it's taking up 10 gig on my hard drive. Either I'll have to format my linux partition (which is almost dead anyway) or I'll have to somehow get sparse images working.
Edit: never mind, I figured it out... My only question now is, why can't I write to a sparse image in Bochs and then view it in a hex-editor to test my read/write functions? I currently have to use a flat image and it's taking up 10 gig on my hard drive. Either I'll have to format my linux partition (which is almost dead anyway) or I'll have to somehow get sparse images working.
As far as I know, the IDENTIFY DEVICE command returns all we need to know from an ATA device, and we can see there if LBA48 is implemented. LBA28 is always implemented in the most recent versions of hard disks (I think to have seen LBA disks from 1997 that support LBA). I don't know if those LBA disks support CHS operations.
Generally, if you execute directly a command and it's not supported, it will return ABRT bit set and other related data and in that case either you can give up or try another function (for example, if LBA48 didn't work and returned ABRT, you may test LBA28 or CHS, and so on). You'll need the older ATA (1?), ATA-2, ATA-3, ATA-4, ATA-5... specifications to find out how to use CHS disks, if you are sure that your read/write routines are correct (test them on real hardware).
Maybe this Bochs documentation helps somehow to figure out the "translation mode" used to address the disk image:
http://bochs.sourceforge.net/doc/docbook/user/bios-tips.html
Generally, if you execute directly a command and it's not supported, it will return ABRT bit set and other related data and in that case either you can give up or try another function (for example, if LBA48 didn't work and returned ABRT, you may test LBA28 or CHS, and so on). You'll need the older ATA (1?), ATA-2, ATA-3, ATA-4, ATA-5... specifications to find out how to use CHS disks, if you are sure that your read/write routines are correct (test them on real hardware).
Maybe this Bochs documentation helps somehow to figure out the "translation mode" used to address the disk image:
http://bochs.sourceforge.net/doc/docbook/user/bios-tips.html
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Ok... ATM I'm using LBA28.
I got all my information over at www.osdever.net - the LBA tutorial.
Does the IDENTIFY DEVICE command let me find out how big the drive is?
I got all my information over at www.osdever.net - the LBA tutorial.
Does the IDENTIFY DEVICE command let me find out how big the drive is?
You just need to write the same address ports several times, I don't remember if you must start with Most Significant or Least Significant, I better find the time to make a small tutorial on IDE; it's fairly complex.ces_mohab wrote:i use chs,lba28, using ports 01F0-01F7 or 0170-0178 for primary/secodary ide controller.
so my question is where are ports for 48bit lba?
But you must note that you need a disk bigger than ~138Mb; I personally use a 200GB disk to test my LBA48 code, because virtually any smaller disk supports it, that's not necessary anyway for them.
Last edited by ~ on Sat Mar 31, 2007 11:27 pm, edited 2 times in total.
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Try this tutorial, it teaches both LBA28 and LBA48 read/write via ports: LBA HDD Access via PIO~ wrote:You just need to write the same address ports several times, I don't remember if you must start with Most Significant or Least Significant, I better find the time to make a small tutorial on IDE; it's fairly complex.ces_mohab wrote:i use chs,lba28, using ports 01F0-01F7 or 0170-0178 for primary/secodary ide controller.
so my question is where are ports for 48bit lba?
But you must note that you need a disk bigger than ~138Mb; I personally use a 200GB disk to test my LBA48 code, because virtually any smaller disk supports it, that's not necessary anyway for them.