Finding Sector Count with AHCI

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.
Post Reply
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Finding Sector Count with AHCI

Post 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?
My OS: TritiumOS
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Finding Sector Count with AHCI

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