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