ATA Identify Device
ATA Identify Device
Hi All. Im attempting to write an ATA device driver and im having issues with the Identify Device command. Im just trying to get a sector count of connected drives. I read through the specs and all but it just isnt adding up. I dont have the code in front of me but It stats like bytes 59 and 60 are suppose to give the sector count. When I multiply this number I get by 512... (512 bytes per sector) The result is no where near the correct value of the disk size. Any idea what im doing wrong?
What size is the disk, and what values are you getting?
If you are getting too small values for a large disk, there are various limit at various BIOS and such which cause you to get limited sizes.
Disk size with traditional addressing is cylinders*heads*sectors*blocksize, and without having bothered with ATA yet, I can tell that LBA32 or LBA48 addressing won't fit in 2 bytes... so get the cylinders and heads as well, or switch to LBA.
If you are getting too small values for a large disk, there are various limit at various BIOS and such which cause you to get limited sizes.
Disk size with traditional addressing is cylinders*heads*sectors*blocksize, and without having bothered with ATA yet, I can tell that LBA32 or LBA48 addressing won't fit in 2 bytes... so get the cylinders and heads as well, or switch to LBA.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
or if you use gcc + extensions use:Aali wrote:i know its not standard, but you could use long long, which is guaranteed to be atleast 64 bits
Code: Select all
typedef signed int64s __attribute__((mode(DI)));
Author of COBOS
-
- 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:
It's not a byte count. It's a sector count. In other words, the 'byte count' is:well if I cant use double what would be appropriate? a 32bit integer isnt large enough to hold a byte count.
Code: Select all
2^32 * (byts_per_sec)
The hardware has no notion of 'bytes per sector', it's giving you the count of sectors on the disk.
Edit: so far, desktop OS's don't have to handle anything more than really 500 GB... Once drive sizes are > 2 TB the whole ATA specification will have to be redone. Can't wait
Hi,
The current ATA specification already has support for 48-bit LBA addressing and 48-bit total number of sectors (see "words(103:100)" or the 8 bytes at offset 0xC8 in the "Identify Device" data structure). They won't need to change things until we reach 131072 TiB disks.
Even then the existing "Identify Device" data structure could easily handle a 64-bit total number of sectors, and the existing functions for 48-bit LBA could be extended to 52-bit LBA by defining 4 reserved flags.
Cheers,
Brendan
Fortunately, you don't need to wait...pcmattman wrote:Edit: so far, desktop OS's don't have to handle anything more than really 500 GB... Once drive sizes are > 2 TB the whole ATA specification will have to be redone. Can't wait
The current ATA specification already has support for 48-bit LBA addressing and 48-bit total number of sectors (see "words(103:100)" or the 8 bytes at offset 0xC8 in the "Identify Device" data structure). They won't need to change things until we reach 131072 TiB disks.
Even then the existing "Identify Device" data structure could easily handle a 64-bit total number of sectors, and the existing functions for 48-bit LBA could be extended to 52-bit LBA by defining 4 reserved flags.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.