* to the appropriate SCSI command handling routine if the issued command is supported by the device, else it returns\r
* a command failure due to a ILLEGAL REQUEST.\r
*\r
- * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
+ * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
*/\r
-bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_t* MSInterfaceInfo)\r
+bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)\r
{\r
bool CommandSuccess = false;\r
\r
/* Run the appropriate SCSI command hander function based on the passed command */\r
- switch (MSInterfaceInfo->CommandBlock.SCSICommandData[0])\r
+ switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])\r
{\r
case SCSI_CMD_INQUIRY:\r
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo); \r
case SCSI_CMD_VERIFY_10:\r
/* These commands should just succeed, no handling required */\r
CommandSuccess = true;\r
- MSInterfaceInfo->CommandBlock.DataTransferLength = 0;\r
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;\r
break;\r
default:\r
/* Update the SENSE key to reflect the invalid command */\r
/** Command processing for an issued SCSI INQUIRY command. This command returns information about the device's features\r
* and capabilities to the host.\r
*\r
- * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
+ * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
*\r
* \return Boolean true if the command completed successfully, false otherwise.\r
*/\r
-static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_t* MSInterfaceInfo)\r
+static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)\r
{\r
- uint16_t AllocationLength = (((uint16_t)MSInterfaceInfo->CommandBlock.SCSICommandData[3] << 8) |\r
- MSInterfaceInfo->CommandBlock.SCSICommandData[4]);\r
+ uint16_t AllocationLength = (((uint16_t)MSInterfaceInfo->State.CommandBlock.SCSICommandData[3] << 8) |\r
+ MSInterfaceInfo->State.CommandBlock.SCSICommandData[4]);\r
uint16_t BytesTransferred = (AllocationLength < sizeof(InquiryData))? AllocationLength :\r
sizeof(InquiryData);\r
\r
/* Only the standard INQUIRY data is supported, check if any optional INQUIRY bits set */\r
- if ((MSInterfaceInfo->CommandBlock.SCSICommandData[1] & ((1 << 0) | (1 << 1))) ||\r
- MSInterfaceInfo->CommandBlock.SCSICommandData[2])\r
+ if ((MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & ((1 << 0) | (1 << 1))) ||\r
+ MSInterfaceInfo->State.CommandBlock.SCSICommandData[2])\r
{\r
/* Optional but unsupported bits set - update the SENSE key and fail the request */\r
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,\r
Endpoint_ClearIN();\r
\r
/* Succeed the command and update the bytes transferred counter */\r
- MSInterfaceInfo->CommandBlock.DataTransferLength -= BytesTransferred;\r
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;\r
\r
return true;\r
}\r
/** Command processing for an issued SCSI REQUEST SENSE command. This command returns information about the last issued command,\r
* including the error code and additional error information so that the host can determine why a command failed to complete.\r
*\r
- * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
+ * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
*\r
* \return Boolean true if the command completed successfully, false otherwise.\r
*/\r
-static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_t* MSInterfaceInfo)\r
+static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)\r
{\r
- uint8_t AllocationLength = MSInterfaceInfo->CommandBlock.SCSICommandData[4];\r
+ uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];\r
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);\r
\r
uint8_t PadBytes[AllocationLength - BytesTransferred];\r
Endpoint_ClearIN();\r
\r
/* Succeed the command and update the bytes transferred counter */\r
- MSInterfaceInfo->CommandBlock.DataTransferLength -= BytesTransferred;\r
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;\r
\r
return true;\r
}\r
/** Command processing for an issued SCSI READ CAPACITY (10) command. This command returns information about the device's capacity\r
* on the selected Logical Unit (drive), as a number of OS-sized blocks.\r
*\r
- * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
+ * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
*\r
* \return Boolean true if the command completed successfully, false otherwise.\r
*/\r
-static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_t* MSInterfaceInfo)\r
+static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)\r
{\r
- uint32_t TotalLUNs = (LUN_MEDIA_BLOCKS - 1);\r
- uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE;\r
+ uint32_t LastBlockAddressInLUN = (LUN_MEDIA_BLOCKS - 1);\r
+ uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE;\r
\r
- Endpoint_Write_Stream_BE(&TotalLUNs, sizeof(TotalLUNs), NO_STREAM_CALLBACK);\r
+ Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);\r
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);\r
Endpoint_ClearIN();\r
\r
/* Succeed the command and update the bytes transferred counter */\r
- MSInterfaceInfo->CommandBlock.DataTransferLength -= 8;\r
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;\r
\r
return true;\r
}\r
* board, and indicates if they are present and functioning correctly. Only the Self-Test portion of the diagnostic command is\r
* supported.\r
*\r
- * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
+ * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
*\r
* \return Boolean true if the command completed successfully, false otherwise.\r
*/\r
-static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_t* MSInterfaceInfo)\r
+static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)\r
{\r
uint8_t ReturnByte;\r
\r
/* Check to see if the SELF TEST bit is not set */\r
- if (!(MSInterfaceInfo->CommandBlock.SCSICommandData[1] & (1 << 2)))\r
+ if (!(MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & (1 << 2)))\r
{\r
/* Only self-test supported - update SENSE key and fail the command */\r
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,\r
#endif\r
\r
/* Succeed the command and update the bytes transferred counter */\r
- MSInterfaceInfo->CommandBlock.DataTransferLength = 0;\r
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;\r
\r
return true;\r
}\r
* and total number of blocks to process, then calls the appropriate low-level dataflash routine to handle the actual\r
* reading and writing of the data.\r
*\r
- * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
- * \param IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)\r
+ * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with\r
+ * \param[in] IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)\r
*\r
* \return Boolean true if the command completed successfully, false otherwise.\r
*/\r
-static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_t* MSInterfaceInfo, const bool IsDataRead)\r
+static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const bool IsDataRead)\r
{\r
uint32_t BlockAddress;\r
uint16_t TotalBlocks;\r
\r
/* Load in the 32-bit block address (SCSI uses big-endian, so have to do it byte-by-byte) */\r
- ((uint8_t*)&BlockAddress)[3] = MSInterfaceInfo->CommandBlock.SCSICommandData[2];\r
- ((uint8_t*)&BlockAddress)[2] = MSInterfaceInfo->CommandBlock.SCSICommandData[3];\r
- ((uint8_t*)&BlockAddress)[1] = MSInterfaceInfo->CommandBlock.SCSICommandData[4];\r
- ((uint8_t*)&BlockAddress)[0] = MSInterfaceInfo->CommandBlock.SCSICommandData[5];\r
+ ((uint8_t*)&BlockAddress)[3] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[2];\r
+ ((uint8_t*)&BlockAddress)[2] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[3];\r
+ ((uint8_t*)&BlockAddress)[1] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];\r
+ ((uint8_t*)&BlockAddress)[0] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[5];\r
\r
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to do it byte-by-byte) */\r
- ((uint8_t*)&TotalBlocks)[1] = MSInterfaceInfo->CommandBlock.SCSICommandData[7];\r
- ((uint8_t*)&TotalBlocks)[0] = MSInterfaceInfo->CommandBlock.SCSICommandData[8];\r
+ ((uint8_t*)&TotalBlocks)[1] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[7];\r
+ ((uint8_t*)&TotalBlocks)[0] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[8];\r
\r
/* Check if the block address is outside the maximum allowable value for the LUN */\r
if (BlockAddress >= LUN_MEDIA_BLOCKS)\r
\r
#if (TOTAL_LUNS > 1)\r
/* Adjust the given block address to the real media address based on the selected LUN */\r
- BlockAddress += ((uint32_t)MSInterfaceInfo->CommandBlock.LUN * LUN_MEDIA_BLOCKS);\r
+ BlockAddress += ((uint32_t)MSInterfaceInfo->State.CommandBlock.LUN * LUN_MEDIA_BLOCKS);\r
#endif\r
\r
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */\r
DataflashManager_WriteBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);\r
\r
/* Update the bytes transferred counter and succeed the command */\r
- MSInterfaceInfo->CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);\r
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);\r
\r
return true;\r
}\r