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