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
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.
17 Usb Bus Driver Binding and Bus IO Protocol
24 #ifndef _EFI_USB_BUS_H_
25 #define _EFI_USB_BUS_H_
30 #include <Protocol/Usb2HostController.h>
31 #include <Protocol/UsbHostController.h>
32 #include <Protocol/UsbIo.h>
33 #include <Protocol/DevicePath.h>
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>
44 #include <IndustryStandard/Usb.h>
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
;
52 #include "UsbUtility.h"
55 #include "UsbEnumer.h"
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,
70 USB_MAX_INTERFACE
= 16,
71 USB_MAX_DEVICES
= 128,
74 // Bus raises TPL to TPL_NOTIFY to serialize all its operations
75 // to protect shared data structures.
77 USB_BUS_TPL
= TPL_NOTIFY
,
79 USB_INTERFACE_SIGNATURE
= EFI_SIGNATURE_32 ('U', 'S', 'B', 'I'),
80 USB_BUS_SIGNATURE
= EFI_SIGNATURE_32 ('U', 'S', 'B', 'B')
83 #define USB_BIT(a) ((UINTN)(1 << (a)))
84 #define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
86 #define EFI_USB_BUS_PROTOCOL_GUID \
87 {0x2B2F68CC, 0x0CD2, 0x44cf, {0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75}}
89 #define USB_INTERFACE_FROM_USBIO(a) \
90 CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE)
92 #define USB_BUS_FROM_THIS(a) \
93 CR(a, USB_BUS, BusId, USB_BUS_SIGNATURE)
96 // Used to locate USB_BUS
98 typedef struct _EFI_USB_BUS_PROTOCOL
{
100 } EFI_USB_BUS_PROTOCOL
;
104 // Stands for the real USB device. Each device may
105 // has several seperately working interfaces.
111 // Configuration information
118 // The device's descriptors and its configuration
120 USB_DEVICE_DESC
*DevDesc
;
121 USB_CONFIG_DESC
*ActiveConfig
;
123 UINT16 LangId
[USB_MAX_LANG_ID
];
126 UINT8 NumOfInterface
;
127 USB_INTERFACE
*Interfaces
[USB_MAX_INTERFACE
];
130 // Parent child relationship
132 EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator
;
135 USB_INTERFACE
*ParentIf
;
136 UINT8 ParentPort
; // Start at 0
140 // Stands for different functions of USB device
142 struct _USB_INTERFACE
{
145 USB_INTERFACE_DESC
*IfDesc
;
146 USB_INTERFACE_SETTING
*IfSetting
;
149 // Handles and protocols
152 EFI_USB_IO_PROTOCOL UsbIo
;
153 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
157 // Hub device special data
165 // Data used only by normal hub devices
167 USB_ENDPOINT_DESC
*HubEp
;
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.
179 // Stands for the current USB Bus
183 EFI_USB_BUS_PROTOCOL BusId
;
186 // Managed USB host controller
188 EFI_HANDLE HostHandle
;
189 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
190 EFI_USB2_HC_PROTOCOL
*Usb2Hc
;
191 EFI_USB_HC_PROTOCOL
*UsbHc
;
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].
197 USB_DEVICE
*Devices
[USB_MAX_DEVICES
];
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
;