40 #include <descriptors.h>
52 #define kUSBMSC_RWSuccess USBMSC_RW_SUCCESS
53 #define kUSBMSC_RWNotReady USBMSC_RW_NOT_READY
54 #define kUSBMSC_RWIllegalReq USBMSC_RW_ILLEGAL_REQUEST
55 #define kUSBMSC_RWUnitAttn USBMSC_RW_UNIT_ATTENTION
56 #define kUSBMSC_RWLbaOutOfRange USBMSC_RW_LBA_OUT_OF_RANGE
57 #define kUSBMSC_RWMedNotPresent USBMSC_RW_MEDIA_NOT_PRESENT
58 #define kUSBMSC_RWDevWriteFault USBMSC_RW_DEVICE_WRITE_FAULT
59 #define kUSBMSC_RWUnrecoveredRead USBMSC_RW_UNRECOVERED_READ
60 #define kUSBMSC_RWWriteProtected USBMSC_RW_WRITE_PROTECTED
61 #define kUSBMSC_READ USBMSC_READ
62 #define kUSBMSC_WRITE USBMSC_WRITE
63 #define kUSBMSC_MEDIA_PRESENT USBMSC_MEDIA_PRESENT
64 #define kUSBMSC_MEDIA_NOT_PRESENT USBMSC_MEDIA_NOT_PRESENT
65 #define kUSBMSC_WRITE_PROTECTED USBMSC_WRITE_PROTECTED
67 #define USBMSC_fetchInfoStruct USBMSC_fetchInformationStructure
72 #define CBW_SIGNATURE 0x43425355u
73 #define CSW_SIGNATURE 0x53425355u
80 #define SCSI_TEST_UNIT_READY 0x00
81 #define SCSI_REQUEST_SENSE 0x03
82 #define SCSI_INQUIRY 0x12
83 #define SCSI_MODE_SENSE_6 0x1A
84 #define SCSI_MODE_SENSE_10 0x5A
85 #define SCSI_READ_CAPACITY_10 0x25
86 #define SCSI_READ_10 0x28
87 #define SCSI_WRITE_10 0x2A
88 #define SCSI_READ_FORMAT_CAPACITIES 0x23
89 #define SCSI_MODE_SELECT_6 0x15
90 #define SCSI_MODE_SELECT_10 0x55
91 #define PREVENT_ALLW_MDM 0x1E
92 #define START_STOP_UNIT 0x1B
93 #define SCSI_REPORT_LUNS 0xA0
94 #define SCSI_VERIFY 0x2F
96 #define SCSI_READ_TOC_PMA_ATIP 0x43
97 #define Scsi_Read_TOC_PMA_ATIP_F1_LEN 20
98 #define Scsi_Read_TOC_PMA_ATIP_F2_LEN 48
99 #define SCSI_GET_CONFIGURATION 0x46
100 #define SCSI_GET_CONFIGURATION_LEN 4
101 #define SCSI_EVENT_STATUS 0x4A
102 #define SCSI_EVENT_STATUS_LEN 8
103 #define SCSI_READ_DISC_INFORMATION 0x51
104 #define SCSI_SET_CD_SPEED 0xBB
105 #define SCSI_READ_DISC_INFORMATION_LEN 36
108 #define SCSI_PASSED 0
109 #define SCSI_FAILED 1
110 #define SCSI_PHASE_ERROR 2
111 #define SCSI_READWRITE_FAIL 2
113 #define USBMSC_RW_SUCCESS 0
114 #define USBMSC_RW_NOT_READY 1
115 #define USBMSC_RW_ILLEGAL_REQUEST 2
116 #define USBMSC_RW_UNIT_ATTENTION 3
117 #define USBMSC_RW_LBA_OUT_OF_RANGE 4
118 #define USBMSC_RW_MEDIA_NOT_PRESENT 5
119 #define USBMSC_RW_DEVICE_WRITE_FAULT 6
120 #define USBMSC_RW_UNRECOVERED_READ 7
121 #define USBMSC_RW_WRITE_PROTECTED 8
125 #define USBMSC_READ 1
126 #define USBMSC_WRITE 2
128 #define USBMSC_MEDIA_PRESENT 0x81
129 #define USBMSC_MEDIA_NOT_PRESENT 0x82
131 #define USBMSC_WRITE_PROTECTED 0x00
134 #define MSC_READY 0x00
135 #define MSC_COMMAND_TRANSPORT 0x01
136 #define MSC_DATA_IN 0x02
137 #define MSC_DATA_OUT 0x03
138 #define MSC_STATUS_TRANSPORT 0x04
139 #define MSC_DATA 0x05
140 #define MSC_WAIT4RESET 0x06
143 #define SCSI_SCSI_INQUIRY_CMD_LEN 36
144 #define SCSI_READ_CAPACITY_CMD_LEN 8
145 #define SCSI_MODE_SENSE_6_CMD_LEN 4
146 #define SCSI_MODE_SENSE_10_CMD_LEN 8
147 #define SCSI_REQ_SENSE_CMD_LEN 18
148 #define SCSI_READ_FORMAT_CAPACITY_CMD_LEN 12
149 #define SCSI_REPORT_LUNS_CMD_LEN 16
156 uint32_t dCBWSignature;
158 uint32_t dCBWDataTransferLength;
161 uint8_t bCBWCBLength;
167 uint32_t dCSWSignature;
169 uint32_t dCSWDataResidue;
175 uint8_t ResponseCode : 7;
178 uint8_t SenseKey : 4;
182 uint8_t FILEMARK : 1;
183 uint8_t Information[4];
185 uint8_t CmdSpecificInfo[4];
189 uint8_t SenseKeySpecific[3];
214 uint8_t bufferProcessed;
225 uint32_t lastBlockLba;
226 uint32_t bytesPerBlock;
227 uint8_t mediaPresent;
228 uint8_t mediaChanged;
229 uint8_t writeProtected;
247 uint8_t LunListLength[4];
259 uint32_t dwBytesToReceiveLeft;
261 uint16_t wFreeBytesLeft;
263 uint8_t *pUserBuffer;
265 uint16_t wCurrentByte;
270 uint8_t bCurrentBufferXY;
271 uint8_t bWriteProcessing;
277 uint32_t dwBytesToSendLeft;
278 uint8_t *pUserBuffer;
285 uint8_t bCurrentBufferXY;
286 uint8_t bReadProcessing;
293 uint16_t wMscUserBufferSize;
295 uint8_t lbaBufCapacity;
296 uint8_t *xBufferAddr;
297 uint8_t *yBufferAddr;
298 uint8_t bMediaPresent;
299 uint8_t bWriteProtected;
303 volatile uint32_t Scsi_Residue;
304 volatile uint8_t Scsi_Status;
305 int16_t bMcsCommandSupported;
306 int16_t bMscCbwReceived;
308 int16_t isMSCConfigured;
309 uint8_t bUnitAttention;
310 uint8_t bMscCbwFailed;
311 uint8_t bMscResetRequired;
312 uint8_t stallEndpoint;
313 uint8_t stallAtEndofTx;
339 uint8_t Scsi_Cmd_Parser (uint8_t opcode);
340 uint8_t Scsi_Send_CSW (uint8_t intfNum);
343 void Msc_ResetStateMachine(
void);
344 void Msc_ResetFlags(
void);
345 void Msc_ResetStruct(
void);
346 void SET_RequestsenseNotReady(
void);
347 void SET_RequestsenseMediaNotPresent(
void);
348 void MscResetCtrlLun(
void);
374 #endif //_MSC_SCSI_H_
Definition: UsbMscScsi.h:246
Definition: UsbMscScsi.h:276
Definition: UsbMscScsi.h:155
USBMSC_RWbuf_Info * USBMSC_fetchInformationStructure(void)
Definition: UsbMscScsi.h:166
Definition: UsbMscScsi.h:302
Definition: UsbMscScsi.h:258
Definition: UsbMscScsi.h:242
Definition: UsbMscScsi.h:174
Definition: UsbMscScsi.h:194
Definition: UsbMscScsi.h:252
Definition: UsbMscScsi.h:292
Definition: UsbMscScsi.h:201
Definition: UsbMscScsi.h:233