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