FreeBSD/sys/dev/isci/scil/sati_util.c
/**
 * @brief This method extracts the Logical Block Address high and low 32-bit
 *        values and the sector count 32-bit value from the ATA identify
 *        device data.
 *
 * @param[in]  identify This parameter specifies the ATA_IDENTIFY_DEVICE_DATA
 *             from which to extract the sector information.
 * @param[out] lba_high This parameter specifies the upper 32 bits for the
 *             number of logical block addresses for the device. The upper
 *             16-bits should always be 0, since 48-bits of LBA is the most
 *             supported by an ATA device.
 * @param[out] lba_low This parameter specifies the lower 32 bits for the
 *             number of logical block addresses for the device.
 * @param[out] sector_size This parameter specifies the 32-bits of sector
 *             size.  If the ATA device doesn't support reporting it's
 *             sector size, then 512 bytes is utilized as the default value.
 *
 * @return none
 */
@brief This method extracts the Logical Block Address high and low 32-bit
values and the sector count 32-bit value from the ATA identify
device data.

@param[in]  identify This parameter specifies the ATA_IDENTIFY_DEVICE_DATA
from which to extract the sector information.
@param[out] lba_high This parameter specifies the upper 32 bits for the
number of logical block addresses for the device. The upper
16-bits should always be 0, since 48-bits of LBA is the most
supported by an ATA device.
@param[out] lba_low This parameter specifies the lower 32 bits for the
number of logical block addresses for the device.
@param[out] sector_size This parameter specifies the 32-bits of sector
size.  If the ATA device doesn't support reporting it's
sector size, then 512 bytes is utilized as the default value.

@return none
@brief This method extracts the Logical Block Address high and low 32 - bit values and the sector count 32 - bit value from the ATA identify device data . @param [ in ] identify This parameter specifies the ATA_IDENTIFY_DEVICE_DATA from which to extract the sector information . @param [ out ] lba_high This parameter specifies the upper 32 bits for the number of logical block addresses for the device . The upper 16 - bits should always be 0 since 48 - bits of LBA is the most supported by an ATA device . @param [ out ] lba_low This parameter specifies the lower 32 bits for the number of logical block addresses for the device . @param [ out ] sector_size This parameter specifies the 32 - bits of sector size . If the ATA device doesn ' t support reporting it ' s sector size then 512 bytes is utilized as the default value . @return none
void sati_ata_identify_device_get_sector_info(
   ATA_IDENTIFY_DEVICE_DATA_T * identify,
   U32                        * lba_high,
   U32                        * lba_low,
   U32                        * sector_size
)
{
   if (identify->command_set_enabled1
       & ATA_IDENTIFY_COMMAND_SET_SUPPORTED1_48BIT_ENABLE)
   {
      *lba_high  = identify->max_48bit_lba[7] << 24;
      *lba_high |= identify->max_48bit_lba[6] << 16;
      *lba_high |= identify->max_48bit_lba[5] << 8;
      *lba_high |= identify->max_48bit_lba[4];
      *lba_low  = identify->max_48bit_lba[3] << 24;
      *lba_low |= identify->max_48bit_lba[2] << 16;
      *lba_low |= identify->max_48bit_lba[1] << 8;
      *lba_low |= identify->max_48bit_lba[0];
   }
   else
   {
      *lba_high  = 0;
      *lba_low   = identify->total_num_sectors[3] << 24;
      *lba_low  |= identify->total_num_sectors[2] << 16;
      *lba_low  |= identify->total_num_sectors[1] << 8;
      *lba_low  |= identify->total_num_sectors[0];
   }
   if (identify->physical_logical_sector_info
       & ATA_IDENTIFY_SECTOR_LARGER_THEN_512_ENABLE)
   {
      *sector_size  = identify->words_per_logical_sector[3] << 24;
      *sector_size |= identify->words_per_logical_sector[2] << 16;
      *sector_size |= identify->words_per_logical_sector[1] << 8;
      *sector_size |= identify->words_per_logical_sector[0];
   }
   else
   {
      *sector_size = 512;
   }
}
void sati_ata_identify_device_get_sector_info ( ATA_IDENTIFY_DEVICE_DATA_T * identify , U32 * lba_high , U32 * lba_low , U32 * sector_size ) { if ( identify -> command_set_enabled1 & ATA_IDENTIFY_COMMAND_SET_SUPPORTED1_48BIT_ENABLE ) { * lba_high = identify -> max_48bit_lba [ 7 ] << 24 ; * lba_high |= identify -> max_48bit_lba [ 6 ] << 16 ; * lba_high |= identify -> max_48bit_lba [ 5 ] << 8 ; * lba_high |= identify -> max_48bit_lba [ 4 ] ; * lba_low = identify -> max_48bit_lba [ 3 ] << 24 ; * lba_low |= identify -> max_48bit_lba [ 2 ] << 16 ; * lba_low |= identify -> max_48bit_lba [ 1 ] << 8 ; * lba_low |= identify -> max_48bit_lba [ 0 ] ; } else { * lba_high = 0 ; * lba_low = identify -> total_num_sectors [ 3 ] << 24 ; * lba_low |= identify -> total_num_sectors [ 2 ] << 16 ; * lba_low |= identify -> total_num_sectors [ 1 ] << 8 ; * lba_low |= identify -> total_num_sectors [ 0 ] ; } if ( identify -> physical_logical_sector_info & ATA_IDENTIFY_SECTOR_LARGER_THEN_512_ENABLE ) { * sector_size = identify -> words_per_logical_sector [ 3 ] << 24 ; * sector_size |= identify -> words_per_logical_sector [ 2 ] << 16 ; * sector_size |= identify -> words_per_logical_sector [ 1 ] << 8 ; * sector_size |= identify -> words_per_logical_sector [ 0 ] ; } else { * sector_size = 512 ; } }
@brief This method extracts the Logical Block Address high and low 32-bit
        values and the sector count 32-bit value from the ATA identify
        device data.
@brief This method extracts the Logical Block Address high and low 32 - bit values and the sector count 32 - bit value from the ATA identify device data .
// Calculate the values to be returned // Calculation will be different if the SATA device supports // 48-bit addressing.  Bit 10 of Word 86 of ATA Identify // This drive supports 48-bit addressing // This device doesn't support 48-bit addressing // Pull out the largest LBA from words 60 and 61. // If the ATA device reports its sector size (bit 12 of Word 106), // then use that instead. // Default the sector size to 512 bytes