Page 1 of 1

Finding Sector Count with AHCI

Posted: Tue Nov 24, 2020 8:45 pm
by foliagecanine
Hello.
I've had a minimal AHCI driver for a while, but I still haven't come across anything that talks about how you would get the count of the sectors of the disk.
The closest I've come is [this thread] about the ATA IDENTIFY command, but it seems like there is only one 32-bit spot for the sector count:

Code: Select all

...
      unsigned int   lba_capacity;   /* total number of sectors */
...
However, this would limit hard disks to 2TB max. Obviously, modern AHCI is capable of addressing much more than just 2TB.

I've tried looking in the manual for "capacity" or "sector count" but turned up nothing.

Am I misinterpreting the IDENTIFY response? Is that the correct spot for the capacity, or is there another spot that I've overlooked that allows for more than 2TB?

Re: Finding Sector Count with AHCI

Posted: Tue Nov 24, 2020 9:20 pm
by Octocontrabass
You're looking for words 100 through 103 of the IDENTIFY DEVICE data.

You probably didn't find anything because it's called "Maximum user LBA for 48-bit Address feature set" or "Total Number of User Addressable Sectors for the 48-bit Address feature set" or "Total Number of User Addressable Logical Sectors for 48-bit commands" or "Number of User Addressable Logical Sectors" in the various ATA specification drafts I can find.