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