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