improve msc device
- change tud_msc_scsi_cb return type to simply bool - change tud_msc_write10_cb, tud_msc_read10_cb params order
This commit is contained in:
@@ -59,8 +59,8 @@ static scsi_inquiry_data_t const mscd_inquiry_data =
|
||||
|
||||
static scsi_read_capacity10_data_t const mscd_read_capacity10_data =
|
||||
{
|
||||
.last_lba = ENDIAN_BE(DISK_BLOCK_NUM-1), // read capacity
|
||||
.block_size = ENDIAN_BE(DISK_BLOCK_SIZE)
|
||||
.last_lba = ENDIAN_BE(DISK_BLOCK_NUM-1), // Big Endian
|
||||
.block_size = ENDIAN_BE(DISK_BLOCK_SIZE) // Big Endian
|
||||
};
|
||||
|
||||
static scsi_sense_fixed_data_t mscd_sense_data =
|
||||
@@ -99,7 +99,7 @@ void msc_app_umount(uint8_t rhport)
|
||||
|
||||
}
|
||||
|
||||
msc_csw_status_t tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t scsi_cmd[16], void* buffer, uint16_t* p_len)
|
||||
bool tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t scsi_cmd[16], void* buffer, uint16_t* p_len)
|
||||
{
|
||||
// read10 & write10 has their own callback and MUST not be handled here
|
||||
|
||||
@@ -145,13 +145,13 @@ msc_csw_status_t tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t scsi_cmd[
|
||||
|
||||
default:
|
||||
(*p_len) = 0;
|
||||
return MSC_CSW_STATUS_FAILED;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( bufptr && buflen )
|
||||
{
|
||||
// Response len must not larger than expected from host
|
||||
TU_ASSERT( (*p_len) >= buflen, MSC_CSW_STATUS_FAILED);
|
||||
TU_ASSERT( (*p_len) >= buflen );
|
||||
|
||||
memcpy(buffer, bufptr, buflen);
|
||||
(*p_len) = buflen;
|
||||
@@ -165,7 +165,7 @@ msc_csw_status_t tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t scsi_cmd[
|
||||
mscd_sense_data.additional_sense_qualifier = 0;
|
||||
}
|
||||
|
||||
return MSC_CSW_STATUS_PASSED;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
@@ -91,13 +91,13 @@ uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
|
||||
//--------------------------------------------------------------------+
|
||||
// IMPLEMENTATION
|
||||
//--------------------------------------------------------------------+
|
||||
uint16_t tud_msc_read10_cb (uint8_t rhport, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
|
||||
uint16_t tud_msc_read10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint16_t block_count, void** pp_buffer)
|
||||
{
|
||||
(*pp_buffer) = msc_device_ramdisk[lba];
|
||||
|
||||
return min16_of(block_count, DISK_BLOCK_NUM);
|
||||
}
|
||||
uint16_t tud_msc_write10_cb(uint8_t rhport, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
|
||||
uint16_t tud_msc_write10_cb(uint8_t rhport, uint8_t lun, uint32_t lba, uint16_t block_count, void** pp_buffer)
|
||||
{
|
||||
(*pp_buffer) = msc_device_ramdisk[lba];
|
||||
|
||||
|
@@ -97,7 +97,7 @@ static uint8_t sector_buffer[DISK_BLOCK_SIZE];
|
||||
//--------------------------------------------------------------------+
|
||||
// IMPLEMENTATION
|
||||
//--------------------------------------------------------------------+
|
||||
uint16_t tusbd_msc_read10_cb (uint8_t rhport, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
|
||||
uint16_t tusbd_msc_read10_cb (uint8_t rhport, uint8_t lun, uint32_t lba, uint16_t block_count, void** pp_buffer)
|
||||
{
|
||||
memcpy(sector_buffer, msc_device_app_rommdisk[lba], DISK_BLOCK_SIZE);
|
||||
(*pp_buffer) = sector_buffer;
|
||||
@@ -106,7 +106,7 @@ uint16_t tusbd_msc_read10_cb (uint8_t rhport, uint8_t lun, void** pp_buffer, uin
|
||||
}
|
||||
|
||||
// Stall write10 by return 0, as this is readonly disk
|
||||
uint16_t tusbd_msc_write10_cb(uint8_t rhport, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
|
||||
uint16_t tusbd_msc_write10_cb(uint8_t rhport, uint8_t lun, uint32_t lba, uint16_t block_count, void** pp_buffer)
|
||||
{
|
||||
(*pp_buffer) = NULL;
|
||||
|
||||
|
Reference in New Issue
Block a user