3 Copyright (c) 2006 - 2007, Intel Corporation
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
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.
26 // EFI Component Name Functions
29 Retrieves a Unicode string that is the user readable name of the driver.
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.
38 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
39 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
59 @retval EFI_INVALID_PARAMETER Language is NULL.
61 @retval EFI_INVALID_PARAMETER DriverName is NULL.
63 @retval EFI_UNSUPPORTED The driver specified by This does not support
64 the language specified by Language.
69 EhciComponentNameGetDriverName (
70 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
72 OUT CHAR16
**DriverName
77 Retrieves a Unicode string that is the user readable name of the controller
78 that is being managed by a driver.
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.
89 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
90 EFI_COMPONENT_NAME_PROTOCOL instance.
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
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
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.
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
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
127 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
129 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
132 @retval EFI_INVALID_PARAMETER Language is NULL.
134 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
136 @retval EFI_UNSUPPORTED The driver specified by This is not currently
137 managing the controller specified by
138 ControllerHandle and ChildHandle.
140 @retval EFI_UNSUPPORTED The driver specified by This does not support
141 the language specified by Language.
146 EhciComponentNameGetControllerName (
147 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
148 IN EFI_HANDLE ControllerHandle
,
149 IN EFI_HANDLE ChildHandle OPTIONAL
,
151 OUT CHAR16
**ControllerName
156 // EFI Component Name Protocol
158 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName
= {
159 EhciComponentNameGetDriverName
,
160 EhciComponentNameGetControllerName
,
165 // EFI Component Name 2 Protocol
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
,
174 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEhciDriverNameTable
[] = {
175 { "eng;en", L
"Usb Ehci Driver" },
180 Retrieves a Unicode string that is the user readable name of the driver.
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.
189 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
190 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
210 @retval EFI_INVALID_PARAMETER Language is NULL.
212 @retval EFI_INVALID_PARAMETER DriverName is NULL.
214 @retval EFI_UNSUPPORTED The driver specified by This does not support
215 the language specified by Language.
220 EhciComponentNameGetDriverName (
221 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
223 OUT CHAR16
**DriverName
226 return LookupUnicodeString2 (
228 This
->SupportedLanguages
,
229 mEhciDriverNameTable
,
231 (BOOLEAN
)(This
== &gEhciComponentName
)
236 Retrieves a Unicode string that is the user readable name of the controller
237 that is being managed by a driver.
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.
248 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
249 EFI_COMPONENT_NAME_PROTOCOL instance.
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
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
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.
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
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
286 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
288 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
291 @retval EFI_INVALID_PARAMETER Language is NULL.
293 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
295 @retval EFI_UNSUPPORTED The driver specified by This is not currently
296 managing the controller specified by
297 ControllerHandle and ChildHandle.
299 @retval EFI_UNSUPPORTED The driver specified by This does not support
300 the language specified by Language.
305 EhciComponentNameGetControllerName (
306 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
307 IN EFI_HANDLE ControllerHandle
,
308 IN EFI_HANDLE ChildHandle OPTIONAL
,
310 OUT CHAR16
**ControllerName
314 USB2_HC_DEV
*EhciDev
;
315 EFI_USB2_HC_PROTOCOL
*Usb2Hc
;
318 // This is a device driver, so ChildHandle must be NULL.
320 if (ChildHandle
!= NULL
) {
321 return EFI_UNSUPPORTED
;
324 // Make sure this driver is currently managing ControllerHandle
326 Status
= EfiTestManagedDevice (
328 gEhciDriverBinding
.DriverBindingHandle
,
329 &gEfiPciIoProtocolGuid
331 if (EFI_ERROR (Status
)) {
335 // Get the device context
337 Status
= gBS
->OpenProtocol (
339 &gEfiUsb2HcProtocolGuid
,
341 gEhciDriverBinding
.DriverBindingHandle
,
343 EFI_OPEN_PROTOCOL_GET_PROTOCOL
345 if (EFI_ERROR (Status
)) {
349 EhciDev
= EHC_FROM_THIS (Usb2Hc
);
351 return LookupUnicodeString2 (
353 This
->SupportedLanguages
,
354 EhciDev
->ControllerNameTable
,
356 (BOOLEAN
)(This
== &gEhciComponentName
)