Exemple #1
0
// Process a SCSI command
// input:
//   pdev - pointer to the USB device handle
//   lun - logical unit number
//   params - pointer to the buffer with command parameters
int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params) {
	switch (params[0]) {
		case SCSI_TEST_UNIT_READY:
			return SCSI_TestUnitReady(pdev,lun,params);
		case SCSI_REQUEST_SENSE:
			return SCSI_RequestSense(pdev,lun,params);
		case SCSI_INQUIRY:
			return SCSI_Inquiry(pdev,lun,params);
		case SCSI_START_STOP_UNIT:
			return SCSI_StartStopUnit(pdev,lun,params);
		case SCSI_ALLOW_MEDIUM_REMOVAL:
			return SCSI_StartStopUnit(pdev,lun,params);
		case SCSI_MODE_SENSE6:
			return SCSI_ModeSense6(pdev,lun,params);
		case SCSI_MODE_SENSE10:
			return SCSI_ModeSense10(pdev,lun,params);
		case SCSI_READ_FORMAT_CAPACITIES:
			return SCSI_ReadFormatCapacity(pdev,lun,params);
		case SCSI_READ_CAPACITY10:
			return SCSI_ReadCapacity10(pdev,lun,params);
		case SCSI_READ10:
			return SCSI_Read10(pdev,lun,params);
		case SCSI_WRITE10:
			return SCSI_Write10(pdev,lun,params);
		case SCSI_VERIFY10:
			return SCSI_Verify10(pdev,lun,params);
		default:
			SCSI_SenseCode(pdev,lun,ILLEGAL_REQUEST,INVALID_CDB);
			return -1;
	}
}
Exemple #2
0
/**
* @brief  SCSI_ProcessCmd
*         Process SCSI commands
* @param  pdev: device instance
* @param  lun: Logical unit number
* @param  params: Command parameters
* @retval status
*/
int8_t SCSI_ProcessCmd(USBD_HandleTypeDef  *pdev,
                           uint8_t lun, 
                           uint8_t *params)
{
    /*
    if (params[0] != SCSI_READ10 && params[0] != SCSI_WRITE10) {
        printf("SCSI_ProcessCmd(lun=%d, params=%x, %x)\n", lun, params[0], params[1]);
    }
    */
  
  switch (params[0])
  {
  case SCSI_TEST_UNIT_READY:
    return SCSI_TestUnitReady(pdev, lun, params);
    
  case SCSI_REQUEST_SENSE:
    return SCSI_RequestSense (pdev, lun, params);
  case SCSI_INQUIRY:
    return SCSI_Inquiry(pdev, lun, params);
    
  case SCSI_START_STOP_UNIT:
    return SCSI_StartStopUnit(pdev, lun, params);
    
  case SCSI_ALLOW_MEDIUM_REMOVAL:
    return SCSI_AllowMediumRemoval(pdev, lun, params);
    
  case SCSI_MODE_SENSE6:
    return SCSI_ModeSense6 (pdev, lun, params);
    
  case SCSI_MODE_SENSE10:
    return SCSI_ModeSense10 (pdev, lun, params);
    
  case SCSI_SYNCHRONIZE_CACHE10:
  case SCSI_SYNCHRONIZE_CACHE16:
    return SCSI_SynchronizeCache(pdev, lun, params);

  case SCSI_READ_FORMAT_CAPACITIES:
    return SCSI_ReadFormatCapacity(pdev, lun, params);
    
  case SCSI_READ_CAPACITY10:
    return SCSI_ReadCapacity10(pdev, lun, params);
    
  case SCSI_READ10:
    return SCSI_Read10(pdev, lun, params); 
    
  case SCSI_WRITE10:
    return SCSI_Write10(pdev, lun, params);
    
  case SCSI_VERIFY10:
    return SCSI_Verify10(pdev, lun, params);
    
  default:
    SCSI_SenseCode(pdev, 
                   lun,
                   ILLEGAL_REQUEST, 
                   INVALID_CDB);    
    return -1;
  }
}