]>
Commit | Line | Data |
---|---|---|
e237e7ae | 1 | /** @file\r |
d80ed2a7 | 2 | Definition for the USB mass storage Bulk-Only Transport protocol,\r |
3 | based on the "Universal Serial Bus Mass Storage Class Bulk-Only\r | |
4 | Transport" Revision 1.0, September 31, 1999.\r | |
cc5166ff | 5 | \r |
cd5ebaa0 HT |
6 | Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r |
7 | This program and the accompanying materials\r | |
e237e7ae | 8 | are licensed and made available under the terms and conditions of the BSD License\r |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
e237e7ae | 15 | **/\r |
16 | \r | |
17 | #ifndef _EFI_USBMASS_BOT_H_\r | |
18 | #define _EFI_USBMASS_BOT_H_\r | |
19 | \r | |
3e03cb4d | 20 | #include "UsbMass.h"\r |
21 | \r | |
d80ed2a7 | 22 | extern USB_MASS_TRANSPORT mUsbBotTransport;\r |
23 | \r | |
1ccdbf2a | 24 | //\r |
25 | // Usb Bulk-Only class specfic request\r | |
26 | //\r | |
27 | #define USB_BOT_RESET_REQUEST 0xFF ///< Bulk-Only Mass Storage Reset\r | |
28 | #define USB_BOT_GETLUN_REQUEST 0xFE ///< Get Max Lun\r | |
29 | #define USB_BOT_CBW_SIGNATURE 0x43425355 ///< dCBWSignature, tag the packet as CBW\r | |
30 | #define USB_BOT_CSW_SIGNATURE 0x53425355 ///< dCSWSignature, tag the packet as CSW\r | |
31 | #define USB_BOT_MAX_LUN 0x0F ///< Lun number is from 0 to 15\r | |
32 | #define USB_BOT_MAX_CMDLEN 16 ///< Maxium number of command from command set\r | |
e237e7ae | 33 | \r |
1ccdbf2a | 34 | //\r |
35 | // Usb BOT command block status values\r | |
36 | //\r | |
37 | #define USB_BOT_COMMAND_OK 0x00 ///< Command passed, good status\r | |
38 | #define USB_BOT_COMMAND_FAILED 0x01 ///< Command failed\r | |
39 | #define USB_BOT_COMMAND_ERROR 0x02 ///< Phase error, need to reset the device\r | |
e237e7ae | 40 | \r |
1ccdbf2a | 41 | //\r |
42 | // Usb Bot retry to get CSW, refers to specification[BOT10-5.3, it says 2 times]\r | |
43 | //\r | |
44 | #define USB_BOT_RECV_CSW_RETRY 3\r | |
e237e7ae | 45 | \r |
1ccdbf2a | 46 | //\r |
47 | // Usb Bot wait device reset complete, set by experience\r | |
48 | // \r | |
49 | #define USB_BOT_RESET_DEVICE_STALL (100 * USB_MASS_1_MILLISECOND)\r | |
50 | \r | |
51 | //\r | |
52 | // Usb Bot transport timeout, set by experience\r | |
53 | //\r | |
54 | #define USB_BOT_SEND_CBW_TIMEOUT (3 * USB_MASS_1_SECOND)\r | |
55 | #define USB_BOT_RECV_CSW_TIMEOUT (3 * USB_MASS_1_SECOND)\r | |
56 | #define USB_BOT_RESET_DEVICE_TIMEOUT (3 * USB_MASS_1_SECOND)\r | |
e237e7ae | 57 | \r |
e237e7ae | 58 | #pragma pack(1)\r |
d80ed2a7 | 59 | ///\r |
60 | /// The CBW (Command Block Wrapper) structures used by the USB BOT protocol.\r | |
61 | ///\r | |
e237e7ae | 62 | typedef struct {\r |
63 | UINT32 Signature;\r | |
64 | UINT32 Tag;\r | |
d80ed2a7 | 65 | UINT32 DataLen; ///< Length of data between CBW and CSW\r |
66 | UINT8 Flag; ///< Bit 7, 0 ~ Data-Out, 1 ~ Data-In\r | |
67 | UINT8 Lun; ///< Lun number. Bits 0~3 are used\r | |
68 | UINT8 CmdLen; ///< Length of the command. Bits 0~4 are used\r | |
e237e7ae | 69 | UINT8 CmdBlock[USB_BOT_MAX_CMDLEN];\r |
70 | } USB_BOT_CBW;\r | |
71 | \r | |
d80ed2a7 | 72 | ///\r |
73 | /// The and CSW (Command Status Wrapper) structures used by the USB BOT protocol.\r | |
74 | ///\r | |
e237e7ae | 75 | typedef struct {\r |
76 | UINT32 Signature;\r | |
77 | UINT32 Tag;\r | |
78 | UINT32 DataResidue;\r | |
79 | UINT8 CmdStatus;\r | |
80 | } USB_BOT_CSW;\r | |
81 | #pragma pack()\r | |
82 | \r | |
e237e7ae | 83 | typedef struct {\r |
d80ed2a7 | 84 | //\r |
85 | // Put Interface at the first field to make it easy to distinguish BOT/CBI Protocol instance\r | |
86 | //\r | |
e237e7ae | 87 | EFI_USB_INTERFACE_DESCRIPTOR Interface;\r |
88 | EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;\r | |
89 | EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;\r | |
90 | UINT32 CbwTag;\r | |
91 | EFI_USB_IO_PROTOCOL *UsbIo;\r | |
92 | } USB_BOT_PROTOCOL;\r | |
93 | \r | |
d80ed2a7 | 94 | /**\r |
95 | Initializes USB BOT protocol.\r | |
96 | \r | |
97 | This function initializes the USB mass storage class BOT protocol.\r | |
98 | It will save its context which is a USB_BOT_PROTOCOL structure\r | |
99 | in the Context if Context isn't NULL.\r | |
100 | \r | |
101 | @param UsbIo The USB I/O Protocol instance\r | |
102 | @param Context The buffer to save the context to\r | |
103 | \r | |
104 | @retval EFI_SUCCESS The device is successfully initialized.\r | |
105 | @retval EFI_UNSUPPORTED The transport protocol doesn't support the device.\r | |
106 | @retval Other The USB BOT initialization fails.\r | |
107 | \r | |
108 | **/\r | |
109 | EFI_STATUS\r | |
110 | UsbBotInit (\r | |
111 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
112 | OUT VOID **Context OPTIONAL\r | |
113 | );\r | |
114 | \r | |
115 | /**\r | |
116 | Call the USB Mass Storage Class BOT protocol to issue\r | |
117 | the command/data/status circle to execute the commands.\r | |
118 | \r | |
119 | @param Context The context of the BOT protocol, that is,\r | |
120 | USB_BOT_PROTOCOL\r | |
121 | @param Cmd The high level command\r | |
122 | @param CmdLen The command length\r | |
123 | @param DataDir The direction of the data transfer\r | |
124 | @param Data The buffer to hold data\r | |
125 | @param DataLen The length of the data\r | |
126 | @param Lun The number of logic unit\r | |
127 | @param Timeout The time to wait command\r | |
128 | @param CmdStatus The result of high level command execution\r | |
129 | \r | |
130 | @retval EFI_SUCCESS The command is executed successfully.\r | |
131 | @retval Other Failed to excute command\r | |
132 | \r | |
133 | **/\r | |
134 | EFI_STATUS\r | |
135 | UsbBotExecCommand (\r | |
136 | IN VOID *Context,\r | |
137 | IN VOID *Cmd,\r | |
138 | IN UINT8 CmdLen,\r | |
139 | IN EFI_USB_DATA_DIRECTION DataDir,\r | |
140 | IN VOID *Data,\r | |
141 | IN UINT32 DataLen,\r | |
142 | IN UINT8 Lun,\r | |
143 | IN UINT32 Timeout,\r | |
144 | OUT UINT32 *CmdStatus\r | |
145 | );\r | |
146 | \r | |
147 | /**\r | |
148 | Reset the USB mass storage device by BOT protocol.\r | |
149 | \r | |
150 | @param Context The context of the BOT protocol, that is,\r | |
151 | USB_BOT_PROTOCOL.\r | |
152 | @param ExtendedVerification If FALSE, just issue Bulk-Only Mass Storage Reset request.\r | |
153 | If TRUE, additionally reset parent hub port.\r | |
154 | \r | |
155 | @retval EFI_SUCCESS The device is reset.\r | |
156 | @retval Others Failed to reset the device..\r | |
157 | \r | |
158 | **/\r | |
159 | EFI_STATUS\r | |
160 | UsbBotResetDevice (\r | |
161 | IN VOID *Context,\r | |
162 | IN BOOLEAN ExtendedVerification\r | |
163 | );\r | |
164 | \r | |
165 | /**\r | |
166 | Get the max LUN (Logical Unit Number) of USB mass storage device.\r | |
167 | \r | |
168 | @param Context The context of the BOT protocol, that is, USB_BOT_PROTOCOL\r | |
169 | @param MaxLun Return pointer to the max number of LUN. (e.g. MaxLun=1 means LUN0 and\r | |
170 | LUN1 in all.)\r | |
171 | \r | |
172 | @retval EFI_SUCCESS Max LUN is got successfully.\r | |
173 | @retval Others Fail to execute this request.\r | |
174 | \r | |
175 | **/\r | |
176 | EFI_STATUS\r | |
177 | UsbBotGetMaxLun (\r | |
178 | IN VOID *Context,\r | |
179 | OUT UINT8 *MaxLun\r | |
180 | );\r | |
181 | \r | |
182 | /**\r | |
183 | Clean up the resource used by this BOT protocol.\r | |
184 | \r | |
185 | @param Context The context of the BOT protocol, that is, USB_BOT_PROTOCOL.\r | |
186 | \r | |
187 | @retval EFI_SUCCESS The resource is cleaned up.\r | |
188 | \r | |
189 | **/\r | |
190 | EFI_STATUS\r | |
191 | UsbBotCleanUp (\r | |
192 | IN VOID *Context\r | |
193 | );\r | |
194 | \r | |
e237e7ae | 195 | #endif\r |