msdscsi.h
Go to the documentation of this file.00001
00017 #ifndef __MSDSCSI_H
00018 #define __MSDSCSI_H
00019
00020
00025
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033
00034 #define SCSI_TESTUNIT_READY 0x00
00035 #define SCSI_REQUESTSENSE 0x03
00036 #define SCSI_INQUIRY 0x12
00037 #define SCSI_STARTSTOP_UNIT 0x1B
00038 #define SCSI_READCAPACITY 0x25
00039 #define SCSI_READ10 0x28
00040 #define SCSI_WRITE10 0x2A
00041 #define SCSI_VERIFY10 0x2F
00043 #define SCSI_READ10_LEN 10U
00044 #define SCSI_WRITE10_LEN 10U
00045 #define SCSI_VERIFY10_LEN 10U
00046 #define SCSI_INQUIRYDATA_LEN 36U
00047 #define SCSI_REQUESTSENSE_LEN 6U
00048 #define SCSI_REQUESTSENSEDATA_LEN 18U
00049 #define SCSI_READCAPACITY_LEN 10U
00050 #define SCSI_READCAPACITYDATA_LEN 8U
00052
00055 EFM32_PACK_START(1)
00056 typedef struct
00057 {
00058 uint8_t OpCode;
00059 struct
00060 {
00061 uint8_t Evpd : 1;
00062 uint8_t Obsolete : 1;
00063 uint8_t Reserved : 6;
00064 };
00065 uint8_t PageCode;
00066 uint16_t AllocationLength;
00067 uint8_t Control;
00068 } __attribute__ ((packed)) MSDSCSI_Inquiry_TypeDef;
00069 EFM32_PACK_END()
00070
00071
00074 EFM32_PACK_START(1)
00075 typedef struct
00076 {
00077 struct
00078 {
00079 uint8_t PeripheralDeviceType : 5;
00080 uint8_t PeripheralQualifier : 3;
00081 };
00082 struct
00083 {
00084 uint8_t Reserved1 : 7;
00085 uint8_t Removable : 1;
00086 };
00087 uint8_t Version;
00088 struct
00089 {
00090 uint8_t ResponseDataFormat : 4;
00091 uint8_t HiSup : 1;
00092 uint8_t NormACA : 1;
00093 uint8_t Obsolete1 : 2;
00094 };
00095 uint8_t AdditionalLength;
00096 struct
00097 {
00098 uint8_t Protect : 1;
00099 uint8_t Reserved2 : 2;
00100 uint8_t ThirdPartyCode : 1;
00101 uint8_t Tpgs : 2;
00102 uint8_t Acc : 1;
00103 uint8_t Sccs : 1;
00104 };
00105 struct
00106 {
00107 uint8_t Addr16 : 1;
00108 uint8_t Obsolete2 : 2;
00109 uint8_t MChngr : 1;
00110 uint8_t MultiP : 1;
00111 uint8_t Vs1 : 1;
00112 uint8_t EncServ : 1;
00113 uint8_t BQue : 1;
00114 };
00115 struct
00116 {
00117 uint8_t Vs2 : 1;
00118 uint8_t CmdQue : 1;
00119 uint8_t Obsolete3 : 1;
00120 uint8_t Linked : 1;
00121 uint8_t Sync : 1;
00122 uint8_t Wbus16 : 1;
00123 uint8_t Obsolete4 : 2;
00124 };
00125 uint8_t T10VendorId[ 8 ];
00126 uint8_t ProductId[ 16 ];
00127 uint8_t ProductRevisionLevel[ 4 ];
00128 } __attribute__ ((packed)) MSDSCSI_InquiryData_TypeDef;
00129 EFM32_PACK_END()
00130
00131
00134 EFM32_PACK_START(1)
00135 typedef struct
00136 {
00137 uint8_t OpCode;
00138 struct
00139 {
00140 uint8_t Desc : 1;
00141 uint8_t Reserved1 : 7;
00142 };
00143 uint8_t Reserved2;
00144 uint8_t Reserved3;
00145 uint8_t AllocationLength;
00146 uint8_t Control;
00147 } __attribute__ ((packed)) MSDSCSI_RequestSense_TypeDef;
00148 EFM32_PACK_END()
00149
00150
00153 EFM32_PACK_START(1)
00154 typedef struct
00155 {
00156 struct
00157 {
00158 uint8_t ResponseCode : 7;
00159 uint8_t Valid : 1;
00160 };
00161 uint8_t Obsolete;
00162 struct
00163 {
00164 uint8_t SenseKey : 4;
00165 uint8_t Reserved : 1;
00166 uint8_t Ili : 1;
00167 uint8_t Eom : 1;
00168 uint8_t FileMark : 1;
00169 };
00170 uint32_t Information;
00171 uint8_t AdditionalLength;
00172 uint32_t CmdSpecificInfo;
00173 uint8_t Asc;
00174 uint8_t Ascq;
00175 uint8_t Fruc;
00176 struct
00177 {
00178 uint8_t SenseKeySpecific1 : 7;
00179 uint8_t Sksv : 1;
00180 };
00181 uint8_t SenseKeySpecific2;
00182 uint8_t SenseKeySpecific3;
00183 } __attribute__ ((packed)) MSDSCSI_RequestSenseData_TypeDef;
00184 EFM32_PACK_END()
00185
00186
00189 EFM32_PACK_START(1)
00190 typedef struct
00191 {
00192 uint8_t OpCode;
00193 struct
00194 {
00195 uint8_t Obsolete : 1;
00196 uint8_t Reserved1 : 7;
00197 };
00198 uint32_t Lba;
00199 uint16_t Reserved2;
00200 struct
00201 {
00202 uint8_t Pmi : 1;
00203 uint8_t Reserved3 : 7;
00204 };
00205 uint8_t Control;
00206 } __attribute__ ((packed)) MSDSCSI_ReadCapacity_TypeDef;
00207 EFM32_PACK_END()
00208
00209
00212 EFM32_PACK_START(1)
00213 typedef struct
00214 {
00215 uint32_t LogicalBlockAddress;
00216 uint32_t LogicalBlockLength;
00217 } __attribute__ ((packed)) MSDSCSI_ReadCapacityData_TypeDef;
00218 EFM32_PACK_END()
00219
00220
00223 EFM32_PACK_START(1)
00224 typedef struct
00225 {
00226 uint8_t OpCode;
00227 struct
00228 {
00229 uint8_t Obsolete : 1;
00230 uint8_t FuaNv : 1;
00231 uint8_t Reserved1 : 1;
00232 uint8_t Fua : 1;
00233 uint8_t Dpo : 1;
00234 uint8_t RdProtect : 3;
00235 };
00236 uint32_t Lba;
00237 struct
00238 {
00239 uint8_t GroupNumber : 5;
00240 uint8_t Reserved2 : 3;
00241 };
00242 uint16_t TransferLength;
00243 uint8_t Control;
00244 } __attribute__ ((packed)) MSDSCSI_Read10_TypeDef;
00245 EFM32_PACK_END()
00246
00247
00250 EFM32_PACK_START(1)
00251 typedef struct
00252 {
00253 uint8_t OpCode;
00254 struct
00255 {
00256 uint8_t Obsolete : 1;
00257 uint8_t FuaNv : 1;
00258 uint8_t Reserved1 : 1;
00259 uint8_t Fua : 1;
00260 uint8_t Dpo : 1;
00261 uint8_t WrProtect : 3;
00262 };
00263 uint32_t Lba;
00264 struct
00265 {
00266 uint8_t GroupNumber : 5;
00267 uint8_t Reserved2 : 3;
00268 };
00269 uint16_t TransferLength;
00270 uint8_t Control;
00271 } __attribute__ ((packed)) MSDSCSI_Write10_TypeDef;
00272 EFM32_PACK_END()
00273
00274
00277 EFM32_PACK_START(1)
00278 typedef struct
00279 {
00280 uint8_t OpCode;
00281 struct
00282 {
00283 uint8_t Obsolete : 1;
00284 uint8_t BytChk : 1;
00285 uint8_t Reserved1 : 2;
00286 uint8_t Dpo : 1;
00287 uint8_t VrProtect : 3;
00288 };
00289 uint32_t Lba;
00290 struct
00291 {
00292 uint8_t GroupNumber : 5;
00293 uint8_t Reserved2 : 2;
00294 uint8_t Restricted : 1;
00295 };
00296 uint16_t Verification;
00297 uint8_t Control;
00298 } __attribute__ ((packed)) MSDSCSI_Verify10_TypeDef;
00299 EFM32_PACK_END()
00300
00301
00302
00303 #if defined(USB_HOST)
00304
00305 bool MSDSCSI_Init(USBH_Ep_TypeDef *out, USBH_Ep_TypeDef *in);
00306 bool MSDSCSI_Inquiry(MSDSCSI_InquiryData_TypeDef *data);
00307 bool MSDSCSI_Read10(uint32_t lba, uint16_t sectors, void *data);
00308 bool MSDSCSI_ReadCapacity(MSDSCSI_ReadCapacityData_TypeDef *data);
00309 bool MSDSCSI_RequestSense(MSDSCSI_RequestSenseData_TypeDef *data);
00310 bool MSDSCSI_TestUnitReady(void);
00311 bool MSDSCSI_Write10(uint32_t lba, uint16_t sectors, const void *data);
00312
00313 #endif
00314
00315 #ifdef __cplusplus
00316 }
00317 #endif
00318
00322 #endif