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