]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/EhciDxe/ComponentName.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / ComponentName.c
CommitLineData
913cb9dc 1/** @file\r
78c2ffb5 2 UEFI Component Name(2) protocol implementation for EHCI driver.\r
913cb9dc 3\r
d1102dba
LG
4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
5\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
913cb9dc 7\r
913cb9dc 8**/\r
9\r
10#include "Ehci.h"\r
11\r
f527bce3 12\r
913cb9dc 13//\r
14// EFI Component Name Protocol\r
15//\r
1307dcd7 16GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName = {\r
913cb9dc 17 EhciComponentNameGetDriverName,\r
18 EhciComponentNameGetControllerName,\r
19 "eng"\r
1307dcd7 20};\r
f527bce3 21\r
22//\r
23// EFI Component Name 2 Protocol\r
24//\r
1307dcd7 25GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2 = {\r
f527bce3 26 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EhciComponentNameGetDriverName,\r
27 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EhciComponentNameGetControllerName,\r
28 "en"\r
1307dcd7 29};\r
f527bce3 30\r
913cb9dc 31\r
d1aeb0bd 32GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEhciDriverNameTable[] = {\r
f527bce3 33 { "eng;en", L"Usb Ehci Driver" },\r
913cb9dc 34 { NULL , NULL }\r
35};\r
36\r
aa79b0b3 37\r
f527bce3 38/**\r
39 Retrieves a Unicode string that is the user readable name of the driver.\r
40\r
41 This function retrieves the user readable name of a driver in the form of a\r
42 Unicode string. If the driver specified by This has a user readable name in\r
43 the language specified by Language, then a pointer to the driver name is\r
44 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
45 by This does not support the language specified by Language,\r
46 then EFI_UNSUPPORTED is returned.\r
47\r
48 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
49 EFI_COMPONENT_NAME_PROTOCOL instance.\r
50\r
51 @param Language[in] A pointer to a Null-terminated ASCII string\r
52 array indicating the language. This is the\r
53 language of the driver name that the caller is\r
54 requesting, and it must match one of the\r
55 languages specified in SupportedLanguages. The\r
56 number of languages supported by a driver is up\r
57 to the driver writer. Language is specified\r
0254efc0 58 in RFC 4646 or ISO 639-2 language code format.\r
f527bce3 59\r
60 @param DriverName[out] A pointer to the Unicode string to return.\r
61 This Unicode string is the name of the\r
62 driver specified by This in the language\r
63 specified by Language.\r
64\r
65 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
66 This and the language specified by Language was\r
67 returned in DriverName.\r
68\r
69 @retval EFI_INVALID_PARAMETER Language is NULL.\r
70\r
71 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
72\r
73 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
74 the language specified by Language.\r
75\r
76**/\r
913cb9dc 77EFI_STATUS\r
78EFIAPI\r
79EhciComponentNameGetDriverName (\r
f527bce3 80 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
81 IN CHAR8 *Language,\r
82 OUT CHAR16 **DriverName\r
913cb9dc 83 )\r
913cb9dc 84{\r
f527bce3 85 return LookupUnicodeString2 (\r
86 Language,\r
87 This->SupportedLanguages,\r
88 mEhciDriverNameTable,\r
89 DriverName,\r
90 (BOOLEAN)(This == &gEhciComponentName)\r
91 );\r
913cb9dc 92}\r
93\r
f527bce3 94/**\r
95 Retrieves a Unicode string that is the user readable name of the controller\r
96 that is being managed by a driver.\r
97\r
98 This function retrieves the user readable name of the controller specified by\r
99 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
100 driver specified by This has a user readable name in the language specified by\r
101 Language, then a pointer to the controller name is returned in ControllerName,\r
102 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
103 managing the controller specified by ControllerHandle and ChildHandle,\r
104 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
105 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
106\r
107 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
108 EFI_COMPONENT_NAME_PROTOCOL instance.\r
109\r
110 @param ControllerHandle[in] The handle of a controller that the driver\r
111 specified by This is managing. This handle\r
112 specifies the controller whose name is to be\r
113 returned.\r
114\r
115 @param ChildHandle[in] The handle of the child controller to retrieve\r
116 the name of. This is an optional parameter that\r
117 may be NULL. It will be NULL for device\r
118 drivers. It will also be NULL for a bus drivers\r
119 that wish to retrieve the name of the bus\r
120 controller. It will not be NULL for a bus\r
121 driver that wishes to retrieve the name of a\r
122 child controller.\r
123\r
124 @param Language[in] A pointer to a Null-terminated ASCII string\r
125 array indicating the language. This is the\r
126 language of the driver name that the caller is\r
127 requesting, and it must match one of the\r
128 languages specified in SupportedLanguages. The\r
129 number of languages supported by a driver is up\r
130 to the driver writer. Language is specified in\r
0254efc0 131 RFC 4646 or ISO 639-2 language code format.\r
f527bce3 132\r
133 @param ControllerName[out] A pointer to the Unicode string to return.\r
134 This Unicode string is the name of the\r
135 controller specified by ControllerHandle and\r
136 ChildHandle in the language specified by\r
137 Language from the point of view of the driver\r
138 specified by This.\r
139\r
140 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
141 the language specified by Language for the\r
142 driver specified by This was returned in\r
143 DriverName.\r
144\r
284ee2e8 145 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
f527bce3 146\r
147 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
148 EFI_HANDLE.\r
149\r
150 @retval EFI_INVALID_PARAMETER Language is NULL.\r
151\r
152 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
153\r
154 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
155 managing the controller specified by\r
156 ControllerHandle and ChildHandle.\r
157\r
158 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
159 the language specified by Language.\r
160\r
161**/\r
913cb9dc 162EFI_STATUS\r
163EFIAPI\r
164EhciComponentNameGetControllerName (\r
f527bce3 165 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
166 IN EFI_HANDLE ControllerHandle,\r
167 IN EFI_HANDLE ChildHandle OPTIONAL,\r
168 IN CHAR8 *Language,\r
169 OUT CHAR16 **ControllerName\r
913cb9dc 170 )\r
913cb9dc 171{\r
172 EFI_STATUS Status;\r
173 USB2_HC_DEV *EhciDev;\r
174 EFI_USB2_HC_PROTOCOL *Usb2Hc;\r
175\r
176 //\r
177 // This is a device driver, so ChildHandle must be NULL.\r
178 //\r
179 if (ChildHandle != NULL) {\r
180 return EFI_UNSUPPORTED;\r
181 }\r
182 //\r
183 // Make sure this driver is currently managing ControllerHandle\r
184 //\r
185 Status = EfiTestManagedDevice (\r
186 ControllerHandle,\r
187 gEhciDriverBinding.DriverBindingHandle,\r
188 &gEfiPciIoProtocolGuid\r
189 );\r
190 if (EFI_ERROR (Status)) {\r
191 return Status;\r
192 }\r
193 //\r
194 // Get the device context\r
195 //\r
196 Status = gBS->OpenProtocol (\r
197 ControllerHandle,\r
198 &gEfiUsb2HcProtocolGuid,\r
199 (VOID **) &Usb2Hc,\r
200 gEhciDriverBinding.DriverBindingHandle,\r
201 ControllerHandle,\r
202 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
203 );\r
204 if (EFI_ERROR (Status)) {\r
205 return Status;\r
206 }\r
207\r
208 EhciDev = EHC_FROM_THIS (Usb2Hc);\r
209\r
f527bce3 210 return LookupUnicodeString2 (\r
211 Language,\r
212 This->SupportedLanguages,\r
213 EhciDev->ControllerNameTable,\r
214 ControllerName,\r
215 (BOOLEAN)(This == &gEhciComponentName)\r
216 );\r
913cb9dc 217\r
218}\r