]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.h
modify coding style to pass ecc tool and provide comments that complied with Doxgen.
[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 struct _USB_HUB_API{
95 USB_HUB_INIT Init;
96 USB_HUB_GET_PORT_STATUS GetPortStatus;
97 USB_HUB_CLEAR_PORT_CHANGE ClearPortChange;
98 USB_HUB_SET_PORT_FEATURE SetPortFeature;
99 USB_HUB_CLEAR_PORT_FEATURE ClearPortFeature;
100 USB_HUB_RESET_PORT ResetPort;
101 USB_HUB_RELEASE Release;
102 };
103
104 /**
105 Return the endpoint descriptor in this interface.
106
107 @param UsbIf The interface to search in.
108 @param EpAddr The address of the endpoint to return.
109
110 @return The endpoint descriptor or NULL.
111
112 **/
113 USB_ENDPOINT_DESC*
114 UsbGetEndpointDesc (
115 IN USB_INTERFACE *UsbIf,
116 IN UINT8 EpAddr
117 );
118
119 /**
120 Select an alternate setting for the interface.
121 Each interface can have several mutually exclusive
122 settings. Only one setting is active. It will
123 also reset its endpoints' toggle to zero.
124
125 @param IfDesc The interface descriptor to set.
126 @param Alternate The alternate setting number to locate.
127
128 @retval EFI_NOT_FOUND There is no setting with this alternate index.
129 @retval EFI_SUCCESS The interface is set to Alternate setting.
130
131 **/
132 EFI_STATUS
133 UsbSelectSetting (
134 IN USB_INTERFACE_DESC *IfDesc,
135 IN UINT8 Alternate
136 );
137
138 /**
139 Select a new configuration for the device. Each
140 device may support several configurations.
141
142 @param Device The device to select configuration.
143 @param ConfigIndex The index of the configuration ( != 0).
144
145 @retval EFI_NOT_FOUND There is no configuration with the index.
146 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
147 @retval EFI_SUCCESS The configuration is selected.
148
149 **/
150 EFI_STATUS
151 UsbSelectConfig (
152 IN USB_DEVICE *Device,
153 IN UINT8 ConfigIndex
154 );
155
156 /**
157 Remove the current device configuration.
158
159 @param Device The USB device to remove configuration from.
160
161 @return None.
162
163 **/
164 VOID
165 UsbRemoveConfig (
166 IN USB_DEVICE *Device
167 );
168
169 /**
170 Remove the device and all its children from the bus.
171
172 @param Device The device to remove.
173
174 @retval EFI_SUCCESS The device is removed.
175
176 **/
177 EFI_STATUS
178 UsbRemoveDevice (
179 IN USB_DEVICE *Device
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 UsbHubEnumeration (
194 IN EFI_EVENT Event,
195 IN VOID *Context
196 );
197
198 /**
199 Enumerate all the changed hub ports.
200
201 @param Event The event that is triggered.
202 @param Context The context to the event.
203
204 @return None.
205
206 **/
207 VOID
208 EFIAPI
209 UsbRootHubEnumeration (
210 IN EFI_EVENT Event,
211 IN VOID *Context
212 );
213 #endif