sources/common/libs/STM32Cube_F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c
/**
  * @brief  SCSI_Read10
  *         Process Read10 command
  * @param  lun: Logical unit number
  * @param  params: Command parameters
  * @retval status
  */
@brief  SCSI_Read10
Process Read10 command
@param  lun: Logical unit number
@param  params: Command parameters
@retval status
@brief SCSI_Read10 Process Read10 command @param lun : Logical unit number @param params : Command parameters @retval status
static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
{
  USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
  if (hmsc == NULL)
  {
    return -1;
  }
  if (hmsc->bot_state == USBD_BOT_IDLE) 
  {
    if ((hmsc->cbw.bmFlags & 0x80U) != 0x80U)
    {
      SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
      return -1;
    }
    if (hmsc->scsi_medium_state == SCSI_MEDIUM_EJECTED)
    {
      SCSI_SenseCode(pdev, lun, NOT_READY, MEDIUM_NOT_PRESENT);
      return -1;
    }
    if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->IsReady(lun) != 0)
    {
      SCSI_SenseCode(pdev, lun, NOT_READY, MEDIUM_NOT_PRESENT);
      return -1;
    }
    hmsc->scsi_blk_addr = ((uint32_t)params[2] << 24) |
                          ((uint32_t)params[3] << 16) |
                          ((uint32_t)params[4] <<  8) |
                          (uint32_t)params[5];
    hmsc->scsi_blk_len = ((uint32_t)params[7] <<  8) | (uint32_t)params[8];
    if (SCSI_CheckAddressRange(pdev, lun, hmsc->scsi_blk_addr,
                               hmsc->scsi_blk_len) < 0)
    {
      return -1; 
    }
    if (hmsc->cbw.dDataLength != (hmsc->scsi_blk_len * hmsc->scsi_blk_size))
    {
      SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
      return -1;
    }
    hmsc->bot_state = USBD_BOT_DATA_IN;
  }
  hmsc->bot_data_length = MSC_MEDIA_PACKET;
  return SCSI_ProcessRead(pdev, lun);
}
static int8_t SCSI_Read10 ( USBD_HandleTypeDef * pdev , uint8_t lun , uint8_t * params ) { USBD_MSC_BOT_HandleTypeDef * hmsc = ( USBD_MSC_BOT_HandleTypeDef * ) pdev -> pClassDataCmsit [ pdev -> classId ] ; if ( hmsc == NULL ) { return -1 ; } if ( hmsc -> bot_state == USBD_BOT_IDLE ) { if ( ( hmsc -> cbw . bmFlags & 0x80U ) != 0x80U ) { SCSI_SenseCode ( pdev , hmsc -> cbw . bLUN , ILLEGAL_REQUEST , INVALID_CDB ) ; return -1 ; } if ( hmsc -> scsi_medium_state == SCSI_MEDIUM_EJECTED ) { SCSI_SenseCode ( pdev , lun , NOT_READY , MEDIUM_NOT_PRESENT ) ; return -1 ; } if ( ( ( USBD_StorageTypeDef * ) pdev -> pUserData [ pdev -> classId ] ) -> IsReady ( lun ) != 0 ) { SCSI_SenseCode ( pdev , lun , NOT_READY , MEDIUM_NOT_PRESENT ) ; return -1 ; } hmsc -> scsi_blk_addr = ( ( uint32_t ) params [ 2 ] << 24 ) | ( ( uint32_t ) params [ 3 ] << 16 ) | ( ( uint32_t ) params [ 4 ] << 8 ) | ( uint32_t ) params [ 5 ] ; hmsc -> scsi_blk_len = ( ( uint32_t ) params [ 7 ] << 8 ) | ( uint32_t ) params [ 8 ] ; if ( SCSI_CheckAddressRange ( pdev , lun , hmsc -> scsi_blk_addr , hmsc -> scsi_blk_len ) < 0 ) { return -1 ; } if ( hmsc -> cbw . dDataLength != ( hmsc -> scsi_blk_len * hmsc -> scsi_blk_size ) ) { SCSI_SenseCode ( pdev , hmsc -> cbw . bLUN , ILLEGAL_REQUEST , INVALID_CDB ) ; return -1 ; } hmsc -> bot_state = USBD_BOT_DATA_IN ; } hmsc -> bot_data_length = MSC_MEDIA_PACKET ; return SCSI_ProcessRead ( pdev , lun ) ; }
@brief  SCSI_Read10
         Process Read10 command
 @param  lun: Logical unit number
 @param  params: Command parameters
 @retval status
@brief SCSI_Read10 Process Read10 command @param lun : Logical unit number @param params : Command parameters @retval status
/* Idle */ /* case 10 : Ho <> Di */ /* error */ /* cases 4,5 : Hi <> Dn */