]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/EhciDxe/ComponentName.c
Save original PCI attributes in start() function and restore it in Stop() for those...
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / ComponentName.c
1 /** @file
2
3 Copyright (c) 2006 - 2007, Intel Corporation
4
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution. The
8 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 Module Name:
15
16 ComponentName.c
17
18 Abstract:
19
20
21 **/
22
23 #include "Ehci.h"
24
25 //
26 // EFI Component Name Functions
27 //
28 /**
29 Retrieves a Unicode string that is the user readable name of the driver.
30
31 This function retrieves the user readable name of a driver in the form of a
32 Unicode string. If the driver specified by This has a user readable name in
33 the language specified by Language, then a pointer to the driver name is
34 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
35 by This does not support the language specified by Language,
36 then EFI_UNSUPPORTED is returned.
37
38 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
39 EFI_COMPONENT_NAME_PROTOCOL instance.
40
41 @param Language[in] A pointer to a Null-terminated ASCII string
42 array indicating the language. This is the
43 language of the driver name that the caller is
44 requesting, and it must match one of the
45 languages specified in SupportedLanguages. The
46 number of languages supported by a driver is up
47 to the driver writer. Language is specified
48 in RFC 3066 or ISO 639-2 language code format.
49
50 @param DriverName[out] A pointer to the Unicode string to return.
51 This Unicode string is the name of the
52 driver specified by This in the language
53 specified by Language.
54
55 @retval EFI_SUCCESS The Unicode string for the Driver specified by
56 This and the language specified by Language was
57 returned in DriverName.
58
59 @retval EFI_INVALID_PARAMETER Language is NULL.
60
61 @retval EFI_INVALID_PARAMETER DriverName is NULL.
62
63 @retval EFI_UNSUPPORTED The driver specified by This does not support
64 the language specified by Language.
65
66 **/
67 EFI_STATUS
68 EFIAPI
69 EhciComponentNameGetDriverName (
70 IN EFI_COMPONENT_NAME_PROTOCOL *This,
71 IN CHAR8 *Language,
72 OUT CHAR16 **DriverName
73 );
74
75
76 /**
77 Retrieves a Unicode string that is the user readable name of the controller
78 that is being managed by a driver.
79
80 This function retrieves the user readable name of the controller specified by
81 ControllerHandle and ChildHandle in the form of a Unicode string. If the
82 driver specified by This has a user readable name in the language specified by
83 Language, then a pointer to the controller name is returned in ControllerName,
84 and EFI_SUCCESS is returned. If the driver specified by This is not currently
85 managing the controller specified by ControllerHandle and ChildHandle,
86 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
87 support the language specified by Language, then EFI_UNSUPPORTED is returned.
88
89 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
90 EFI_COMPONENT_NAME_PROTOCOL instance.
91
92 @param ControllerHandle[in] The handle of a controller that the driver
93 specified by This is managing. This handle
94 specifies the controller whose name is to be
95 returned.
96
97 @param ChildHandle[in] The handle of the child controller to retrieve
98 the name of. This is an optional parameter that
99 may be NULL. It will be NULL for device
100 drivers. It will also be NULL for a bus drivers
101 that wish to retrieve the name of the bus
102 controller. It will not be NULL for a bus
103 driver that wishes to retrieve the name of a
104 child controller.
105
106 @param Language[in] A pointer to a Null-terminated ASCII string
107 array indicating the language. This is the
108 language of the driver name that the caller is
109 requesting, and it must match one of the
110 languages specified in SupportedLanguages. The
111 number of languages supported by a driver is up
112 to the driver writer. Language is specified in
113 RFC 3066 or ISO 639-2 language code format.
114
115 @param ControllerName[out] A pointer to the Unicode string to return.
116 This Unicode string is the name of the
117 controller specified by ControllerHandle and
118 ChildHandle in the language specified by
119 Language from the point of view of the driver
120 specified by This.
121
122 @retval EFI_SUCCESS The Unicode string for the user readable name in
123 the language specified by Language for the
124 driver specified by This was returned in
125 DriverName.
126
127 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
128
129 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
130 EFI_HANDLE.
131
132 @retval EFI_INVALID_PARAMETER Language is NULL.
133
134 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
135
136 @retval EFI_UNSUPPORTED The driver specified by This is not currently
137 managing the controller specified by
138 ControllerHandle and ChildHandle.
139
140 @retval EFI_UNSUPPORTED The driver specified by This does not support
141 the language specified by Language.
142
143 **/
144 EFI_STATUS
145 EFIAPI
146 EhciComponentNameGetControllerName (
147 IN EFI_COMPONENT_NAME_PROTOCOL *This,
148 IN EFI_HANDLE ControllerHandle,
149 IN EFI_HANDLE ChildHandle OPTIONAL,
150 IN CHAR8 *Language,
151 OUT CHAR16 **ControllerName
152 );
153
154
155 //
156 // EFI Component Name Protocol
157 //
158 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName = {
159 EhciComponentNameGetDriverName,
160 EhciComponentNameGetControllerName,
161 "eng"
162 };
163
164 //
165 // EFI Component Name 2 Protocol
166 //
167 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2 = {
168 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EhciComponentNameGetDriverName,
169 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EhciComponentNameGetControllerName,
170 "en"
171 };
172
173
174 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEhciDriverNameTable[] = {
175 { "eng;en", L"Usb Ehci Driver" },
176 { NULL , NULL }
177 };
178
179 /**
180 Retrieves a Unicode string that is the user readable name of the driver.
181
182 This function retrieves the user readable name of a driver in the form of a
183 Unicode string. If the driver specified by This has a user readable name in
184 the language specified by Language, then a pointer to the driver name is
185 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
186 by This does not support the language specified by Language,
187 then EFI_UNSUPPORTED is returned.
188
189 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
190 EFI_COMPONENT_NAME_PROTOCOL instance.
191
192 @param Language[in] A pointer to a Null-terminated ASCII string
193 array indicating the language. This is the
194 language of the driver name that the caller is
195 requesting, and it must match one of the
196 languages specified in SupportedLanguages. The
197 number of languages supported by a driver is up
198 to the driver writer. Language is specified
199 in RFC 3066 or ISO 639-2 language code format.
200
201 @param DriverName[out] A pointer to the Unicode string to return.
202 This Unicode string is the name of the
203 driver specified by This in the language
204 specified by Language.
205
206 @retval EFI_SUCCESS The Unicode string for the Driver specified by
207 This and the language specified by Language was
208 returned in DriverName.
209
210 @retval EFI_INVALID_PARAMETER Language is NULL.
211
212 @retval EFI_INVALID_PARAMETER DriverName is NULL.
213
214 @retval EFI_UNSUPPORTED The driver specified by This does not support
215 the language specified by Language.
216
217 **/
218 EFI_STATUS
219 EFIAPI
220 EhciComponentNameGetDriverName (
221 IN EFI_COMPONENT_NAME_PROTOCOL *This,
222 IN CHAR8 *Language,
223 OUT CHAR16 **DriverName
224 )
225 {
226 return LookupUnicodeString2 (
227 Language,
228 This->SupportedLanguages,
229 mEhciDriverNameTable,
230 DriverName,
231 (BOOLEAN)(This == &gEhciComponentName)
232 );
233 }
234
235 /**
236 Retrieves a Unicode string that is the user readable name of the controller
237 that is being managed by a driver.
238
239 This function retrieves the user readable name of the controller specified by
240 ControllerHandle and ChildHandle in the form of a Unicode string. If the
241 driver specified by This has a user readable name in the language specified by
242 Language, then a pointer to the controller name is returned in ControllerName,
243 and EFI_SUCCESS is returned. If the driver specified by This is not currently
244 managing the controller specified by ControllerHandle and ChildHandle,
245 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
246 support the language specified by Language, then EFI_UNSUPPORTED is returned.
247
248 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
249 EFI_COMPONENT_NAME_PROTOCOL instance.
250
251 @param ControllerHandle[in] The handle of a controller that the driver
252 specified by This is managing. This handle
253 specifies the controller whose name is to be
254 returned.
255
256 @param ChildHandle[in] The handle of the child controller to retrieve
257 the name of. This is an optional parameter that
258 may be NULL. It will be NULL for device
259 drivers. It will also be NULL for a bus drivers
260 that wish to retrieve the name of the bus
261 controller. It will not be NULL for a bus
262 driver that wishes to retrieve the name of a
263 child controller.
264
265 @param Language[in] A pointer to a Null-terminated ASCII string
266 array indicating the language. This is the
267 language of the driver name that the caller is
268 requesting, and it must match one of the
269 languages specified in SupportedLanguages. The
270 number of languages supported by a driver is up
271 to the driver writer. Language is specified in
272 RFC 3066 or ISO 639-2 language code format.
273
274 @param ControllerName[out] A pointer to the Unicode string to return.
275 This Unicode string is the name of the
276 controller specified by ControllerHandle and
277 ChildHandle in the language specified by
278 Language from the point of view of the driver
279 specified by This.
280
281 @retval EFI_SUCCESS The Unicode string for the user readable name in
282 the language specified by Language for the
283 driver specified by This was returned in
284 DriverName.
285
286 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
287
288 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
289 EFI_HANDLE.
290
291 @retval EFI_INVALID_PARAMETER Language is NULL.
292
293 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
294
295 @retval EFI_UNSUPPORTED The driver specified by This is not currently
296 managing the controller specified by
297 ControllerHandle and ChildHandle.
298
299 @retval EFI_UNSUPPORTED The driver specified by This does not support
300 the language specified by Language.
301
302 **/
303 EFI_STATUS
304 EFIAPI
305 EhciComponentNameGetControllerName (
306 IN EFI_COMPONENT_NAME_PROTOCOL *This,
307 IN EFI_HANDLE ControllerHandle,
308 IN EFI_HANDLE ChildHandle OPTIONAL,
309 IN CHAR8 *Language,
310 OUT CHAR16 **ControllerName
311 )
312 {
313 EFI_STATUS Status;
314 USB2_HC_DEV *EhciDev;
315 EFI_USB2_HC_PROTOCOL *Usb2Hc;
316
317 //
318 // This is a device driver, so ChildHandle must be NULL.
319 //
320 if (ChildHandle != NULL) {
321 return EFI_UNSUPPORTED;
322 }
323 //
324 // Make sure this driver is currently managing ControllerHandle
325 //
326 Status = EfiTestManagedDevice (
327 ControllerHandle,
328 gEhciDriverBinding.DriverBindingHandle,
329 &gEfiPciIoProtocolGuid
330 );
331 if (EFI_ERROR (Status)) {
332 return Status;
333 }
334 //
335 // Get the device context
336 //
337 Status = gBS->OpenProtocol (
338 ControllerHandle,
339 &gEfiUsb2HcProtocolGuid,
340 (VOID **) &Usb2Hc,
341 gEhciDriverBinding.DriverBindingHandle,
342 ControllerHandle,
343 EFI_OPEN_PROTOCOL_GET_PROTOCOL
344 );
345 if (EFI_ERROR (Status)) {
346 return Status;
347 }
348
349 EhciDev = EHC_FROM_THIS (Usb2Hc);
350
351 return LookupUnicodeString2 (
352 Language,
353 This->SupportedLanguages,
354 EhciDev->ControllerNameTable,
355 ControllerName,
356 (BOOLEAN)(This == &gEhciComponentName)
357 );
358
359 }