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