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