3 Copyright (C) Dean Camera, 2011.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
33 * Mass Storage Device commands, to issue MSD commands to the device for
34 * reading device status, capacity, and other characteristics. This file
35 * also contains block read and write functions, so that device blocks
36 * can be read and written. In general, these functions would be chained
37 * to a FAT library to give file-level access to an attached device's contents.
39 * \note Many Mass Storage devices on the market are non-compliant to the
40 * specifications and thus can prove difficult to interface with. It
41 * may be necessary to retry the functions in the module several times
42 * after they have returned and error to successfully send the command
43 * to the device. Some devices may also need to have the stream function
44 * timeout period extended beyond 100ms (some badly designed devices exceeding
45 * 1.5 seconds occasionally) by defining USB_STREAM_TIMEOUT_MS to a
46 * larger value in the project makefile and passing it to the compiler
50 #define INCLUDE_FROM_MASSSTORE_COMMANDS_C
51 #include "MassStoreCommands.h"
53 /** Current Tag value used in issued CBWs to the device. This is automatically incremented
54 * each time a command is sent, and is not externally accessible.
56 static uint32_t MassStore_Tag
= 1;
59 /** Routine to send the current CBW to the device, and increment the Tag value as needed.
61 * \param[in] SCSICommandBlock Pointer to a SCSI command block structure to send to the attached device
62 * \param[in,out] BufferPtr Pointer to a buffer for the data to send or receive to/from the device, or NULL if no data
64 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum
66 static uint8_t MassStore_SendCommand(MS_CommandBlockWrapper_t
* const SCSICommandBlock
,
69 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
71 /* Each transmission should have a unique tag value, increment before use */
72 SCSICommandBlock
->Tag
= ++MassStore_Tag
;
74 /* Wrap Tag value when invalid - MS class defines tag values of 0 and 0xFFFFFFFF to be invalid */
75 if (MassStore_Tag
== 0xFFFFFFFF)
78 /* Select the OUT data pipe for CBW transmission */
79 Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE
);
82 /* Write the CBW command to the OUT pipe */
83 if ((ErrorCode
= Pipe_Write_Stream_LE(SCSICommandBlock
, sizeof(MS_CommandBlockWrapper_t
))) != PIPE_RWSTREAM_NoError
)
86 /* Send the data in the OUT pipe to the attached device */
89 /* Wait until command has been sent */
90 Pipe_WaitUntilReady();
92 /* Freeze pipe after use */
95 /* Send data if any */
96 if ((BufferPtr
!= NULL
) &&
97 ((ErrorCode
= MassStore_SendReceiveData(SCSICommandBlock
, BufferPtr
)) != PIPE_READYWAIT_NoError
))
106 /** Waits until the attached device is ready to accept data following a CBW, checking
107 * to ensure that the device has not stalled the transaction.
109 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum
111 static uint8_t MassStore_WaitForDataReceived(void)
113 uint16_t TimeoutMSRem
= COMMAND_DATA_TIMEOUT_MS
;
114 uint16_t PreviousFrameNumber
= USB_Host_GetFrameNumber();
116 /* Select the IN data pipe for data reception */
117 Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE
);
120 /* Wait until data received in the IN pipe */
121 while (!(Pipe_IsINReceived()))
123 uint16_t CurrentFrameNumber
= USB_Host_GetFrameNumber();
125 /* Check to see if a new frame has been issued (1ms elapsed) */
126 if (CurrentFrameNumber
!= PreviousFrameNumber
)
128 /* Save the new frame number and decrement the timeout period */
129 PreviousFrameNumber
= CurrentFrameNumber
;
132 /* Check to see if the timeout period for the command has elapsed */
134 return PIPE_RWSTREAM_Timeout
;
138 Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE
);
141 /* Check if pipe stalled (command failed by device) */
142 if (Pipe_IsStalled())
144 /* Clear the stall condition on the OUT pipe */
145 USB_Host_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE
);
147 return PIPE_RWSTREAM_PipeStalled
;
151 Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE
);
154 /* Check if pipe stalled (command failed by device) */
155 if (Pipe_IsStalled())
157 /* Clear the stall condition on the IN pipe */
158 USB_Host_ClearPipeStall(MASS_STORE_DATA_IN_PIPE
);
160 return PIPE_RWSTREAM_PipeStalled
;
163 /* Check to see if the device was disconnected, if so exit function */
164 if (USB_HostState
== HOST_STATE_Unattached
)
165 return PIPE_RWSTREAM_DeviceDisconnected
;
168 Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE
);
171 Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE
);
174 return PIPE_RWSTREAM_NoError
;
177 /** Sends or receives the transaction's data stage to or from the attached device, reading or
178 * writing to the nominated buffer.
180 * \param[in] SCSICommandBlock Pointer to a SCSI command block structure being sent to the attached device
181 * \param[in,out] BufferPtr Pointer to the data buffer to read from or write to
183 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum
185 static uint8_t MassStore_SendReceiveData(MS_CommandBlockWrapper_t
* const SCSICommandBlock
,
188 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
189 uint16_t BytesRem
= SCSICommandBlock
->DataTransferLength
;
191 /* Check the direction of the SCSI command data stage */
192 if (SCSICommandBlock
->Flags
& MS_COMMAND_DIR_DATA_IN
)
194 /* Wait until the device has replied with some data */
195 if ((ErrorCode
= MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_NoError
)
198 /* Select the IN data pipe for data reception */
199 Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE
);
202 /* Read in the block data from the pipe */
203 if ((ErrorCode
= Pipe_Read_Stream_LE(BufferPtr
, BytesRem
)) != PIPE_RWSTREAM_NoError
)
206 /* Acknowledge the packet */
211 /* Select the OUT data pipe for data transmission */
212 Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE
);
215 /* Write the block data to the pipe */
216 if ((ErrorCode
= Pipe_Write_Stream_LE(BufferPtr
, BytesRem
)) != PIPE_RWSTREAM_NoError
)
219 /* Acknowledge the packet */
222 while (!(Pipe_IsOUTReady()))
224 if (USB_HostState
== HOST_STATE_Unattached
)
225 return PIPE_RWSTREAM_DeviceDisconnected
;
229 /* Freeze used pipe after use */
232 return PIPE_RWSTREAM_NoError
;
235 /** Routine to receive the current CSW from the device.
237 * \param[out] SCSICommandStatus Pointer to a destination where the returned status data should be stored
239 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
241 static uint8_t MassStore_GetReturnedStatus(MS_CommandStatusWrapper_t
* const SCSICommandStatus
)
243 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
245 /* If an error in the command occurred, abort */
246 if ((ErrorCode
= MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_NoError
)
249 /* Select the IN data pipe for data reception */
250 Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE
);
253 /* Load in the CSW from the attached device */
254 if ((ErrorCode
= Pipe_Read_Stream_LE(SCSICommandStatus
, sizeof(MS_CommandStatusWrapper_t
))) != PIPE_RWSTREAM_NoError
)
257 /* Clear the data ready for next reception */
260 /* Freeze the IN pipe after use */
263 /* Check to see if command failed */
264 if (SCSICommandStatus
->Status
!= MS_SCSI_COMMAND_Pass
)
265 ErrorCode
= MASS_STORE_SCSI_COMMAND_FAILED
;
270 /** Issues a Mass Storage class specific request to reset the attached device's Mass Storage interface,
271 * readying the device for the next CBW.
273 * \return A value from the USB_Host_SendControlErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
275 uint8_t MassStore_MassStorageReset(void)
277 USB_ControlRequest
= (USB_Request_Header_t
)
279 .bmRequestType
= (REQDIR_HOSTTODEVICE
| REQTYPE_CLASS
| REQREC_INTERFACE
),
280 .bRequest
= MS_REQ_MassStorageReset
,
286 /* Select the control pipe for the request transfer */
287 Pipe_SelectPipe(PIPE_CONTROLPIPE
);
289 return USB_Host_SendControlRequest(NULL
);
292 /** Issues a Mass Storage class specific request to determine the index of the highest numbered Logical
293 * Unit in the attached device.
295 * \note Some devices do not support this request, and will STALL it when issued. To get around this,
296 * on unsupported devices the max LUN index will be reported as zero and no error will be returned
297 * if the device STALLs the request.
299 * \param[out] MaxLUNIndex Pointer to the location that the maximum LUN index value should be stored
301 * \return A value from the USB_Host_SendControlErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
303 uint8_t MassStore_GetMaxLUN(uint8_t* const MaxLUNIndex
)
305 uint8_t ErrorCode
= HOST_SENDCONTROL_Successful
;
307 USB_ControlRequest
= (USB_Request_Header_t
)
309 .bmRequestType
= (REQDIR_DEVICETOHOST
| REQTYPE_CLASS
| REQREC_INTERFACE
),
310 .bRequest
= MS_REQ_GetMaxLUN
,
316 /* Select the control pipe for the request transfer */
317 Pipe_SelectPipe(PIPE_CONTROLPIPE
);
319 if ((ErrorCode
= USB_Host_SendControlRequest(MaxLUNIndex
)) == HOST_SENDCONTROL_SetupStalled
)
321 /* Clear the pipe stall */
324 /* Some faulty Mass Storage devices don't implement the GET_MAX_LUN request, so assume a single LUN */
327 /* Clear the error, and pretend the request executed correctly if the device STALLed it */
328 ErrorCode
= HOST_SENDCONTROL_Successful
;
334 /** Issues a SCSI Inquiry command to the attached device, to determine the device's information. This
335 * gives information on the device's capabilities.
337 * \param[in] LUNIndex Index of the LUN inside the device the command is being addressed to
338 * \param[out] InquiryPtr Pointer to the inquiry data structure where the inquiry data from the device is to be stored
340 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
342 uint8_t MassStore_Inquiry(const uint8_t LUNIndex
,
343 SCSI_Inquiry_Response_t
* const InquiryPtr
)
345 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
347 /* Create a CBW with a SCSI command to issue INQUIRY command */
348 MS_CommandBlockWrapper_t SCSICommandBlock
= (MS_CommandBlockWrapper_t
)
350 .Signature
= MS_CBW_SIGNATURE
,
351 .DataTransferLength
= sizeof(SCSI_Inquiry_Response_t
),
352 .Flags
= MS_COMMAND_DIR_DATA_IN
,
354 .SCSICommandLength
= 6,
361 sizeof(SCSI_Inquiry_Response_t
), // Allocation Length
362 0x00 // Unused (control)
366 MS_CommandStatusWrapper_t SCSICommandStatus
;
368 /* Send the command and any data to the attached device */
369 if ((ErrorCode
= MassStore_SendCommand(&SCSICommandBlock
, InquiryPtr
)) != PIPE_RWSTREAM_NoError
)
375 /* Retrieve status information from the attached device */
376 if ((ErrorCode
= MassStore_GetReturnedStatus(&SCSICommandStatus
)) != PIPE_RWSTREAM_NoError
)
385 /** Issues a SCSI Request Sense command to the attached device, to determine the current SCSI sense information. This
386 * gives error codes for the last issued SCSI command to the device.
388 * \param[in] LUNIndex Index of the LUN inside the device the command is being addressed to
389 * \param[out] SensePtr Pointer to the sense data structure where the sense data from the device is to be stored
391 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
393 uint8_t MassStore_RequestSense(const uint8_t LUNIndex
,
394 SCSI_Request_Sense_Response_t
* const SensePtr
)
396 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
398 /* Create a CBW with a SCSI command to issue REQUEST SENSE command */
399 MS_CommandBlockWrapper_t SCSICommandBlock
= (MS_CommandBlockWrapper_t
)
401 .Signature
= MS_CBW_SIGNATURE
,
402 .DataTransferLength
= sizeof(SCSI_Request_Sense_Response_t
),
403 .Flags
= MS_COMMAND_DIR_DATA_IN
,
405 .SCSICommandLength
= 6,
408 SCSI_CMD_REQUEST_SENSE
,
412 sizeof(SCSI_Request_Sense_Response_t
), // Allocation Length
413 0x00 // Unused (control)
417 MS_CommandStatusWrapper_t SCSICommandStatus
;
419 /* Send the command and any data to the attached device */
420 if ((ErrorCode
= MassStore_SendCommand(&SCSICommandBlock
, SensePtr
)) != PIPE_RWSTREAM_NoError
)
426 /* Retrieve status information from the attached device */
427 if ((ErrorCode
= MassStore_GetReturnedStatus(&SCSICommandStatus
)) != PIPE_RWSTREAM_NoError
)
436 /** Issues a SCSI Device Block Read command to the attached device, to read in one or more data blocks from the
437 * storage medium into a buffer.
439 * \param[in] LUNIndex Index of the LUN inside the device the command is being addressed to
440 * \param[in] BlockAddress Start block address to read from
441 * \param[in] Blocks Number of blocks to read from the device
442 * \param[in] BlockSize Size in bytes of each block to read
443 * \param[out] BufferPtr Pointer to the buffer where the read data is to be written to
445 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
447 uint8_t MassStore_ReadDeviceBlock(const uint8_t LUNIndex
,
448 const uint32_t BlockAddress
,
449 const uint8_t Blocks
,
450 const uint16_t BlockSize
,
453 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
455 /* Create a CBW with a SCSI command to read in the given blocks from the device */
456 MS_CommandBlockWrapper_t SCSICommandBlock
= (MS_CommandBlockWrapper_t
)
458 .Signature
= MS_CBW_SIGNATURE
,
459 .DataTransferLength
= ((uint32_t)Blocks
* BlockSize
),
460 .Flags
= MS_COMMAND_DIR_DATA_IN
,
462 .SCSICommandLength
= 10,
466 0x00, // Unused (control bits, all off)
467 (BlockAddress
>> 24), // MSB of Block Address
468 (BlockAddress
>> 16),
470 (BlockAddress
& 0xFF), // LSB of Block Address
472 0x00, // MSB of Total Blocks to Read
473 Blocks
, // LSB of Total Blocks to Read
474 0x00 // Unused (control)
478 MS_CommandStatusWrapper_t SCSICommandStatus
;
480 /* Send the command and any data to the attached device */
481 if ((ErrorCode
= MassStore_SendCommand(&SCSICommandBlock
, BufferPtr
)) != PIPE_RWSTREAM_NoError
)
487 /* Retrieve status information from the attached device */
488 if ((ErrorCode
= MassStore_GetReturnedStatus(&SCSICommandStatus
)) != PIPE_RWSTREAM_NoError
)
497 /** Issues a SCSI Device Block Write command to the attached device, to write one or more data blocks to the
498 * storage medium from a buffer.
500 * \param[in] LUNIndex Index of the LUN inside the device the command is being addressed to
501 * \param[in] BlockAddress Start block address to write to
502 * \param[in] Blocks Number of blocks to write to in the device
503 * \param[in] BlockSize Size in bytes of each block to write
504 * \param[in] BufferPtr Pointer to the buffer where the write data is to be sourced from
506 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
508 uint8_t MassStore_WriteDeviceBlock(const uint8_t LUNIndex
,
509 const uint32_t BlockAddress
,
510 const uint8_t Blocks
,
511 const uint16_t BlockSize
,
514 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
516 /* Create a CBW with a SCSI command to write the given blocks to the device */
517 MS_CommandBlockWrapper_t SCSICommandBlock
= (MS_CommandBlockWrapper_t
)
519 .Signature
= MS_CBW_SIGNATURE
,
520 .DataTransferLength
= ((uint32_t)Blocks
* BlockSize
),
521 .Flags
= MS_COMMAND_DIR_DATA_OUT
,
523 .SCSICommandLength
= 10,
527 0x00, // Unused (control bits, all off)
528 (BlockAddress
>> 24), // MSB of Block Address
529 (BlockAddress
>> 16),
531 (BlockAddress
& 0xFF), // LSB of Block Address
532 0x00, // Unused (reserved)
533 0x00, // MSB of Total Blocks to Write
534 Blocks
, // LSB of Total Blocks to Write
535 0x00 // Unused (control)
539 MS_CommandStatusWrapper_t SCSICommandStatus
;
541 /* Send the command and any data to the attached device */
542 if ((ErrorCode
= MassStore_SendCommand(&SCSICommandBlock
, BufferPtr
)) != PIPE_RWSTREAM_NoError
)
548 /* Retrieve status information from the attached device */
549 if ((ErrorCode
= MassStore_GetReturnedStatus(&SCSICommandStatus
)) != PIPE_RWSTREAM_NoError
)
558 /** Issues a SCSI Device Test Unit Ready command to the attached device, to determine if the device is ready to accept
561 * \param[in] LUNIndex Index of the LUN inside the device the command is being addressed to
563 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
565 uint8_t MassStore_TestUnitReady(const uint8_t LUNIndex
)
567 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
569 /* Create a CBW with a SCSI command to issue TEST UNIT READY command */
570 MS_CommandBlockWrapper_t SCSICommandBlock
= (MS_CommandBlockWrapper_t
)
572 .Signature
= MS_CBW_SIGNATURE
,
573 .DataTransferLength
= 0,
574 .Flags
= MS_COMMAND_DIR_DATA_IN
,
576 .SCSICommandLength
= 6,
579 SCSI_CMD_TEST_UNIT_READY
,
584 0x00 // Unused (control)
588 MS_CommandStatusWrapper_t SCSICommandStatus
;
590 /* Send the command and any data to the attached device */
591 if ((ErrorCode
= MassStore_SendCommand(&SCSICommandBlock
, NULL
)) != PIPE_RWSTREAM_NoError
)
597 /* Retrieve status information from the attached device */
598 if ((ErrorCode
= MassStore_GetReturnedStatus(&SCSICommandStatus
)) != PIPE_RWSTREAM_NoError
)
607 /** Issues a SCSI Device Read Capacity command to the attached device, to determine the capacity of the
608 * given Logical Unit within the device.
610 * \param[in] LUNIndex Index of the LUN inside the device the command is being addressed to
611 * \param[out] CapacityPtr Device capacity structure where the capacity data is to be stored
613 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
615 uint8_t MassStore_ReadCapacity(const uint8_t LUNIndex
,
616 SCSI_Capacity_t
* const CapacityPtr
)
618 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
620 /* Create a CBW with a SCSI command to issue READ CAPACITY command */
621 MS_CommandBlockWrapper_t SCSICommandBlock
= (MS_CommandBlockWrapper_t
)
623 .Signature
= MS_CBW_SIGNATURE
,
624 .DataTransferLength
= sizeof(SCSI_Capacity_t
),
625 .Flags
= MS_COMMAND_DIR_DATA_IN
,
627 .SCSICommandLength
= 10,
630 SCSI_CMD_READ_CAPACITY_10
,
632 0x00, // MSB of Logical block address
635 0x00, // LSB of Logical block address
638 0x00, // Partial Medium Indicator
639 0x00 // Unused (control)
643 MS_CommandStatusWrapper_t SCSICommandStatus
;
645 /* Send the command and any data to the attached device */
646 if ((ErrorCode
= MassStore_SendCommand(&SCSICommandBlock
, CapacityPtr
)) != PIPE_RWSTREAM_NoError
)
652 /* Endian-correct the read data */
653 CapacityPtr
->Blocks
= SwapEndian_32(CapacityPtr
->Blocks
);
654 CapacityPtr
->BlockSize
= SwapEndian_32(CapacityPtr
->BlockSize
);
656 /* Retrieve status information from the attached device */
657 if ((ErrorCode
= MassStore_GetReturnedStatus(&SCSICommandStatus
)) != PIPE_RWSTREAM_NoError
)
666 /** Issues a SCSI Device Prevent/Allow Medium Removal command to the attached device, to lock the physical media from
667 * being removed. This is a legacy command for SCSI disks with removable storage (such as ZIP disks), but should still
668 * be issued before the first read or write command is sent.
670 * \param[in] LUNIndex Index of the LUN inside the device the command is being addressed to
671 * \param[in] PreventRemoval Whether or not the LUN media should be locked to prevent removal or not
673 * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails
675 uint8_t MassStore_PreventAllowMediumRemoval(const uint8_t LUNIndex
,
676 const bool PreventRemoval
)
678 uint8_t ErrorCode
= PIPE_RWSTREAM_NoError
;
680 /* Create a CBW with a SCSI command to issue PREVENT ALLOW MEDIUM REMOVAL command */
681 MS_CommandBlockWrapper_t SCSICommandBlock
= (MS_CommandBlockWrapper_t
)
683 .Signature
= MS_CBW_SIGNATURE
,
684 .DataTransferLength
= 0,
685 .Flags
= MS_COMMAND_DIR_DATA_OUT
,
687 .SCSICommandLength
= 6,
690 SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL
,
693 PreventRemoval
, // Prevent flag
695 0x00 // Unused (control)
699 MS_CommandStatusWrapper_t SCSICommandStatus
;
701 /* Send the command and any data to the attached device */
702 if ((ErrorCode
= MassStore_SendCommand(&SCSICommandBlock
, NULL
)) != PIPE_RWSTREAM_NoError
)
708 /* Retrieve status information from the attached device */
709 if ((ErrorCode
= MassStore_GetReturnedStatus(&SCSICommandStatus
)) != PIPE_RWSTREAM_NoError
)