summaryrefslogtreecommitdiff
path: root/bsp/allwinner/libraries/sunxi-hal/hal/source/usb/storage/Class/mscTransport.h
blob: 1e68f3e680f9ebf40921c45225b6051e0e7865b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
********************************************************************************************************************
*                                              usb host driver
*
*                              (c) Copyright 2007-2010, javen.China
*                                       All Rights Reserved
*
* File Name     : mscTransport.h
*
* Author        : javen
*
* Version       : 2.0
*
* Date          : 2010.03.02
*
* Description   :
*
* History       :
*
********************************************************************************************************************
*/
#ifndef  __MSCTRANSPORT_H__
#define  __MSCTRANSPORT_H__

/* ´«Êä´íÎóºÅ */
#define  USB_STOR_XFER_GOOD             0
#define  USB_STOR_XFER_ERROR            1
#define  USB_STOR_XFER_SHORT            2
#define  USB_STOR_XFER_STALLED          3
#define  USB_STOR_XFER_LONG             4
#define  USB_STOR_XFER_TIME_OUT         5

/* mass storage transport time out */
#define  USB_STOR_REST_TIME             8000    //4s, ¸´Î»ÇëÇó
#define  USB_STOR_CTRL_MSG_TIME         8000    //4s, ¿ØÖÆÃüÁî
#define  USB_STOR_CBW_CSW_TIME          8000    //4s, cbw, csw

#define  MAX_CBWCB_SIZE                 16
#define  MAX_BOT_CSW_REPEAT             2

/* bulk-only class specific requests */
#define  USB_BULK_RESET_REQUEST         0xff
#define  USB_BULK_GET_MAX_LUN           0xfe

// Command Block Wrapper Signature 'USBC'
#define CBW_SIGNATURE               0x43425355
#define CBW_FLAGS_DATA_IN           0x80
#define CBW_FLAGS_DATA_OUT          0x00

// Command Status Wrapper Signature 'USBS'
#define CSW_SIGNATURE               0x53425355
#define CSW_STATUS_GOOD             0x00
#define CSW_STATUS_FAILED           0x01
#define CSW_STATUS_PHASE_ERROR      0x02

// Command Block Wrapper
typedef struct __CBW
{
    unsigned int dCBWSignature;            // 0-3
    unsigned int dCBWTag;                  // 4-7
    unsigned int dCBWDataTransferLength;   // 8-11
    unsigned char  bmCBWFlags;               // 12
    unsigned char  bCBWLUN: 4;               // 13
    unsigned char  bReserved1: 4;
    unsigned char  bCBWCBLength: 5;          // 14
    unsigned char  bReserved2: 3;
    unsigned char  CBWCB[MAX_CBWCB_SIZE];    // 15-30
} __attribute__((packed)) __CBW_t;

// Command Status Wrapper
typedef struct __CSW
{
    unsigned int dCSWSignature;        // 0-3
    unsigned int dCSWTag;              // 4-7
    unsigned int dCSWDataResidue;      // 8-11
    unsigned char  bCSWStatus;           // 12
} __attribute__((packed)) __CSW_t;


//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
unsigned int mscGetMaxLun(__mscDev_t *mscDev);
int mscResetRecovery(__mscDev_t *mscDev);
int mscBoTransport(__mscDev_t *mscDev, __ScsiCmnd_t *ScsiCmnd);
int mscBoStopTransport(__mscDev_t *mscDev);

int mscGetDataTransportReason(__mscLun_t *mscLun, __ScsiCmnd_t *ScsiCmnd);


#endif   //__MSCTRANSPORT_H__