Update Atmel Studio blob - use sane method to extract the extension's bundled Getting...
[pub/USBasp.git] / Bootloaders / MassStorage / Lib / SCSI.c
index 0bb1c7a..eeb2c25 100644 (file)
@@ -86,7 +86,7 @@ static SCSI_Request_Sense_Response_t SenseData =
  *
  *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface structure that the command is associated with
  *
- *  \return Boolean true if the command completed successfully, false otherwise
+ *  \return Boolean \c true if the command completed successfully, \c false otherwise
  */
 bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
 {
@@ -148,7 +148,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
  *
  *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface structure that the command is associated with
  *
- *  \return Boolean true if the command completed successfully, false otherwise.
+ *  \return Boolean \c true if the command completed successfully, \c false otherwise.
  */
 static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
 {
@@ -186,7 +186,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
  *
  *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface structure that the command is associated with
  *
- *  \return Boolean true if the command completed successfully, false otherwise.
+ *  \return Boolean \c true if the command completed successfully, \c false otherwise.
  */
 static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
 {
@@ -208,15 +208,12 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
  *
  *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface structure that the command is associated with
  *
- *  \return Boolean true if the command completed successfully, false otherwise.
+ *  \return Boolean \c true if the command completed successfully, \c false otherwise.
  */
 static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
 {
-       uint32_t LastBlockAddressInLUN = (LUN_MEDIA_BLOCKS - 1);
-       uint32_t MediaBlockSize        = SECTOR_SIZE_BYTES;
-
-       Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NULL);
-       Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NULL);
+       Endpoint_Write_32_BE(LUN_MEDIA_BLOCKS - 1);
+       Endpoint_Write_32_BE(SECTOR_SIZE_BYTES);
        Endpoint_ClearIN();
 
        /* Succeed the command and update the bytes transferred counter */
@@ -232,12 +229,12 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
  *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface structure that the command is associated with
  *  \param[in] IsDataRead  Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)
  *
- *  \return Boolean true if the command completed successfully, false otherwise.
+ *  \return Boolean \c true if the command completed successfully, \c false otherwise.
  */
 static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
                                       const bool IsDataRead)
 {
-       uint32_t BlockAddress;
+       uint16_t BlockAddress;
        uint16_t TotalBlocks;
 
        /* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
@@ -258,10 +255,13 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
        }
 
        /* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
-       if (IsDataRead == DATA_READ)
-         VirtualFAT_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
-       else
-         VirtualFAT_WriteBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
+       for (uint16_t i = 0; i < TotalBlocks; i++)
+       {
+               if (IsDataRead == DATA_READ)
+                 VirtualFAT_ReadBlock(BlockAddress + i);
+               else
+                 VirtualFAT_WriteBlock(BlockAddress + i);
+       }
 
        /* Update the bytes transferred counter and succeed the command */
        MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * SECTOR_SIZE_BYTES);
@@ -274,7 +274,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
  *
  *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface structure that the command is associated with
  *
- *  \return Boolean true if the command completed successfully, false otherwise.
+ *  \return Boolean \c true if the command completed successfully, \c false otherwise.
  */
 static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
 {