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