1 /* 2 ******************************************************************************************************************** 3 * usb host driver 4 * 5 * (c) Copyright 2007-2010, javen.China 6 * All Rights Reserved 7 * 8 * File Name : mscTransport.h 9 * 10 * Author : javen 11 * 12 * Version : 2.0 13 * 14 * Date : 2010.03.02 15 * 16 * Description : 17 * 18 * History : 19 * 20 ******************************************************************************************************************** 21 */ 22 #ifndef __MSCTRANSPORT_H__ 23 #define __MSCTRANSPORT_H__ 24 25 /* ´«Êä´íÎóºÅ */ 26 #define USB_STOR_XFER_GOOD 0 27 #define USB_STOR_XFER_ERROR 1 28 #define USB_STOR_XFER_SHORT 2 29 #define USB_STOR_XFER_STALLED 3 30 #define USB_STOR_XFER_LONG 4 31 #define USB_STOR_XFER_TIME_OUT 5 32 33 /* mass storage transport time out */ 34 #define USB_STOR_REST_TIME 8000 //4s, ¸´Î»ÇëÇó 35 #define USB_STOR_CTRL_MSG_TIME 8000 //4s, ¿ØÖÆÃüÁî 36 #define USB_STOR_CBW_CSW_TIME 8000 //4s, cbw, csw 37 38 #define MAX_CBWCB_SIZE 16 39 #define MAX_BOT_CSW_REPEAT 2 40 41 /* bulk-only class specific requests */ 42 #define USB_BULK_RESET_REQUEST 0xff 43 #define USB_BULK_GET_MAX_LUN 0xfe 44 45 // Command Block Wrapper Signature 'USBC' 46 #define CBW_SIGNATURE 0x43425355 47 #define CBW_FLAGS_DATA_IN 0x80 48 #define CBW_FLAGS_DATA_OUT 0x00 49 50 // Command Status Wrapper Signature 'USBS' 51 #define CSW_SIGNATURE 0x53425355 52 #define CSW_STATUS_GOOD 0x00 53 #define CSW_STATUS_FAILED 0x01 54 #define CSW_STATUS_PHASE_ERROR 0x02 55 56 // Command Block Wrapper 57 typedef struct __CBW 58 { 59 unsigned int dCBWSignature; // 0-3 60 unsigned int dCBWTag; // 4-7 61 unsigned int dCBWDataTransferLength; // 8-11 62 unsigned char bmCBWFlags; // 12 63 unsigned char bCBWLUN: 4; // 13 64 unsigned char bReserved1: 4; 65 unsigned char bCBWCBLength: 5; // 14 66 unsigned char bReserved2: 3; 67 unsigned char CBWCB[MAX_CBWCB_SIZE]; // 15-30 68 } __attribute__((packed)) __CBW_t; 69 70 // Command Status Wrapper 71 typedef struct __CSW 72 { 73 unsigned int dCSWSignature; // 0-3 74 unsigned int dCSWTag; // 4-7 75 unsigned int dCSWDataResidue; // 8-11 76 unsigned char bCSWStatus; // 12 77 } __attribute__((packed)) __CSW_t; 78 79 80 ////////////////////////////////////////////////////////////////////// 81 ////////////////////////////////////////////////////////////////////// 82 unsigned int mscGetMaxLun(__mscDev_t *mscDev); 83 int mscResetRecovery(__mscDev_t *mscDev); 84 int mscBoTransport(__mscDev_t *mscDev, __ScsiCmnd_t *ScsiCmnd); 85 int mscBoStopTransport(__mscDev_t *mscDev); 86 87 int mscGetDataTransportReason(__mscLun_t *mscLun, __ScsiCmnd_t *ScsiCmnd); 88 89 90 #endif //__MSCTRANSPORT_H__ 91 92 93