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