2 UEFI Component Name(2) protocol implementation for XHCI driver.
4 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
6 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 Protocol
22 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gXhciComponentName
= {
23 XhciComponentNameGetDriverName
,
24 XhciComponentNameGetControllerName
,
29 // EFI Component Name 2 Protocol
31 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gXhciComponentName2
= {
32 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) XhciComponentNameGetDriverName
,
33 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) XhciComponentNameGetControllerName
,
37 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mXhciDriverNameTable
[] = {
38 { "eng;en", L
"Usb Xhci Driver" },
43 Retrieves a Unicode string that is the user readable name of the driver.
45 This function retrieves the user readable name of a driver in the form of a
46 Unicode string. If the driver specified by This has a user readable name in
47 the language specified by Language, then a pointer to the driver name is
48 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
49 by This does not support the language specified by Language,
50 then EFI_UNSUPPORTED is returned.
52 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
53 EFI_COMPONENT_NAME_PROTOCOL instance.
55 @param Language[in] A pointer to a Null-terminated ASCII string
56 array indicating the language. This is the
57 language of the driver name that the caller is
58 requesting, and it must match one of the
59 languages specified in SupportedLanguages. The
60 number of languages supported by a driver is up
61 to the driver writer. Language is specified
62 in RFC 4646 or ISO 639-2 language code format.
64 @param DriverName[out] A pointer to the Unicode string to return.
65 This Unicode string is the name of the
66 driver specified by This in the language
67 specified by Language.
69 @retval EFI_SUCCESS The Unicode string for the Driver specified by
70 This and the language specified by Language was
71 returned in DriverName.
73 @retval EFI_INVALID_PARAMETER Language is NULL.
75 @retval EFI_INVALID_PARAMETER DriverName is NULL.
77 @retval EFI_UNSUPPORTED The driver specified by This does not support
78 the language specified by Language.
83 XhciComponentNameGetDriverName (
84 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
86 OUT CHAR16
**DriverName
89 return LookupUnicodeString2 (
91 This
->SupportedLanguages
,
94 (BOOLEAN
)(This
== &gXhciComponentName
)
99 Retrieves a Unicode string that is the user readable name of the controller
100 that is being managed by a driver.
102 This function retrieves the user readable name of the controller specified by
103 ControllerHandle and ChildHandle in the form of a Unicode string. If the
104 driver specified by This has a user readable name in the language specified by
105 Language, then a pointer to the controller name is returned in ControllerName,
106 and EFI_SUCCESS is returned. If the driver specified by This is not currently
107 managing the controller specified by ControllerHandle and ChildHandle,
108 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
109 support the language specified by Language, then EFI_UNSUPPORTED is returned.
111 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
112 EFI_COMPONENT_NAME_PROTOCOL instance.
114 @param ControllerHandle[in] The handle of a controller that the driver
115 specified by This is managing. This handle
116 specifies the controller whose name is to be
119 @param ChildHandle[in] The handle of the child controller to retrieve
120 the name of. This is an optional parameter that
121 may be NULL. It will be NULL for device
122 drivers. It will also be NULL for a bus drivers
123 that wish to retrieve the name of the bus
124 controller. It will not be NULL for a bus
125 driver that wishes to retrieve the name of a
128 @param Language[in] A pointer to a Null-terminated ASCII string
129 array indicating the language. This is the
130 language of the driver name that the caller is
131 requesting, and it must match one of the
132 languages specified in SupportedLanguages. The
133 number of languages supported by a driver is up
134 to the driver writer. Language is specified in
135 RFC 4646 or ISO 639-2 language code format.
137 @param ControllerName[out] A pointer to the Unicode string to return.
138 This Unicode string is the name of the
139 controller specified by ControllerHandle and
140 ChildHandle in the language specified by
141 Language from the point of view of the driver
144 @retval EFI_SUCCESS The Unicode string for the user readable name in
145 the language specified by Language for the
146 driver specified by This was returned in
149 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
151 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
154 @retval EFI_INVALID_PARAMETER Language is NULL.
156 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
158 @retval EFI_UNSUPPORTED The driver specified by This is not currently
159 managing the controller specified by
160 ControllerHandle and ChildHandle.
162 @retval EFI_UNSUPPORTED The driver specified by This does not support
163 the language specified by Language.
168 XhciComponentNameGetControllerName (
169 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
170 IN EFI_HANDLE ControllerHandle
,
171 IN EFI_HANDLE ChildHandle OPTIONAL
,
173 OUT CHAR16
**ControllerName
177 EFI_USB2_HC_PROTOCOL
*Usb2Hc
;
178 USB_XHCI_INSTANCE
*XhciDev
;
181 // This is a device driver, so ChildHandle must be NULL.
183 if (ChildHandle
!= NULL
) {
184 return EFI_UNSUPPORTED
;
188 // Make sure this driver is currently managing ControllerHandle
190 Status
= EfiTestManagedDevice (
192 gXhciDriverBinding
.DriverBindingHandle
,
193 &gEfiPciIoProtocolGuid
195 if (EFI_ERROR (Status
)) {
200 // Get the device context
202 Status
= gBS
->OpenProtocol (
204 &gEfiUsb2HcProtocolGuid
,
206 gXhciDriverBinding
.DriverBindingHandle
,
208 EFI_OPEN_PROTOCOL_GET_PROTOCOL
210 if (EFI_ERROR (Status
)) {
214 XhciDev
= XHC_FROM_THIS (Usb2Hc
);
216 return LookupUnicodeString2 (
218 This
->SupportedLanguages
,
219 XhciDev
->ControllerNameTable
,
221 (BOOLEAN
)(This
== &gXhciComponentName
)