//***************************************************************************** // //! This function performs a block read to an MSC device. //! //! \param psMSCInstance is the device instance to use for this read. //! \param ui32LBA is the logical block address to read on the device. //! \param pui8Data is a pointer to the returned data buffer. //! \param ui32NumBlocks is the number of blocks to read from the device. //! //! This function will perform a block sized read from the device associated //! with the \e psMSCInstance parameter. The \e ui32LBA parameter specifies //! the logical block address to read on the device. This function will only //! perform \e ui32NumBlocks block sized reads. In most cases this is a read //! of 512 bytes of data. The \e *pui8Data buffer should be at least //! \e ui32NumBlocks * 512 bytes in size. //! //! \return The function returns zero for success and any negative value //! indicates a failure. // //***************************************************************************** int32_t USBHMSCBlockRead(tUSBHMSCInstance *psMSCInstance, uint32_t ui32LBA, uint8_t *pui8Data, uint32_t ui32NumBlocks) { uint32_t ui32Size; // // If there is no device present then return an error. // if(psMSCInstance->psDevice == 0) { return(-1); } // // Calculate the actual byte size of the read. // ui32Size = psMSCInstance->ui32BlockSize * ui32NumBlocks; // // Perform the SCSI read command. // if(USBHSCSIRead10(psMSCInstance->ui32BulkInPipe, psMSCInstance->ui32BulkOutPipe, ui32LBA, pui8Data, &ui32Size, ui32NumBlocks) != SCSI_CMD_STATUS_PASS) { return(-1); } // // Success. // return(0); }
//***************************************************************************** // //! This function performs a block read to an MSC device. //! //! \param ulInstance is the device instance to use for this read. //! \param ulLBA is the logical block address to read on the device. //! \param pucData is a pointer to the returned data buffer. //! \param ulNumBlocks is the number of blocks to read from the device. //! //! This function will perform a block sized read from the device associated //! with the \e ulInstance parameter. The \e ulLBA parameter specifies the //! logical block address to read on the device. This function will only //! perform \e ulNumBlocks block sized reads. In most cases this is a read //! of 512 bytes of data. The \e *pucData buffer should be at least //! \e ulNumBlocks * 512 bytes in size. //! //! \return The function returns zero for success and any negative value //! indicates a failure. // //***************************************************************************** long USBHMSCBlockRead(unsigned long ulInstance, unsigned long ulLBA, unsigned char *pucData, unsigned long ulNumBlocks) { tUSBHMSCInstance *pMSCDevice; unsigned long ulSize; // // Get the instance pointer in a more usable form. // pMSCDevice = (tUSBHMSCInstance *)ulInstance; // // If there is no device present then return an error. // if(pMSCDevice->pDevice == 0) { return(-1); } // // Calculate the actual byte size of the read. // ulSize = pMSCDevice->ulBlockSize * ulNumBlocks; // // Perform the SCSI read command. // if(USBHSCSIRead10(pMSCDevice->ulBulkInPipe, pMSCDevice->ulBulkOutPipe, ulLBA, pucData, &ulSize, ulNumBlocks) != SCSI_CMD_STATUS_PASS) { return(-1); } // // Success. // return(0); }