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