Problems finding drive size with ATA Identify

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
SpaceDoge
Posts: 2
Joined: Tue May 11, 2021 1:34 am
Libera.chat IRC: spacedoge

Problems finding drive size with ATA Identify

Post by SpaceDoge »

A brief overview; I am using AHCI to write a driver and am currently stuck on trying to get the connected drives size. I can read and write to a drive, but it would be very helpful to know the size of the drive.

When I test my driver on real hardware with a 250GB drive the ATA identify command returns the max sector amount(137GB) as if it is a 28-bit LBA drive. And this is returned in words 230-233 "extended # of user addressable sectors" not in the 28-bit sector amount words(60-61). Also the 28-bit sector amount words(60-61) show 0x0007000. The last place for sector amount(100-103) shows 0. I know my drive has 48-bit support and the BIOS confirms this by showing the proper drive size. Also the drive was in this laptop before and completely functional in a Windows Vista installation.

The other interesting thing is that I noticed is the "48-bit address feature set is supported" bit in word 83 is set but the "48-bit address feature set is supported" in word 86 is not set. To me this means that it is supported but not enabled since 83 is labeled as features supported and 86 is labeled as features enabled.

I couldn't find any information about enabling 48-bit lba and decided to just ask this question on here. Does anyone know if there is a way to enable 48-bit lba or does anyone have an idea of what might be going on here?
Octocontrabass
Member
Member
Posts: 5543
Joined: Mon Mar 25, 2013 7:01 pm

Re: Problems finding drive size with ATA Identify

Post by Octocontrabass »

There's no way to disable 48-bit LBA. If the drive supports it, it's always enabled. My guess is it's some kind of memory corruption bug, since those values are all nonsense.

Have you tried dumping the whole IDENTIFY DEVICE data and comparing against what you see in another OS? (Using hdparm --Iraw/--Istdin under Linux, for example.)
SpaceDoge
Posts: 2
Joined: Tue May 11, 2021 1:34 am
Libera.chat IRC: spacedoge

Re: Problems finding drive size with ATA Identify

Post by SpaceDoge »

Thank you for the hdparm tip, I did not know about it. When running it I do get the correct number for everything.

I compared it's raw output to my raw output and they match exactly except for a couple nibbles that were slightly different. I think my structure must either be messed up or I am indexing words incorrectly.

Either way thank you so much showing me how to see the expected data compared to what I get. I think I can solve this issue now.
Post Reply