2 Implementation of EFI_COMPONENT_NAME_PROTOCOL and
3 EFI_COMPONENT_NAME2_PROTOCOL protocol.
5 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
14 // EFI Component Name Functions
18 Retrieves a Unicode string that is the user-readable name of the driver.
20 This function retrieves the user-readable name of a driver in the form of a
21 Unicode string. If the driver specified by This has a user-readable name in
22 the language specified by Language, then a pointer to the driver name is
23 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
24 by This does not support the language specified by Language,
25 then EFI_UNSUPPORTED is returned.
27 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
28 EFI_COMPONENT_NAME_PROTOCOL instance.
30 @param[in] Language A pointer to a Null-terminated ASCII string
31 array indicating the language. This is the
32 language of the driver name that the caller is
33 requesting, and it must match one of the
34 languages specified in SupportedLanguages. The
35 number of languages supported by a driver is up
36 to the driver writer. Language is specified
37 in RFC 4646 or ISO 639-2 language code format.
39 @param[out] DriverName A pointer to the Unicode string to return.
40 This Unicode string is the name of the
41 driver specified by This in the language
42 specified by Language.
44 @retval EFI_SUCCESS The Unicode string for the Driver specified by
45 This and the language specified by Language was
46 returned in DriverName.
48 @retval EFI_INVALID_PARAMETER Language is NULL.
50 @retval EFI_INVALID_PARAMETER DriverName is NULL.
52 @retval EFI_UNSUPPORTED The driver specified by This does not support
53 the language specified by Language.
58 Ip6ComponentNameGetDriverName (
59 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
61 OUT CHAR16
**DriverName
65 Retrieves a Unicode string that is the user-readable name of the controller
66 that is managed by a driver.
68 This function retrieves the user-readable name of the controller specified by
69 ControllerHandle and ChildHandle in the form of a Unicode string. If the
70 driver specified by This has a user-readable name in the language specified by
71 Language, then a pointer to the controller name is returned in ControllerName,
72 and EFI_SUCCESS is returned. If the driver specified by This is not currently
73 managing the controller specified by ControllerHandle and ChildHandle,
74 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
75 support the language specified by Language, then EFI_UNSUPPORTED is returned.
77 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
78 EFI_COMPONENT_NAME_PROTOCOL instance.
80 @param[in] ControllerHandle The handle of a controller that the driver
81 specified by This is managing. This handle
82 specifies the controller whose name is to be
85 @param[in] ChildHandle The handle of the child controller to retrieve
86 the name of. This is an optional parameter that
87 may be NULL. It will be NULL for device
88 drivers. It will also be NULL for a bus drivers
89 that wish to retrieve the name of the bus
90 controller. It will not be NULL for a bus
91 driver that wishes to retrieve the name of a
94 @param[in] Language A pointer to a Null-terminated ASCII string
95 array indicating the language. This is the
96 language of the driver name that the caller is
97 requesting, and it must match one of the
98 languages specified in SupportedLanguages. The
99 number of languages supported by a driver is up
100 to the driver writer. Language is specified in
101 RFC 4646 or ISO 639-2 language code format.
103 @param[out] ControllerName A pointer to the Unicode string to return.
104 This Unicode string is the name of the
105 controller specified by ControllerHandle and
106 ChildHandle in the language specified by
107 Language from the point of view of the driver
110 @retval EFI_SUCCESS The Unicode string for the user-readable name in
111 the language specified by Language for the
112 driver specified by This was returned in
115 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
117 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
120 @retval EFI_INVALID_PARAMETER Language is NULL.
122 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
124 @retval EFI_UNSUPPORTED The driver specified by This is not currently
125 managing the controller specified by
126 ControllerHandle and ChildHandle.
128 @retval EFI_UNSUPPORTED The driver specified by This does not support
129 the language specified by Language.
134 Ip6ComponentNameGetControllerName (
135 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
136 IN EFI_HANDLE ControllerHandle
,
137 IN EFI_HANDLE ChildHandle OPTIONAL
,
139 OUT CHAR16
**ControllerName
143 // EFI Component Name Protocol.
145 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp6ComponentName
= {
146 Ip6ComponentNameGetDriverName
,
147 Ip6ComponentNameGetControllerName
,
152 // EFI Component Name 2 Protocol.
154 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp6ComponentName2
= {
155 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Ip6ComponentNameGetDriverName
,
156 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Ip6ComponentNameGetControllerName
,
160 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp6DriverNameTable
[] = {
163 L
"IP6 Network Service Driver"
171 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gIp6ControllerNameTable
= NULL
;
174 Retrieves a Unicode string that is the user-readable name of the driver.
176 This function retrieves the user-readable name of a driver in the form of a
177 Unicode string. If the driver specified by This has a user-readable name in
178 the language specified by Language, then a pointer to the driver name is
179 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
180 by This does not support the language specified by Language,
181 then EFI_UNSUPPORTED is returned.
183 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
184 EFI_COMPONENT_NAME_PROTOCOL instance.
186 @param[in] Language A pointer to a Null-terminated ASCII string
187 array indicating the language. This is the
188 language of the driver name that the caller is
189 requesting, and it must match one of the
190 languages specified in SupportedLanguages. The
191 number of languages supported by a driver is up
192 to the driver writer. Language is specified
193 in RFC 4646 or ISO 639-2 language code format.
195 @param[out] DriverName A pointer to the Unicode string to return.
196 This Unicode string is the name of the
197 driver specified by This in the language
198 specified by Language.
200 @retval EFI_SUCCESS The Unicode string for the Driver specified by
201 This and the language specified by Language was
202 returned in DriverName.
204 @retval EFI_INVALID_PARAMETER Language is NULL.
206 @retval EFI_INVALID_PARAMETER DriverName is NULL.
208 @retval EFI_UNSUPPORTED The driver specified by This does not support
209 the language specified by Language.
214 Ip6ComponentNameGetDriverName (
215 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
217 OUT CHAR16
**DriverName
220 return LookupUnicodeString2 (
222 This
->SupportedLanguages
,
225 (BOOLEAN
) (This
== &gIp6ComponentName
)
231 Update the component name for the IP6 child handle.
233 @param Ip6[in] A pointer to the EFI_IP6_PROTOCOL.
236 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
237 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
242 IN EFI_IP6_PROTOCOL
*Ip6
246 CHAR16 HandleName
[128];
247 EFI_IP6_MODE_DATA Ip6ModeData
;
249 CHAR16 Address
[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
252 return EFI_INVALID_PARAMETER
;
256 // Format the child name into the string buffer.
259 Status
= Ip6
->GetModeData (Ip6
, &Ip6ModeData
, NULL
, NULL
);
260 if (!EFI_ERROR (Status
)) {
261 if (Ip6ModeData
.AddressList
!= NULL
) {
262 FreePool (Ip6ModeData
.AddressList
);
265 if (Ip6ModeData
.GroupTable
!= NULL
) {
266 FreePool (Ip6ModeData
.GroupTable
);
269 if (Ip6ModeData
.RouteTable
!= NULL
) {
270 FreePool (Ip6ModeData
.RouteTable
);
273 if (Ip6ModeData
.NeighborCache
!= NULL
) {
274 FreePool (Ip6ModeData
.NeighborCache
);
277 if (Ip6ModeData
.PrefixTable
!= NULL
) {
278 FreePool (Ip6ModeData
.PrefixTable
);
281 if (Ip6ModeData
.IcmpTypeList
!= NULL
) {
282 FreePool (Ip6ModeData
.IcmpTypeList
);
286 if (!EFI_ERROR (Status
) && Ip6ModeData
.IsStarted
) {
287 Status
= NetLibIp6ToStr (&Ip6ModeData
.ConfigData
.StationAddress
, Address
, sizeof(Address
));
288 if (EFI_ERROR (Status
)) {
291 Offset
+= UnicodeSPrint (
294 L
"IPv6(StationAddress=%s, ",
297 Status
= NetLibIp6ToStr (&Ip6ModeData
.ConfigData
.DestinationAddress
, Address
, sizeof(Address
));
298 if (EFI_ERROR (Status
)) {
303 sizeof(HandleName
) - Offset
* sizeof (CHAR16
),
304 L
"DestinationAddress=%s)",
307 } else if (!Ip6ModeData
.IsStarted
) {
308 UnicodeSPrint (HandleName
, sizeof(HandleName
), L
"IPv6(Not started)");
310 UnicodeSPrint (HandleName
, sizeof(HandleName
), L
"IPv6(%r)", Status
);
313 if (gIp6ControllerNameTable
!= NULL
) {
314 FreeUnicodeStringTable (gIp6ControllerNameTable
);
315 gIp6ControllerNameTable
= NULL
;
318 Status
= AddUnicodeString2 (
320 gIp6ComponentName
.SupportedLanguages
,
321 &gIp6ControllerNameTable
,
325 if (EFI_ERROR (Status
)) {
329 return AddUnicodeString2 (
331 gIp6ComponentName2
.SupportedLanguages
,
332 &gIp6ControllerNameTable
,
339 Retrieves a Unicode string that is the user-readable name of the controller
340 that is being managed by a driver.
342 This function retrieves the user-readable name of the controller specified by
343 ControllerHandle and ChildHandle in the form of a Unicode string. If the
344 driver specified by This has a user-readable name in the language specified by
345 Language, then a pointer to the controller name is returned in ControllerName,
346 and EFI_SUCCESS is returned. If the driver specified by This is not currently
347 managing the controller specified by ControllerHandle and ChildHandle,
348 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
349 support the language specified by Language, then EFI_UNSUPPORTED is returned.
351 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
352 EFI_COMPONENT_NAME_PROTOCOL instance.
354 @param[in] ControllerHandle The handle of a controller that the driver
355 specified by This is managing. This handle
356 specifies the controller whose name is to be
359 @param[in] ChildHandle The handle of the child controller to retrieve
360 the name of. This is an optional parameter that
361 may be NULL. It will be NULL for device
362 drivers. It will also be NULL for a bus drivers
363 that wish to retrieve the name of the bus
364 controller. It will not be NULL for a bus
365 driver that wishes to retrieve the name of a
368 @param[in] Language A pointer to a Null-terminated ASCII string
369 array indicating the language. This is the
370 language of the driver name that the caller is
371 requesting, and it must match one of the
372 languages specified in SupportedLanguages. The
373 number of languages supported by a driver is up
374 to the driver writer. Language is specified in
375 RFC 4646 or ISO 639-2 language code format.
377 @param[out] ControllerName A pointer to the Unicode string to return.
378 This Unicode string is the name of the
379 controller specified by ControllerHandle and
380 ChildHandle in the language specified by
381 Language from the point of view of the driver
384 @retval EFI_SUCCESS The Unicode string for the user-readable name in
385 the language specified by Language for the
386 driver specified by This was returned in
389 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
391 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
394 @retval EFI_INVALID_PARAMETER Language is NULL.
396 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
398 @retval EFI_UNSUPPORTED The driver specified by This is not currently
399 managing the controller specified by
400 ControllerHandle and ChildHandle.
402 @retval EFI_UNSUPPORTED The driver specified by This does not support
403 the language specified by Language.
408 Ip6ComponentNameGetControllerName (
409 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
410 IN EFI_HANDLE ControllerHandle
,
411 IN EFI_HANDLE ChildHandle OPTIONAL
,
413 OUT CHAR16
**ControllerName
417 EFI_IP6_PROTOCOL
*Ip6
;
420 // Only provide names for child handles.
422 if (ChildHandle
== NULL
) {
423 return EFI_UNSUPPORTED
;
427 // Make sure this driver produced ChildHandle
429 Status
= EfiTestChildHandle (
432 &gEfiManagedNetworkProtocolGuid
434 if (EFI_ERROR (Status
)) {
439 // Retrieve an instance of a produced protocol from ChildHandle
441 Status
= gBS
->OpenProtocol (
443 &gEfiIp6ProtocolGuid
,
447 EFI_OPEN_PROTOCOL_GET_PROTOCOL
449 if (EFI_ERROR (Status
)) {
454 // Update the component name for this child handle.
456 Status
= UpdateName (Ip6
);
457 if (EFI_ERROR (Status
)) {
461 return LookupUnicodeString2 (
463 This
->SupportedLanguages
,
464 gIp6ControllerNameTable
,
466 (BOOLEAN
)(This
== &gIp6ComponentName
)