]>
Commit | Line | Data |
---|---|---|
e237e7ae | 1 | /** @file\r |
2 | Copyright (c) 2004 - 2007, Intel Corporation\r | |
3 | All rights reserved. This program and the accompanying materials\r | |
4 | are licensed and made available under the terms and conditions of the BSD License\r | |
5 | which accompanies this distribution. The full text of the license may be found at\r | |
6 | http://opensource.org/licenses/bsd-license.php\r | |
7 | \r | |
8 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
9 | WITHOUT 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 | // The package level header files this module uses\r | |
29 | //\r | |
30 | #include <PiDxe.h>\r | |
31 | //\r | |
32 | // The protocols, PPI and GUID defintions for this module\r | |
33 | //\r | |
34 | #include <Protocol/Usb2HostController.h>\r | |
35 | #include <Protocol/UsbHostController.h>\r | |
36 | #include <Protocol/UsbIo.h>\r | |
37 | #include <Protocol/DevicePath.h>\r | |
38 | //\r | |
39 | // The Library classes this module consumes\r | |
40 | //\r | |
41 | #include <Library/DebugLib.h>\r | |
42 | #include <Library/BaseMemoryLib.h>\r | |
43 | #include <Library/UefiDriverEntryPoint.h>\r | |
44 | #include <Library/UefiBootServicesTableLib.h>\r | |
45 | #include <Library/UefiLib.h>\r | |
46 | #include <Library/DevicePathLib.h>\r | |
47 | #include <Library/MemoryAllocationLib.h>\r | |
48 | \r | |
49 | \r | |
50 | #include <IndustryStandard/Usb.h>\r | |
51 | \r | |
52 | typedef struct _USB_DEVICE USB_DEVICE;\r | |
53 | typedef struct _USB_INTERFACE USB_INTERFACE;\r | |
54 | typedef struct _USB_BUS USB_BUS;\r | |
55 | typedef struct _USB_HUB_API USB_HUB_API;\r | |
56 | \r | |
57 | \r | |
58 | #include "UsbUtility.h"\r | |
59 | #include "UsbDesc.h"\r | |
60 | #include "UsbHub.h"\r | |
61 | #include "UsbEnumer.h"\r | |
62 | \r | |
63 | enum {\r | |
64 | //\r | |
65 | // Time definition\r | |
66 | //\r | |
67 | USB_STALL_1_MS = 1000,\r | |
68 | TICKS_PER_MS = 10000U,\r | |
69 | USB_ROOTHUB_POLL_INTERVAL = 1000 * TICKS_PER_MS,\r | |
70 | USB_HUB_POLL_INTERVAL = 64,\r | |
71 | \r | |
72 | //\r | |
73 | // Maximum definition\r | |
74 | //\r | |
75 | USB_MAX_LANG_ID = 16,\r | |
76 | USB_MAX_INTERFACE = 16,\r | |
77 | USB_MAX_DEVICES = 128,\r | |
78 | \r | |
79 | //\r | |
80 | // Bus raises TPL to TPL_NOTIFY to serialize all its operations\r | |
81 | // to protect shared data structures.\r | |
82 | //\r | |
83 | USB_BUS_TPL = TPL_NOTIFY,\r | |
84 | \r | |
85 | USB_INTERFACE_SIGNATURE = EFI_SIGNATURE_32 ('U', 'S', 'B', 'I'),\r | |
c52fa98c | 86 | USB_BUS_SIGNATURE = EFI_SIGNATURE_32 ('U', 'S', 'B', 'B')\r |
e237e7ae | 87 | };\r |
88 | \r | |
89 | #define USB_BIT(a) ((UINTN)(1 << (a)))\r | |
90 | #define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))\r | |
91 | \r | |
92 | #define EFI_USB_BUS_PROTOCOL_GUID \\r | |
93 | {0x2B2F68CC, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75}\r | |
94 | \r | |
95 | #define USB_INTERFACE_FROM_USBIO(a) \\r | |
96 | CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE)\r | |
97 | \r | |
98 | #define USB_BUS_FROM_THIS(a) \\r | |
99 | CR(a, USB_BUS, BusId, USB_BUS_SIGNATURE)\r | |
100 | \r | |
101 | //\r | |
102 | // Used to locate USB_BUS\r | |
103 | //\r | |
104 | typedef struct _EFI_USB_BUS_PROTOCOL {\r | |
105 | UINT64 Reserved;\r | |
106 | } EFI_USB_BUS_PROTOCOL;\r | |
107 | \r | |
108 | \r | |
109 | //\r | |
110 | // Stands for the real USB device. Each device may\r | |
111 | // has several seperately working interfaces.\r | |
112 | //\r | |
c52fa98c | 113 | struct _USB_DEVICE {\r |
e237e7ae | 114 | USB_BUS *Bus;\r |
115 | \r | |
116 | //\r | |
117 | // Configuration information\r | |
118 | //\r | |
119 | UINT8 Speed;\r | |
120 | UINT8 Address;\r | |
121 | UINT8 MaxPacket0;\r | |
122 | \r | |
123 | //\r | |
124 | // The device's descriptors and its configuration\r | |
125 | //\r | |
126 | USB_DEVICE_DESC *DevDesc;\r | |
127 | USB_CONFIG_DESC *ActiveConfig;\r | |
128 | \r | |
129 | UINT16 LangId [USB_MAX_LANG_ID];\r | |
130 | UINT16 TotalLangId;\r | |
131 | \r | |
132 | UINT8 NumOfInterface;\r | |
133 | USB_INTERFACE *Interfaces [USB_MAX_INTERFACE];\r | |
134 | \r | |
135 | //\r | |
136 | // Parent child relationship\r | |
137 | //\r | |
138 | EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;\r | |
139 | \r | |
140 | UINT8 ParentAddr;\r | |
141 | USB_INTERFACE *ParentIf;\r | |
142 | UINT8 ParentPort; // Start at 0\r | |
c52fa98c | 143 | };\r |
e237e7ae | 144 | \r |
145 | //\r | |
146 | // Stands for different functions of USB device\r | |
147 | //\r | |
c52fa98c | 148 | struct _USB_INTERFACE {\r |
e237e7ae | 149 | UINTN Signature;\r |
150 | USB_DEVICE *Device;\r | |
151 | USB_INTERFACE_DESC *IfDesc;\r | |
152 | USB_INTERFACE_SETTING *IfSetting;\r | |
153 | \r | |
154 | //\r | |
155 | // Handles and protocols\r | |
156 | //\r | |
157 | EFI_HANDLE Handle;\r | |
158 | EFI_USB_IO_PROTOCOL UsbIo;\r | |
159 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
160 | BOOLEAN IsManaged;\r | |
161 | \r | |
162 | //\r | |
163 | // Hub device special data\r | |
164 | //\r | |
165 | BOOLEAN IsHub;\r | |
166 | USB_HUB_API *HubApi;\r | |
167 | UINT8 NumOfPort;\r | |
168 | EFI_EVENT HubNotify;\r | |
169 | \r | |
170 | //\r | |
171 | // Data used only by normal hub devices\r | |
172 | //\r | |
173 | USB_ENDPOINT_DESC *HubEp;\r | |
174 | UINT8 *ChangeMap;\r | |
175 | \r | |
176 | //\r | |
177 | // Data used only by root hub to hand over device to\r | |
178 | // companion UHCI driver if low/full speed devices are\r | |
179 | // connected to EHCI.\r | |
180 | //\r | |
181 | UINT8 MaxSpeed;\r | |
c52fa98c | 182 | };\r |
e237e7ae | 183 | \r |
184 | //\r | |
185 | // Stands for the current USB Bus\r | |
186 | //\r | |
c52fa98c | 187 | struct _USB_BUS {\r |
e237e7ae | 188 | UINTN Signature;\r |
189 | EFI_USB_BUS_PROTOCOL BusId;\r | |
190 | \r | |
191 | //\r | |
192 | // Managed USB host controller\r | |
193 | //\r | |
194 | EFI_HANDLE HostHandle;\r | |
195 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
196 | EFI_USB2_HC_PROTOCOL *Usb2Hc;\r | |
197 | EFI_USB_HC_PROTOCOL *UsbHc;\r | |
198 | \r | |
199 | //\r | |
200 | // An array of device that is on the bus. Devices[0] is\r | |
201 | // for root hub. Device with address i is at Devices[i].\r | |
202 | //\r | |
203 | USB_DEVICE *Devices[USB_MAX_DEVICES];\r | |
c52fa98c | 204 | };\r |
e237e7ae | 205 | \r |
206 | extern EFI_USB_IO_PROTOCOL mUsbIoProtocol;\r | |
207 | extern EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding;\r | |
208 | extern EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName;\r | |
209 | \r | |
210 | #endif\r |