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_
28 // The package level header files this module uses
32 // The protocols, PPI and GUID defintions for this module
34 #include <Protocol/Usb2HostController.h>
35 #include <Protocol/UsbHostController.h>
36 #include <Protocol/UsbIo.h>
37 #include <Protocol/DevicePath.h>
39 // The Library classes this module consumes
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>
50 #include <IndustryStandard/Usb.h>
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
;
58 #include "UsbUtility.h"
61 #include "UsbEnumer.h"
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,
76 USB_MAX_INTERFACE
= 16,
77 USB_MAX_DEVICES
= 128,
80 // Bus raises TPL to TPL_NOTIFY to serialize all its operations
81 // to protect shared data structures.
83 USB_BUS_TPL
= TPL_NOTIFY
,
85 USB_INTERFACE_SIGNATURE
= EFI_SIGNATURE_32 ('U', 'S', 'B', 'I'),
86 USB_BUS_SIGNATURE
= EFI_SIGNATURE_32 ('U', 'S', 'B', 'B')
89 #define USB_BIT(a) ((UINTN)(1 << (a)))
90 #define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
92 #define EFI_USB_BUS_PROTOCOL_GUID \
93 {0x2B2F68CC, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75}
95 #define USB_INTERFACE_FROM_USBIO(a) \
96 CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE)
98 #define USB_BUS_FROM_THIS(a) \
99 CR(a, USB_BUS, BusId, USB_BUS_SIGNATURE)
102 // Used to locate USB_BUS
104 typedef struct _EFI_USB_BUS_PROTOCOL
{
106 } EFI_USB_BUS_PROTOCOL
;
110 // Stands for the real USB device. Each device may
111 // has several seperately working interfaces.
117 // Configuration information
124 // The device's descriptors and its configuration
126 USB_DEVICE_DESC
*DevDesc
;
127 USB_CONFIG_DESC
*ActiveConfig
;
129 UINT16 LangId
[USB_MAX_LANG_ID
];
132 UINT8 NumOfInterface
;
133 USB_INTERFACE
*Interfaces
[USB_MAX_INTERFACE
];
136 // Parent child relationship
138 EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator
;
141 USB_INTERFACE
*ParentIf
;
142 UINT8 ParentPort
; // Start at 0
146 // Stands for different functions of USB device
148 struct _USB_INTERFACE
{
151 USB_INTERFACE_DESC
*IfDesc
;
152 USB_INTERFACE_SETTING
*IfSetting
;
155 // Handles and protocols
158 EFI_USB_IO_PROTOCOL UsbIo
;
159 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
163 // Hub device special data
171 // Data used only by normal hub devices
173 USB_ENDPOINT_DESC
*HubEp
;
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.
185 // Stands for the current USB Bus
189 EFI_USB_BUS_PROTOCOL BusId
;
192 // Managed USB host controller
194 EFI_HANDLE HostHandle
;
195 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
196 EFI_USB2_HC_PROTOCOL
*Usb2Hc
;
197 EFI_USB_HC_PROTOCOL
*UsbHc
;
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].
203 USB_DEVICE
*Devices
[USB_MAX_DEVICES
];
206 extern EFI_USB_IO_PROTOCOL mUsbIoProtocol
;
207 extern EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding
;
208 extern EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName
;