Skip to content
  • Gabe Black's avatar
    ahci: Make the AHCI code find the capacity of disks > 128 GB properly · 19d1d41e
    Gabe Black authored
    
    
    In the structure returned by the ATA identify device command, there are two
    fields which describe the device capacity. One is a 32 bit data type which
    reports the number of sectors as a 28 bit LBA, and the other is a 64 bit data
    type which is for a 48 bit LBA. If the device doesn't support 48 bit LBAs,
    the small value is the only value with the correct size. If it supports more,
    if the number of sectors is small enough to fit into 28 bits, both fields
    reflect the correct value. If it's too large, the smaller field has 28 bits of
    1s, 0xfffffff, and the other field has the correct value.
    
    The AHCI driver is implemented by attaching to the generic SCSI code and
    translating on the fly between SCSI binary data structures and AHCI data
    structures. It responds to requests to execute specific SCSI commands by
    executing the equivalent AHCI commands and then crafting a response which
    matches what a SCSI disk would send.
    
    The AHCI driver now considers both fields and chooses the correct one when
    implementing both the SCSI READ CAPACITY (10) and READ CAPACITY (16) commands.
    
    Signed-off-by: default avatarGabe Black <gabeblack@chromium.org>
    Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
    19d1d41e