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