2 Implementation of EFI_COMPONENT_NAME_PROTOCOL and
3 EFI_COMPONENT_NAME2_PROTOCOL protocol.
5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 // EFI Component Name Functions
24 Retrieves a Unicode string that is the user-readable name of the driver.
26 This function retrieves the user-readable name of a driver in the form of a
27 Unicode string. If the driver specified by This has a user-readable name in
28 the language specified by Language, then a pointer to the driver name is
29 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
30 by This does not support the language specified by Language,
31 then EFI_UNSUPPORTED is returned.
33 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
34 EFI_COMPONENT_NAME_PROTOCOL instance.
36 @param[in] Language A pointer to a Null-terminated ASCII string
37 array indicating the language. This is the
38 language of the driver name that the caller is
39 requesting, and it must match one of the
40 languages specified in SupportedLanguages. The
41 number of languages supported by a driver is up
42 to the driver writer. Language is specified
43 in RFC 4646 or ISO 639-2 language code format.
45 @param[out] DriverName A pointer to the Unicode string to return.
46 This Unicode string is the name of the
47 driver specified by This in the language
48 specified by Language.
50 @retval EFI_SUCCESS The Unicode string for the Driver specified by
51 This and the language specified by Language was
52 returned in DriverName.
54 @retval EFI_INVALID_PARAMETER Language is NULL.
56 @retval EFI_INVALID_PARAMETER DriverName is NULL.
58 @retval EFI_UNSUPPORTED The driver specified by This does not support
59 the language specified by Language.
64 Ip6ComponentNameGetDriverName (
65 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
67 OUT CHAR16
**DriverName
71 Retrieves a Unicode string that is the user-readable name of the controller
72 that is managed by a driver.
74 This function retrieves the user-readable name of the controller specified by
75 ControllerHandle and ChildHandle in the form of a Unicode string. If the
76 driver specified by This has a user-readable name in the language specified by
77 Language, then a pointer to the controller name is returned in ControllerName,
78 and EFI_SUCCESS is returned. If the driver specified by This is not currently
79 managing the controller specified by ControllerHandle and ChildHandle,
80 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
81 support the language specified by Language, then EFI_UNSUPPORTED is returned.
83 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
84 EFI_COMPONENT_NAME_PROTOCOL instance.
86 @param[in] ControllerHandle The handle of a controller that the driver
87 specified by This is managing. This handle
88 specifies the controller whose name is to be
91 @param[in] ChildHandle The handle of the child controller to retrieve
92 the name of. This is an optional parameter that
93 may be NULL. It will be NULL for device
94 drivers. It will also be NULL for a bus drivers
95 that wish to retrieve the name of the bus
96 controller. It will not be NULL for a bus
97 driver that wishes to retrieve the name of a
100 @param[in] Language A pointer to a Null-terminated ASCII string
101 array indicating the language. This is the
102 language of the driver name that the caller is
103 requesting, and it must match one of the
104 languages specified in SupportedLanguages. The
105 number of languages supported by a driver is up
106 to the driver writer. Language is specified in
107 RFC 4646 or ISO 639-2 language code format.
109 @param[out] ControllerName A pointer to the Unicode string to return.
110 This Unicode string is the name of the
111 controller specified by ControllerHandle and
112 ChildHandle in the language specified by
113 Language from the point of view of the driver
116 @retval EFI_SUCCESS The Unicode string for the user-readable name in
117 the language specified by Language for the
118 driver specified by This was returned in
121 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
123 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
126 @retval EFI_INVALID_PARAMETER Language is NULL.
128 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
130 @retval EFI_UNSUPPORTED The driver specified by This is not currently
131 managing the controller specified by
132 ControllerHandle and ChildHandle.
134 @retval EFI_UNSUPPORTED The driver specified by This does not support
135 the language specified by Language.
140 Ip6ComponentNameGetControllerName (
141 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
142 IN EFI_HANDLE ControllerHandle
,
143 IN EFI_HANDLE ChildHandle OPTIONAL
,
145 OUT CHAR16
**ControllerName
149 // EFI Component Name Protocol.
151 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp6ComponentName
= {
152 Ip6ComponentNameGetDriverName
,
153 Ip6ComponentNameGetControllerName
,
158 // EFI Component Name 2 Protocol.
160 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp6ComponentName2
= {
161 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Ip6ComponentNameGetDriverName
,
162 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Ip6ComponentNameGetControllerName
,
166 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp6DriverNameTable
[] = {
169 L
"IP6 Network Service Driver"
177 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gIp6ControllerNameTable
= NULL
;
180 Retrieves a Unicode string that is the user-readable name of the driver.
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.
189 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
190 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
210 @retval EFI_INVALID_PARAMETER Language is NULL.
212 @retval EFI_INVALID_PARAMETER DriverName is NULL.
214 @retval EFI_UNSUPPORTED The driver specified by This does not support
215 the language specified by Language.
220 Ip6ComponentNameGetDriverName (
221 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
223 OUT CHAR16
**DriverName
226 return LookupUnicodeString2 (
228 This
->SupportedLanguages
,
231 (BOOLEAN
) (This
== &gIp6ComponentName
)
237 Update the component name for the IP6 child handle.
239 @param Ip6[in] A pointer to the EFI_IP6_PROTOCOL.
242 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
243 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
248 IN EFI_IP6_PROTOCOL
*Ip6
252 CHAR16 HandleName
[128];
253 EFI_IP6_MODE_DATA Ip6ModeData
;
255 CHAR16 Address
[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
258 return EFI_INVALID_PARAMETER
;
262 // Format the child name into the string buffer.
265 Status
= Ip6
->GetModeData (Ip6
, &Ip6ModeData
, NULL
, NULL
);
266 if (!EFI_ERROR (Status
)) {
267 if (Ip6ModeData
.AddressList
!= NULL
) {
268 FreePool (Ip6ModeData
.AddressList
);
271 if (Ip6ModeData
.GroupTable
!= NULL
) {
272 FreePool (Ip6ModeData
.GroupTable
);
275 if (Ip6ModeData
.RouteTable
!= NULL
) {
276 FreePool (Ip6ModeData
.RouteTable
);
279 if (Ip6ModeData
.NeighborCache
!= NULL
) {
280 FreePool (Ip6ModeData
.NeighborCache
);
283 if (Ip6ModeData
.PrefixTable
!= NULL
) {
284 FreePool (Ip6ModeData
.PrefixTable
);
287 if (Ip6ModeData
.IcmpTypeList
!= NULL
) {
288 FreePool (Ip6ModeData
.IcmpTypeList
);
292 if (!EFI_ERROR (Status
) && Ip6ModeData
.IsStarted
) {
293 Status
= NetLibIp6ToStr (&Ip6ModeData
.ConfigData
.StationAddress
, Address
, sizeof(Address
));
294 if (EFI_ERROR (Status
)) {
297 Offset
+= UnicodeSPrint (
300 L
"IPv6(StationAddress=%s, ",
303 Status
= NetLibIp6ToStr (&Ip6ModeData
.ConfigData
.DestinationAddress
, Address
, sizeof(Address
));
304 if (EFI_ERROR (Status
)) {
309 sizeof(HandleName
) - Offset
* sizeof (CHAR16
),
310 L
"DestinationAddress=%s)",
313 } else if (!Ip6ModeData
.IsStarted
) {
314 UnicodeSPrint (HandleName
, sizeof(HandleName
), L
"IPv6(Not started)");
316 UnicodeSPrint (HandleName
, sizeof(HandleName
), L
"IPv6(%r)", Status
);
319 if (gIp6ControllerNameTable
!= NULL
) {
320 FreeUnicodeStringTable (gIp6ControllerNameTable
);
321 gIp6ControllerNameTable
= NULL
;
324 Status
= AddUnicodeString2 (
326 gIp6ComponentName
.SupportedLanguages
,
327 &gIp6ControllerNameTable
,
331 if (EFI_ERROR (Status
)) {
335 return AddUnicodeString2 (
337 gIp6ComponentName2
.SupportedLanguages
,
338 &gIp6ControllerNameTable
,
345 Retrieves a Unicode string that is the user-readable name of the controller
346 that is being managed by a driver.
348 This function retrieves the user-readable name of the controller specified by
349 ControllerHandle and ChildHandle in the form of a Unicode string. If the
350 driver specified by This has a user-readable name in the language specified by
351 Language, then a pointer to the controller name is returned in ControllerName,
352 and EFI_SUCCESS is returned. If the driver specified by This is not currently
353 managing the controller specified by ControllerHandle and ChildHandle,
354 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
355 support the language specified by Language, then EFI_UNSUPPORTED is returned.
357 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
358 EFI_COMPONENT_NAME_PROTOCOL instance.
360 @param[in] ControllerHandle The handle of a controller that the driver
361 specified by This is managing. This handle
362 specifies the controller whose name is to be
365 @param[in] ChildHandle The handle of the child controller to retrieve
366 the name of. This is an optional parameter that
367 may be NULL. It will be NULL for device
368 drivers. It will also be NULL for a bus drivers
369 that wish to retrieve the name of the bus
370 controller. It will not be NULL for a bus
371 driver that wishes to retrieve the name of a
374 @param[in] Language A pointer to a Null-terminated ASCII string
375 array indicating the language. This is the
376 language of the driver name that the caller is
377 requesting, and it must match one of the
378 languages specified in SupportedLanguages. The
379 number of languages supported by a driver is up
380 to the driver writer. Language is specified in
381 RFC 4646 or ISO 639-2 language code format.
383 @param[out] ControllerName A pointer to the Unicode string to return.
384 This Unicode string is the name of the
385 controller specified by ControllerHandle and
386 ChildHandle in the language specified by
387 Language from the point of view of the driver
390 @retval EFI_SUCCESS The Unicode string for the user-readable name in
391 the language specified by Language for the
392 driver specified by This was returned in
395 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
397 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
400 @retval EFI_INVALID_PARAMETER Language is NULL.
402 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
404 @retval EFI_UNSUPPORTED The driver specified by This is not currently
405 managing the controller specified by
406 ControllerHandle and ChildHandle.
408 @retval EFI_UNSUPPORTED The driver specified by This does not support
409 the language specified by Language.
414 Ip6ComponentNameGetControllerName (
415 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
416 IN EFI_HANDLE ControllerHandle
,
417 IN EFI_HANDLE ChildHandle OPTIONAL
,
419 OUT CHAR16
**ControllerName
423 EFI_IP6_PROTOCOL
*Ip6
;
426 // Only provide names for child handles.
428 if (ChildHandle
== NULL
) {
429 return EFI_UNSUPPORTED
;
433 // Make sure this driver produced ChildHandle
435 Status
= EfiTestChildHandle (
438 &gEfiManagedNetworkProtocolGuid
440 if (EFI_ERROR (Status
)) {
445 // Retrieve an instance of a produced protocol from ChildHandle
447 Status
= gBS
->OpenProtocol (
449 &gEfiIp6ProtocolGuid
,
453 EFI_OPEN_PROTOCOL_GET_PROTOCOL
455 if (EFI_ERROR (Status
)) {
460 // Update the component name for this child handle.
462 Status
= UpdateName (Ip6
);
463 if (EFI_ERROR (Status
)) {
467 return LookupUnicodeString2 (
469 This
->SupportedLanguages
,
470 gIp6ControllerNameTable
,
472 (BOOLEAN
)(This
== &gIp6ComponentName
)