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