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
)
230 Update the component name for the IP6 child handle.
232 @param Ip6[in] A pointer to the EFI_IP6_PROTOCOL.
235 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
236 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
241 IN EFI_IP6_PROTOCOL
*Ip6
245 CHAR16 HandleName
[128];
246 EFI_IP6_MODE_DATA Ip6ModeData
;
248 CHAR16 Address
[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
251 return EFI_INVALID_PARAMETER
;
255 // Format the child name into the string buffer.
258 Status
= Ip6
->GetModeData (Ip6
, &Ip6ModeData
, NULL
, NULL
);
259 if (!EFI_ERROR (Status
)) {
260 if (Ip6ModeData
.AddressList
!= NULL
) {
261 FreePool (Ip6ModeData
.AddressList
);
264 if (Ip6ModeData
.GroupTable
!= NULL
) {
265 FreePool (Ip6ModeData
.GroupTable
);
268 if (Ip6ModeData
.RouteTable
!= NULL
) {
269 FreePool (Ip6ModeData
.RouteTable
);
272 if (Ip6ModeData
.NeighborCache
!= NULL
) {
273 FreePool (Ip6ModeData
.NeighborCache
);
276 if (Ip6ModeData
.PrefixTable
!= NULL
) {
277 FreePool (Ip6ModeData
.PrefixTable
);
280 if (Ip6ModeData
.IcmpTypeList
!= NULL
) {
281 FreePool (Ip6ModeData
.IcmpTypeList
);
285 if (!EFI_ERROR (Status
) && Ip6ModeData
.IsStarted
) {
286 Status
= NetLibIp6ToStr (&Ip6ModeData
.ConfigData
.StationAddress
, Address
, sizeof (Address
));
287 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
)) {
304 sizeof (HandleName
) - Offset
* sizeof (CHAR16
),
305 L
"DestinationAddress=%s)",
308 } else if (!Ip6ModeData
.IsStarted
) {
309 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"IPv6(Not started)");
311 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"IPv6(%r)", Status
);
314 if (gIp6ControllerNameTable
!= NULL
) {
315 FreeUnicodeStringTable (gIp6ControllerNameTable
);
316 gIp6ControllerNameTable
= NULL
;
319 Status
= AddUnicodeString2 (
321 gIp6ComponentName
.SupportedLanguages
,
322 &gIp6ControllerNameTable
,
326 if (EFI_ERROR (Status
)) {
330 return AddUnicodeString2 (
332 gIp6ComponentName2
.SupportedLanguages
,
333 &gIp6ControllerNameTable
,
340 Retrieves a Unicode string that is the user-readable name of the controller
341 that is being managed by a driver.
343 This function retrieves the user-readable name of the controller specified by
344 ControllerHandle and ChildHandle in the form of a Unicode string. If the
345 driver specified by This has a user-readable name in the language specified by
346 Language, then a pointer to the controller name is returned in ControllerName,
347 and EFI_SUCCESS is returned. If the driver specified by This is not currently
348 managing the controller specified by ControllerHandle and ChildHandle,
349 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
350 support the language specified by Language, then EFI_UNSUPPORTED is returned.
352 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
353 EFI_COMPONENT_NAME_PROTOCOL instance.
355 @param[in] ControllerHandle The handle of a controller that the driver
356 specified by This is managing. This handle
357 specifies the controller whose name is to be
360 @param[in] ChildHandle The handle of the child controller to retrieve
361 the name of. This is an optional parameter that
362 may be NULL. It will be NULL for device
363 drivers. It will also be NULL for a bus drivers
364 that wish to retrieve the name of the bus
365 controller. It will not be NULL for a bus
366 driver that wishes to retrieve the name of a
369 @param[in] Language A pointer to a Null-terminated ASCII string
370 array indicating the language. This is the
371 language of the driver name that the caller is
372 requesting, and it must match one of the
373 languages specified in SupportedLanguages. The
374 number of languages supported by a driver is up
375 to the driver writer. Language is specified in
376 RFC 4646 or ISO 639-2 language code format.
378 @param[out] ControllerName A pointer to the Unicode string to return.
379 This Unicode string is the name of the
380 controller specified by ControllerHandle and
381 ChildHandle in the language specified by
382 Language from the point of view of the driver
385 @retval EFI_SUCCESS The Unicode string for the user-readable name in
386 the language specified by Language for the
387 driver specified by This was returned in
390 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
392 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
395 @retval EFI_INVALID_PARAMETER Language is NULL.
397 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
399 @retval EFI_UNSUPPORTED The driver specified by This is not currently
400 managing the controller specified by
401 ControllerHandle and ChildHandle.
403 @retval EFI_UNSUPPORTED The driver specified by This does not support
404 the language specified by Language.
409 Ip6ComponentNameGetControllerName (
410 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
411 IN EFI_HANDLE ControllerHandle
,
412 IN EFI_HANDLE ChildHandle OPTIONAL
,
414 OUT CHAR16
**ControllerName
418 EFI_IP6_PROTOCOL
*Ip6
;
421 // Only provide names for child handles.
423 if (ChildHandle
== NULL
) {
424 return EFI_UNSUPPORTED
;
428 // Make sure this driver produced ChildHandle
430 Status
= EfiTestChildHandle (
433 &gEfiManagedNetworkProtocolGuid
435 if (EFI_ERROR (Status
)) {
440 // Retrieve an instance of a produced protocol from ChildHandle
442 Status
= gBS
->OpenProtocol (
444 &gEfiIp6ProtocolGuid
,
448 EFI_OPEN_PROTOCOL_GET_PROTOCOL
450 if (EFI_ERROR (Status
)) {
455 // Update the component name for this child handle.
457 Status
= UpdateName (Ip6
);
458 if (EFI_ERROR (Status
)) {
462 return LookupUnicodeString2 (
464 This
->SupportedLanguages
,
465 gIp6ControllerNameTable
,
467 (BOOLEAN
)(This
== &gIp6ComponentName
)