]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Bus/Usb/UsbBusDxe/usbbus.h
Enhance the Usb bus driver to support Star with Remaining device path.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / usbbus.h
... / ...
CommitLineData
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
27\r
28#include <PiDxe.h>\r
29\r
30#include <Protocol/Usb2HostController.h>\r
31#include <Protocol/UsbHostController.h>\r
32#include <Protocol/UsbIo.h>\r
33#include <Protocol/DevicePath.h>\r
34\r
35#include <library/BaseLib.h>\r
36#include <Library/DebugLib.h>\r
37#include <Library/BaseMemoryLib.h>\r
38#include <Library/UefiDriverEntryPoint.h>\r
39#include <Library/UefiBootServicesTableLib.h>\r
40#include <Library/UefiLib.h>\r
41#include <Library/DevicePathLib.h>\r
42#include <Library/MemoryAllocationLib.h>\r
43\r
44\r
45#include <IndustryStandard/Usb.h>\r
46\r
47typedef struct _USB_DEVICE USB_DEVICE;\r
48typedef struct _USB_INTERFACE USB_INTERFACE;\r
49typedef struct _USB_BUS USB_BUS;\r
50typedef struct _USB_HUB_API USB_HUB_API;\r
51\r
52\r
53#include "UsbUtility.h"\r
54#include "UsbDesc.h"\r
55#include "UsbHub.h"\r
56#include "UsbEnumer.h"\r
57\r
58enum {\r
59 USB_MAX_LANG_ID = 16,\r
60 USB_MAX_INTERFACE = 16,\r
61 USB_MAX_DEVICES = 128,\r
62\r
63 USB_BUS_1_MILLISECOND = 1000,\r
64\r
65 //\r
66 // Roothub and hub's polling interval, set by experience,\r
67 // The unit of roothub is 100us, means 1s as interval, and\r
68 // the unit of hub is 1ms, means 64ms as interval.\r
69 //\r
70 USB_ROOTHUB_POLL_INTERVAL = 1000 * 10000U,\r
71 USB_HUB_POLL_INTERVAL = 64,\r
72\r
73 //\r
74 // Wait for port stable to work, refers to specification\r
75 // [USB20-9.1.2]\r
76 //\r
77 USB_WAIT_PORT_STABLE_STALL = 100 * USB_BUS_1_MILLISECOND,\r
78\r
79 //\r
80 // Wait for port statue reg change, set by experience\r
81 //\r
82 USB_WAIT_PORT_STS_CHANGE_STALL = 5 * USB_BUS_1_MILLISECOND,\r
83\r
84 //\r
85 // Wait for set device address, refers to specification\r
86 // [USB20-9.2.6.3, it says 2ms]\r
87 //\r
88 USB_SET_DEVICE_ADDRESS_STALL = 20 * USB_BUS_1_MILLISECOND,\r
89\r
90 //\r
91 // Wait for retry max packet size, set by experience\r
92 //\r
93 USB_RETRY_MAX_PACK_SIZE_STALL = 100 * USB_BUS_1_MILLISECOND,\r
94\r
95 //\r
96 // Wait for hub port power-on, refers to specification\r
97 // [USB20-11.23.2]\r
98 //\r
99 USB_SET_PORT_POWER_STALL = 2 * USB_BUS_1_MILLISECOND,\r
100\r
101 //\r
102 // Wait for port reset, refers to specification\r
103 // [USB20-7.1.7.5, it says 10ms for hub and 50ms for\r
104 // root hub]\r
105 //\r
106 USB_SET_PORT_RESET_STALL = 20 * USB_BUS_1_MILLISECOND,\r
107 USB_SET_ROOT_PORT_RESET_STALL = 50 * USB_BUS_1_MILLISECOND,\r
108\r
109 //\r
110 // Wait for clear roothub port reset, set by experience\r
111 //\r
112 USB_CLR_ROOT_PORT_RESET_STALL = 1 * USB_BUS_1_MILLISECOND,\r
113\r
114 //\r
115 // Wait for set roothub port enable, set by experience\r
116 //\r
117 USB_SET_ROOT_PORT_ENABLE_STALL = 20 * USB_BUS_1_MILLISECOND,\r
118\r
119 //\r
120 // Send general device request timeout, refers to\r
121 // specification[USB20-11.24.1]\r
122 //\r
123 USB_GENERAL_DEVICE_REQUEST_TIMEOUT = 50 * USB_BUS_1_MILLISECOND,\r
124\r
125 //\r
126 // Send clear feature request timeout, set by experience\r
127 //\r
128 USB_CLEAR_FEATURE_REQUEST_TIMEOUT = 10 * USB_BUS_1_MILLISECOND,\r
129\r
130 //\r
131 // Bus raises TPL to TPL_NOTIFY to serialize all its operations\r
132 // to protect shared data structures.\r
133 //\r
134 USB_BUS_TPL = TPL_NOTIFY,\r
135\r
136 USB_INTERFACE_SIGNATURE = EFI_SIGNATURE_32 ('U', 'S', 'B', 'I'),\r
137 USB_BUS_SIGNATURE = EFI_SIGNATURE_32 ('U', 'S', 'B', 'B')\r
138};\r
139\r
140#define USB_BIT(a) ((UINTN)(1 << (a)))\r
141#define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))\r
142\r
143#define EFI_USB_BUS_PROTOCOL_GUID \\r
144 {0x2B2F68CC, 0x0CD2, 0x44cf, {0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75}}\r
145\r
146#define USB_INTERFACE_FROM_USBIO(a) \\r
147 CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE)\r
148\r
149#define USB_BUS_FROM_THIS(a) \\r
150 CR(a, USB_BUS, BusId, USB_BUS_SIGNATURE)\r
151\r
152//\r
153// Used to locate USB_BUS\r
154//\r
155typedef struct _EFI_USB_BUS_PROTOCOL {\r
156 UINT64 Reserved;\r
157} EFI_USB_BUS_PROTOCOL;\r
158\r
159\r
160//\r
161// Stands for the real USB device. Each device may\r
162// has several seperately working interfaces.\r
163//\r
164struct _USB_DEVICE {\r
165 USB_BUS *Bus;\r
166\r
167 //\r
168 // Configuration information\r
169 //\r
170 UINT8 Speed;\r
171 UINT8 Address;\r
172 UINT8 MaxPacket0;\r
173\r
174 //\r
175 // The device's descriptors and its configuration\r
176 //\r
177 USB_DEVICE_DESC *DevDesc;\r
178 USB_CONFIG_DESC *ActiveConfig;\r
179\r
180 UINT16 LangId [USB_MAX_LANG_ID];\r
181 UINT16 TotalLangId;\r
182\r
183 UINT8 NumOfInterface;\r
184 USB_INTERFACE *Interfaces [USB_MAX_INTERFACE];\r
185\r
186 //\r
187 // Parent child relationship\r
188 //\r
189 EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;\r
190\r
191 UINT8 ParentAddr;\r
192 USB_INTERFACE *ParentIf;\r
193 UINT8 ParentPort; // Start at 0\r
194};\r
195\r
196//\r
197// Stands for different functions of USB device\r
198//\r
199struct _USB_INTERFACE {\r
200 UINTN Signature;\r
201 USB_DEVICE *Device;\r
202 USB_INTERFACE_DESC *IfDesc;\r
203 USB_INTERFACE_SETTING *IfSetting;\r
204\r
205 //\r
206 // Handles and protocols\r
207 //\r
208 EFI_HANDLE Handle;\r
209 EFI_USB_IO_PROTOCOL UsbIo;\r
210 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
211 BOOLEAN IsManaged;\r
212\r
213 //\r
214 // Hub device special data\r
215 //\r
216 BOOLEAN IsHub;\r
217 USB_HUB_API *HubApi;\r
218 UINT8 NumOfPort;\r
219 EFI_EVENT HubNotify;\r
220\r
221 //\r
222 // Data used only by normal hub devices\r
223 //\r
224 USB_ENDPOINT_DESC *HubEp;\r
225 UINT8 *ChangeMap;\r
226\r
227 //\r
228 // Data used only by root hub to hand over device to\r
229 // companion UHCI driver if low/full speed devices are\r
230 // connected to EHCI.\r
231 //\r
232 UINT8 MaxSpeed;\r
233};\r
234\r
235//\r
236// Stands for the current USB Bus\r
237//\r
238struct _USB_BUS {\r
239 UINTN Signature;\r
240 EFI_USB_BUS_PROTOCOL BusId;\r
241\r
242 //\r
243 // Managed USB host controller\r
244 //\r
245 EFI_HANDLE HostHandle;\r
246 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
247 EFI_USB2_HC_PROTOCOL *Usb2Hc;\r
248 EFI_USB_HC_PROTOCOL *UsbHc;\r
249\r
250 //\r
251 // An array of device that is on the bus. Devices[0] is\r
252 // for root hub. Device with address i is at Devices[i].\r
253 //\r
254 USB_DEVICE *Devices[USB_MAX_DEVICES];\r
255\r
256 //\r
257 // USB Bus driver need to control the recursive connect policy of the bus, only those wanted\r
258 // usb child device will be recursively connected.\r
259 //\r
260 // WantedUsbIoDPList tracks the Usb child devices which user want to recursivly fully connecte,\r
261 // every wanted child device is stored in a item of the WantedUsbIoDPList, whose structrure is\r
262 // DEVICE_PATH_LIST_ITEM\r
263 //\r
264 LIST_ENTRY WantedUsbIoDPList;\r
265\r
266};\r
267\r
268#define USB_US_LAND_ID 0x0409\r
269\r
270#define DEVICE_PATH_LIST_ITEM_SIGNATURE EFI_SIGNATURE_32('d','p','l','i')\r
271typedef struct _DEVICE_PATH_LIST_ITEM{\r
272 UINTN Signature;\r
273 LIST_ENTRY Link;\r
274 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
275} DEVICE_PATH_LIST_ITEM;\r
276\r
277typedef struct {\r
278 USB_CLASS_DEVICE_PATH UsbClass;\r
279 EFI_DEVICE_PATH_PROTOCOL End;\r
280} USB_CLASS_FORMAT_DEVICE_PATH;\r
281\r
282EFI_STATUS\r
283EFIAPI\r
284UsbBusFreeUsbDPList (\r
285 IN LIST_ENTRY *UsbIoDPList\r
286 );\r
287\r
288EFI_STATUS\r
289EFIAPI\r
290UsbBusAddWantedUsbIoDP (\r
291 IN EFI_USB_BUS_PROTOCOL *UsbBusId,\r
292 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
293 );\r
294\r
295BOOLEAN\r
296EFIAPI\r
297UsbBusIsWantedUsbIO (\r
298 IN USB_BUS *Bus,\r
299 IN USB_INTERFACE *UsbIf\r
300 );\r
301\r
302EFI_STATUS\r
303EFIAPI\r
304UsbBusRecursivelyConnectWantedUsbIo (\r
305 IN EFI_USB_BUS_PROTOCOL *UsbBusId\r
306 );\r
307\r
308extern EFI_USB_IO_PROTOCOL mUsbIoProtocol;\r
309extern EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding;\r
310extern EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName;\r
311extern EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2;\r
312\r
313#endif\r