2 UEFI Component Name(2) protocol implementation for EHCI driver.
4 Copyright (c) 2006 - 2007, Intel Corporation
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
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.
20 // EFI Component Name Functions
23 Retrieves a Unicode string that is the user readable name of the driver.
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.
32 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
33 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
53 @retval EFI_INVALID_PARAMETER Language is NULL.
55 @retval EFI_INVALID_PARAMETER DriverName is NULL.
57 @retval EFI_UNSUPPORTED The driver specified by This does not support
58 the language specified by Language.
63 EhciComponentNameGetDriverName (
64 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
66 OUT CHAR16
**DriverName
71 Retrieves a Unicode string that is the user readable name of the controller
72 that is being managed by a driver.
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.
83 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
84 EFI_COMPONENT_NAME_PROTOCOL instance.
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
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
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.
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
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
121 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
123 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
126 @retval EFI_INVALID_PARAMETER Language is NULL.
128 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
130 @retval EFI_UNSUPPORTED The driver specified by This is not currently
131 managing the controller specified by
132 ControllerHandle and ChildHandle.
134 @retval EFI_UNSUPPORTED The driver specified by This does not support
135 the language specified by Language.
140 EhciComponentNameGetControllerName (
141 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
142 IN EFI_HANDLE ControllerHandle
,
143 IN EFI_HANDLE ChildHandle OPTIONAL
,
145 OUT CHAR16
**ControllerName
150 // EFI Component Name Protocol
152 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName
= {
153 EhciComponentNameGetDriverName
,
154 EhciComponentNameGetControllerName
,
159 // EFI Component Name 2 Protocol
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
,
168 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEhciDriverNameTable
[] = {
169 { "eng;en", L
"Usb Ehci Driver" },
174 Retrieves a Unicode string that is the user readable name of the driver.
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.
183 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
184 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
204 @retval EFI_INVALID_PARAMETER Language is NULL.
206 @retval EFI_INVALID_PARAMETER DriverName is NULL.
208 @retval EFI_UNSUPPORTED The driver specified by This does not support
209 the language specified by Language.
214 EhciComponentNameGetDriverName (
215 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
217 OUT CHAR16
**DriverName
220 return LookupUnicodeString2 (
222 This
->SupportedLanguages
,
223 mEhciDriverNameTable
,
225 (BOOLEAN
)(This
== &gEhciComponentName
)
230 Retrieves a Unicode string that is the user readable name of the controller
231 that is being managed by a driver.
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.
242 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
243 EFI_COMPONENT_NAME_PROTOCOL instance.
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
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
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.
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
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
280 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
282 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
285 @retval EFI_INVALID_PARAMETER Language is NULL.
287 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
289 @retval EFI_UNSUPPORTED The driver specified by This is not currently
290 managing the controller specified by
291 ControllerHandle and ChildHandle.
293 @retval EFI_UNSUPPORTED The driver specified by This does not support
294 the language specified by Language.
299 EhciComponentNameGetControllerName (
300 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
301 IN EFI_HANDLE ControllerHandle
,
302 IN EFI_HANDLE ChildHandle OPTIONAL
,
304 OUT CHAR16
**ControllerName
308 USB2_HC_DEV
*EhciDev
;
309 EFI_USB2_HC_PROTOCOL
*Usb2Hc
;
312 // This is a device driver, so ChildHandle must be NULL.
314 if (ChildHandle
!= NULL
) {
315 return EFI_UNSUPPORTED
;
318 // Make sure this driver is currently managing ControllerHandle
320 Status
= EfiTestManagedDevice (
322 gEhciDriverBinding
.DriverBindingHandle
,
323 &gEfiPciIoProtocolGuid
325 if (EFI_ERROR (Status
)) {
329 // Get the device context
331 Status
= gBS
->OpenProtocol (
333 &gEfiUsb2HcProtocolGuid
,
335 gEhciDriverBinding
.DriverBindingHandle
,
337 EFI_OPEN_PROTOCOL_GET_PROTOCOL
339 if (EFI_ERROR (Status
)) {
343 EhciDev
= EHC_FROM_THIS (Usb2Hc
);
345 return LookupUnicodeString2 (
347 This
->SupportedLanguages
,
348 EhciDev
->ControllerNameTable
,
350 (BOOLEAN
)(This
== &gEhciComponentName
)