]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.h
a528e43a2303741604ff86fa234400925c42b4aa
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbEnumer.h
1 /** @file
2
3 USB bus enumeration interface.
4
5 Copyright (c) 2007, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _USB_ENUMERATION_H_
17 #define _USB_ENUMERATION_H_
18
19 //
20 // Advance the byte and bit to the next bit, adjust byte accordingly.
21 //
22 #define USB_NEXT_BIT(Byte, Bit) \
23 do { \
24 (Bit)++; \
25 if ((Bit) > 7) { \
26 (Byte)++; \
27 (Bit) = 0; \
28 } \
29 } while (0)
30
31
32 //
33 // Common interface used by usb bus enumeration process.
34 // This interface is defined to mask the difference between
35 // the root hub and normal hub. So, bus enumeration code
36 // can be shared by both root hub and normal hub
37 //
38 typedef
39 EFI_STATUS
40 (*USB_HUB_INIT) (
41 IN USB_INTERFACE *UsbIf
42 );
43
44 //
45 // Get the port status. This function is required to
46 // ACK the port change bits although it will return
47 // the port changes in PortState. Bus enumeration code
48 // doesn't need to ACK the port change bits.
49 //
50 typedef
51 EFI_STATUS
52 (*USB_HUB_GET_PORT_STATUS) (
53 IN USB_INTERFACE *UsbIf,
54 IN UINT8 Port,
55 OUT EFI_USB_PORT_STATUS *PortState
56 );
57
58 typedef
59 VOID
60 (*USB_HUB_CLEAR_PORT_CHANGE) (
61 IN USB_INTERFACE *HubIf,
62 IN UINT8 Port
63 );
64
65 typedef
66 EFI_STATUS
67 (*USB_HUB_SET_PORT_FEATURE) (
68 IN USB_INTERFACE *UsbIf,
69 IN UINT8 Port,
70 IN EFI_USB_PORT_FEATURE Feature
71 );
72
73 typedef
74 EFI_STATUS
75 (*USB_HUB_CLEAR_PORT_FEATURE) (
76 IN USB_INTERFACE *UsbIf,
77 IN UINT8 Port,
78 IN EFI_USB_PORT_FEATURE Feature
79 );
80
81 typedef
82 EFI_STATUS
83 (*USB_HUB_RESET_PORT) (
84 IN USB_INTERFACE *UsbIf,
85 IN UINT8 Port
86 );
87
88 typedef
89 EFI_STATUS
90 (*USB_HUB_RELEASE) (
91 IN USB_INTERFACE *UsbIf
92 );
93
94 /**
95 Return the endpoint descriptor in this interface.
96
97 @param UsbIf The interface to search in.
98 @param EpAddr The address of the endpoint to return.
99
100 @return The endpoint descriptor or NULL.
101
102 **/
103 USB_ENDPOINT_DESC*
104 UsbGetEndpointDesc (
105 IN USB_INTERFACE *UsbIf,
106 IN UINT8 EpAddr
107 );
108
109 /**
110 Select an alternate setting for the interface.
111 Each interface can have several mutually exclusive
112 settings. Only one setting is active. It will
113 also reset its endpoints' toggle to zero.
114
115 @param IfDesc The interface descriptor to set.
116 @param Alternate The alternate setting number to locate.
117
118 @retval EFI_NOT_FOUND There is no setting with this alternate index.
119 @retval EFI_SUCCESS The interface is set to Alternate setting.
120
121 **/
122 EFI_STATUS
123 UsbSelectSetting (
124 IN USB_INTERFACE_DESC *IfDesc,
125 IN UINT8 Alternate
126 );
127
128 /**
129 Select a new configuration for the device. Each
130 device may support several configurations.
131
132 @param Device The device to select configuration.
133 @param ConfigIndex The index of the configuration ( != 0).
134
135 @retval EFI_NOT_FOUND There is no configuration with the index.
136 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
137 @retval EFI_SUCCESS The configuration is selected.
138
139 **/
140 EFI_STATUS
141 UsbSelectConfig (
142 IN USB_DEVICE *Device,
143 IN UINT8 ConfigIndex
144 );
145
146 /**
147 Remove the current device configuration.
148
149 @param Device The USB device to remove configuration from.
150
151 @return None.
152
153 **/
154 VOID
155 UsbRemoveConfig (
156 IN USB_DEVICE *Device
157 );
158
159 /**
160 Remove the device and all its children from the bus.
161
162 @param Device The device to remove.
163
164 @retval EFI_SUCCESS The device is removed.
165
166 **/
167 EFI_STATUS
168 UsbRemoveDevice (
169 IN USB_DEVICE *Device
170 );
171
172 /**
173 Enumerate all the changed hub ports.
174
175 @param Event The event that is triggered.
176 @param Context The context to the event.
177
178 @return None.
179
180 **/
181 VOID
182 EFIAPI
183 UsbHubEnumeration (
184 IN EFI_EVENT Event,
185 IN VOID *Context
186 );
187
188 /**
189 Enumerate all the changed hub ports.
190
191 @param Event The event that is triggered.
192 @param Context The context to the event.
193
194 @return None.
195
196 **/
197 VOID
198 EFIAPI
199 UsbRootHubEnumeration (
200 IN EFI_EVENT Event,
201 IN VOID *Context
202 );
203 #endif