]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbBusDxe/usbbus.h
Fixed unexpected timeout in Usb MassStorage Driver.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / usbbus.h
CommitLineData
e237e7ae 1/** @file\r
2Copyright (c) 2004 - 2007, Intel Corporation\r
3All rights reserved. This program and the accompanying materials\r
4are licensed and made available under the terms and conditions of the BSD License\r
5which accompanies this distribution. The full text of the license may be found at\r
6http://opensource.org/licenses/bsd-license.php\r
7\r
8THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
9WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
10\r
11 Module Name:\r
12\r
13 UsbBus.h\r
14\r
15 Abstract:\r
16\r
17 Usb Bus Driver Binding and Bus IO Protocol\r
18\r
19 Revision History\r
20\r
21\r
22**/\r
23\r
24#ifndef _EFI_USB_BUS_H_\r
25#define _EFI_USB_BUS_H_\r
26\r
ed7748fe 27\r
e237e7ae 28#include <PiDxe.h>\r
ed7748fe 29\r
e237e7ae 30#include <Protocol/Usb2HostController.h>\r
31#include <Protocol/UsbHostController.h>\r
32#include <Protocol/UsbIo.h>\r
33#include <Protocol/DevicePath.h>\r
ed7748fe 34\r
e237e7ae 35#include <Library/DebugLib.h>\r
36#include <Library/BaseMemoryLib.h>\r
37#include <Library/UefiDriverEntryPoint.h>\r
38#include <Library/UefiBootServicesTableLib.h>\r
39#include <Library/UefiLib.h>\r
40#include <Library/DevicePathLib.h>\r
41#include <Library/MemoryAllocationLib.h>\r
42\r
43\r
44#include <IndustryStandard/Usb.h>\r
45\r
46typedef struct _USB_DEVICE USB_DEVICE;\r
47typedef struct _USB_INTERFACE USB_INTERFACE;\r
48typedef struct _USB_BUS USB_BUS;\r
49typedef struct _USB_HUB_API USB_HUB_API;\r
50\r
51\r
52#include "UsbUtility.h"\r
53#include "UsbDesc.h"\r
54#include "UsbHub.h"\r
55#include "UsbEnumer.h"\r
56\r
57enum {\r
41e8ff27 58 USB_MAX_LANG_ID = 16,\r
59 USB_MAX_INTERFACE = 16,\r
60 USB_MAX_DEVICES = 128,\r
61\r
62 USB_BUS_1_MILLISECOND = 1000,\r
63\r
e237e7ae 64 //\r
41e8ff27 65 // Roothub and hub's polling interval, set by experience,\r
66 // The unit of roothub is 100us, means 1s as interval, and\r
67 // the unit of hub is 1ms, means 64ms as interval.\r
e237e7ae 68 //\r
41e8ff27 69 USB_ROOTHUB_POLL_INTERVAL = 1000 * 10000U,\r
e237e7ae 70 USB_HUB_POLL_INTERVAL = 64,\r
71\r
72 //\r
41e8ff27 73 // Wait for port stable to work, refers to specification\r
74 // [USB20-9.1.2]\r
e237e7ae 75 //\r
41e8ff27 76 USB_WAIT_PORT_STABLE_STALL = 100 * USB_BUS_1_MILLISECOND,\r
77\r
78 // \r
79 // Wait for port statue reg change, set by experience\r
80 //\r
81 USB_WAIT_PORT_STS_CHANGE_STALL = 5 * USB_BUS_1_MILLISECOND,\r
82\r
83 //\r
84 // Wait for set device address, refers to specification\r
85 // [USB20-9.2.6.3, it says 2ms]\r
86 //\r
87 USB_SET_DEVICE_ADDRESS_STALL = 20 * USB_BUS_1_MILLISECOND,\r
88\r
89 //\r
90 // Wait for retry max packet size, set by experience\r
91 //\r
92 USB_RETRY_MAX_PACK_SIZE_STALL = 100 * USB_BUS_1_MILLISECOND,\r
e237e7ae 93\r
41e8ff27 94 //\r
95 // Wait for hub port power-on, refers to specification\r
96 // [USB20-11.23.2]\r
97 //\r
98 USB_SET_PORT_POWER_STALL = 2 * USB_BUS_1_MILLISECOND,\r
99\r
100 //\r
101 // Wait for port reset, refers to specification \r
102 // [USB20-7.1.7.5, it says 10ms for hub and 50ms for \r
103 // root hub]\r
104 //\r
105 USB_SET_PORT_RESET_STALL = 20 * USB_BUS_1_MILLISECOND,\r
106 USB_SET_ROOT_PORT_RESET_STALL = 50 * USB_BUS_1_MILLISECOND,\r
107\r
108 //\r
109 // Wait for clear roothub port reset, set by experience\r
110 //\r
111 USB_CLR_ROOT_PORT_RESET_STALL = 1 * USB_BUS_1_MILLISECOND,\r
112\r
113 //\r
114 // Wait for set roothub port enable, set by experience\r
115 // \r
116 USB_SET_ROOT_PORT_ENABLE_STALL = 20 * USB_BUS_1_MILLISECOND,\r
117\r
118 //\r
119 // Send general device request timeout, refers to \r
120 // specification[USB20-11.24.1]\r
121 //\r
122 USB_GENERAL_DEVICE_REQUEST_TIMEOUT = 50 * USB_BUS_1_MILLISECOND,\r
123\r
124 //\r
125 // Send clear feature request timeout, set by experience\r
126 //\r
127 USB_CLEAR_FEATURE_REQUEST_TIMEOUT = 10 * USB_BUS_1_MILLISECOND,\r
128 \r
e237e7ae 129 //\r
130 // Bus raises TPL to TPL_NOTIFY to serialize all its operations\r
131 // to protect shared data structures.\r
132 //\r
133 USB_BUS_TPL = TPL_NOTIFY,\r
134\r
135 USB_INTERFACE_SIGNATURE = EFI_SIGNATURE_32 ('U', 'S', 'B', 'I'),\r
c52fa98c 136 USB_BUS_SIGNATURE = EFI_SIGNATURE_32 ('U', 'S', 'B', 'B')\r
e237e7ae 137};\r
138\r
139#define USB_BIT(a) ((UINTN)(1 << (a)))\r
140#define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))\r
141\r
142#define EFI_USB_BUS_PROTOCOL_GUID \\r
84b5c78e 143 {0x2B2F68CC, 0x0CD2, 0x44cf, {0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75}}\r
e237e7ae 144\r
145#define USB_INTERFACE_FROM_USBIO(a) \\r
146 CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE)\r
147\r
148#define USB_BUS_FROM_THIS(a) \\r
149 CR(a, USB_BUS, BusId, USB_BUS_SIGNATURE)\r
150\r
151//\r
152// Used to locate USB_BUS\r
153//\r
154typedef struct _EFI_USB_BUS_PROTOCOL {\r
155 UINT64 Reserved;\r
156} EFI_USB_BUS_PROTOCOL;\r
157\r
158\r
159//\r
160// Stands for the real USB device. Each device may\r
161// has several seperately working interfaces.\r
162//\r
c52fa98c 163struct _USB_DEVICE {\r
e237e7ae 164 USB_BUS *Bus;\r
165\r
166 //\r
167 // Configuration information\r
168 //\r
169 UINT8 Speed;\r
170 UINT8 Address;\r
171 UINT8 MaxPacket0;\r
172\r
173 //\r
174 // The device's descriptors and its configuration\r
175 //\r
176 USB_DEVICE_DESC *DevDesc;\r
177 USB_CONFIG_DESC *ActiveConfig;\r
178\r
179 UINT16 LangId [USB_MAX_LANG_ID];\r
180 UINT16 TotalLangId;\r
181\r
182 UINT8 NumOfInterface;\r
183 USB_INTERFACE *Interfaces [USB_MAX_INTERFACE];\r
184\r
185 //\r
186 // Parent child relationship\r
187 //\r
188 EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;\r
189\r
190 UINT8 ParentAddr;\r
191 USB_INTERFACE *ParentIf;\r
192 UINT8 ParentPort; // Start at 0\r
c52fa98c 193};\r
e237e7ae 194\r
195//\r
196// Stands for different functions of USB device\r
197//\r
c52fa98c 198struct _USB_INTERFACE {\r
e237e7ae 199 UINTN Signature;\r
200 USB_DEVICE *Device;\r
201 USB_INTERFACE_DESC *IfDesc;\r
202 USB_INTERFACE_SETTING *IfSetting;\r
203\r
204 //\r
205 // Handles and protocols\r
206 //\r
207 EFI_HANDLE Handle;\r
208 EFI_USB_IO_PROTOCOL UsbIo;\r
209 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
210 BOOLEAN IsManaged;\r
211\r
212 //\r
213 // Hub device special data\r
214 //\r
215 BOOLEAN IsHub;\r
216 USB_HUB_API *HubApi;\r
217 UINT8 NumOfPort;\r
218 EFI_EVENT HubNotify;\r
219\r
220 //\r
221 // Data used only by normal hub devices\r
222 //\r
223 USB_ENDPOINT_DESC *HubEp;\r
224 UINT8 *ChangeMap;\r
225\r
226 //\r
227 // Data used only by root hub to hand over device to\r
228 // companion UHCI driver if low/full speed devices are\r
229 // connected to EHCI.\r
230 //\r
231 UINT8 MaxSpeed;\r
c52fa98c 232};\r
e237e7ae 233\r
234//\r
235// Stands for the current USB Bus\r
236//\r
c52fa98c 237struct _USB_BUS {\r
e237e7ae 238 UINTN Signature;\r
239 EFI_USB_BUS_PROTOCOL BusId;\r
240\r
241 //\r
242 // Managed USB host controller\r
243 //\r
244 EFI_HANDLE HostHandle;\r
245 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
246 EFI_USB2_HC_PROTOCOL *Usb2Hc;\r
247 EFI_USB_HC_PROTOCOL *UsbHc;\r
248\r
249 //\r
250 // An array of device that is on the bus. Devices[0] is\r
251 // for root hub. Device with address i is at Devices[i].\r
252 //\r
253 USB_DEVICE *Devices[USB_MAX_DEVICES];\r
c52fa98c 254};\r
e237e7ae 255\r
62b9bb55 256extern EFI_USB_IO_PROTOCOL mUsbIoProtocol;\r
257extern EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding;\r
258extern EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName;\r
259extern EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2;\r
e237e7ae 260\r
261#endif\r