3 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
11 // EFI Component Name Functions
14 Retrieves a Unicode string that is the user readable name of the driver.
16 This function retrieves the user readable name of a driver in the form of a
17 Unicode string. If the driver specified by This has a user readable name in
18 the language specified by Language, then a pointer to the driver name is
19 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
20 by This does not support the language specified by Language,
21 then EFI_UNSUPPORTED is returned.
23 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
24 EFI_COMPONENT_NAME_PROTOCOL instance.
26 @param[in] Language A pointer to a Null-terminated ASCII string
27 array indicating the language. This is the
28 language of the driver name that the caller is
29 requesting, and it must match one of the
30 languages specified in SupportedLanguages. The
31 number of languages supported by a driver is up
32 to the driver writer. Language is specified
33 in RFC 4646 or ISO 639-2 language code format.
35 @param[out] DriverName A pointer to the Unicode string to return.
36 This Unicode string is the name of the
37 driver specified by This in the language
38 specified by Language.
40 @retval EFI_SUCCESS The Unicode string for the Driver specified by
41 This and the language specified by Language was
42 returned in DriverName.
44 @retval EFI_INVALID_PARAMETER Language is NULL.
46 @retval EFI_INVALID_PARAMETER DriverName is NULL.
48 @retval EFI_UNSUPPORTED The driver specified by This does not support
49 the language specified by Language.
54 Ip4ComponentNameGetDriverName (
55 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
57 OUT CHAR16
**DriverName
62 Retrieves a Unicode string that is the user readable name of the controller
63 that is being managed by a driver.
65 This function retrieves the user readable name of the controller specified by
66 ControllerHandle and ChildHandle in the form of a Unicode string. If the
67 driver specified by This has a user readable name in the language specified by
68 Language, then a pointer to the controller name is returned in ControllerName,
69 and EFI_SUCCESS is returned. If the driver specified by This is not currently
70 managing the controller specified by ControllerHandle and ChildHandle,
71 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
72 support the language specified by Language, then EFI_UNSUPPORTED is returned.
74 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
75 EFI_COMPONENT_NAME_PROTOCOL instance.
77 @param[in] ControllerHandle The handle of a controller that the driver
78 specified by This is managing. This handle
79 specifies the controller whose name is to be
82 @param[in] ChildHandle The handle of the child controller to retrieve
83 the name of. This is an optional parameter that
84 may be NULL. It will be NULL for device
85 drivers. It will also be NULL for a bus drivers
86 that wish to retrieve the name of the bus
87 controller. It will not be NULL for a bus
88 driver that wishes to retrieve the name of a
91 @param[in] Language A pointer to a Null-terminated ASCII string
92 array indicating the language. This is the
93 language of the driver name that the caller is
94 requesting, and it must match one of the
95 languages specified in SupportedLanguages. The
96 number of languages supported by a driver is up
97 to the driver writer. Language is specified in
98 RFC 4646 or ISO 639-2 language code format.
100 @param[out] ControllerName A pointer to the Unicode string to return.
101 This Unicode string is the name of the
102 controller specified by ControllerHandle and
103 ChildHandle in the language specified by
104 Language from the point of view of the driver
107 @retval EFI_SUCCESS The Unicode string for the user readable name in
108 the language specified by Language for the
109 driver specified by This was returned in
112 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
114 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
117 @retval EFI_INVALID_PARAMETER Language is NULL.
119 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
121 @retval EFI_UNSUPPORTED The driver specified by This is not currently
122 managing the controller specified by
123 ControllerHandle and ChildHandle.
125 @retval EFI_UNSUPPORTED The driver specified by This does not support
126 the language specified by Language.
131 Ip4ComponentNameGetControllerName (
132 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
133 IN EFI_HANDLE ControllerHandle
,
134 IN EFI_HANDLE ChildHandle OPTIONAL
,
136 OUT CHAR16
**ControllerName
141 // EFI Component Name Protocol
143 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName
= {
144 Ip4ComponentNameGetDriverName
,
145 Ip4ComponentNameGetControllerName
,
150 // EFI Component Name 2 Protocol
152 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2
= {
153 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Ip4ComponentNameGetDriverName
,
154 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Ip4ComponentNameGetControllerName
,
159 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4DriverNameTable
[] = {
162 L
"IP4 Network Service Driver"
170 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gIp4ControllerNameTable
= NULL
;
173 Retrieves a Unicode string that is the user readable name of the driver.
175 This function retrieves the user readable name of a driver in the form of a
176 Unicode string. If the driver specified by This has a user readable name in
177 the language specified by Language, then a pointer to the driver name is
178 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
179 by This does not support the language specified by Language,
180 then EFI_UNSUPPORTED is returned.
182 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
183 EFI_COMPONENT_NAME_PROTOCOL instance.
185 @param[in] Language A pointer to a Null-terminated ASCII string
186 array indicating the language. This is the
187 language of the driver name that the caller is
188 requesting, and it must match one of the
189 languages specified in SupportedLanguages. The
190 number of languages supported by a driver is up
191 to the driver writer. Language is specified
192 in RFC 4646 or ISO 639-2 language code format.
194 @param[out] DriverName A pointer to the Unicode string to return.
195 This Unicode string is the name of the
196 driver specified by This in the language
197 specified by Language.
199 @retval EFI_SUCCESS The Unicode string for the Driver specified by
200 This and the language specified by Language was
201 returned in DriverName.
203 @retval EFI_INVALID_PARAMETER Language is NULL.
205 @retval EFI_INVALID_PARAMETER DriverName is NULL.
207 @retval EFI_UNSUPPORTED The driver specified by This does not support
208 the language specified by Language.
213 Ip4ComponentNameGetDriverName (
214 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
216 OUT CHAR16
**DriverName
219 return LookupUnicodeString2 (
221 This
->SupportedLanguages
,
224 (BOOLEAN
)(This
== &gIp4ComponentName
)
230 Update the component name for the IP4 child handle.
232 @param Ip4[in] A pointer to the EFI_IP4_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_IP4_PROTOCOL
*Ip4
245 CHAR16 HandleName
[80];
246 EFI_IP4_MODE_DATA Ip4ModeData
;
249 return EFI_INVALID_PARAMETER
;
253 // Format the child name into the string buffer as:
254 // IPv4 (SrcIP=127.0.0.1, DestIP=127.0.0.1)
256 Status
= Ip4
->GetModeData (Ip4
, &Ip4ModeData
, NULL
, NULL
);
257 if (EFI_ERROR (Status
)) {
261 if (!Ip4ModeData
.IsStarted
|| !Ip4ModeData
.IsConfigured
) {
262 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"IPv4 (Not started)");
264 UnicodeSPrint (HandleName
, sizeof (HandleName
),
265 L
"IPv4 (SrcIP=%d.%d.%d.%d)",
266 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[0],
267 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[1],
268 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[2],
269 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[3]
273 if (gIp4ControllerNameTable
!= NULL
) {
274 FreeUnicodeStringTable (gIp4ControllerNameTable
);
275 gIp4ControllerNameTable
= NULL
;
277 Status
= AddUnicodeString2 (
279 gIp4ComponentName
.SupportedLanguages
,
280 &gIp4ControllerNameTable
,
284 if (EFI_ERROR (Status
)) {
288 return AddUnicodeString2 (
290 gIp4ComponentName2
.SupportedLanguages
,
291 &gIp4ControllerNameTable
,
298 Retrieves a Unicode string that is the user readable name of the controller
299 that is being managed by a driver.
301 This function retrieves the user readable name of the controller specified by
302 ControllerHandle and ChildHandle in the form of a Unicode string. If the
303 driver specified by This has a user readable name in the language specified by
304 Language, then a pointer to the controller name is returned in ControllerName,
305 and EFI_SUCCESS is returned. If the driver specified by This is not currently
306 managing the controller specified by ControllerHandle and ChildHandle,
307 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
308 support the language specified by Language, then EFI_UNSUPPORTED is returned.
310 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
311 EFI_COMPONENT_NAME_PROTOCOL instance.
313 @param[in] ControllerHandle The handle of a controller that the driver
314 specified by This is managing. This handle
315 specifies the controller whose name is to be
318 @param[in] ChildHandle The handle of the child controller to retrieve
319 the name of. This is an optional parameter that
320 may be NULL. It will be NULL for device
321 drivers. It will also be NULL for a bus drivers
322 that wish to retrieve the name of the bus
323 controller. It will not be NULL for a bus
324 driver that wishes to retrieve the name of a
327 @param[in] Language A pointer to a Null-terminated ASCII string
328 array indicating the language. This is the
329 language of the driver name that the caller is
330 requesting, and it must match one of the
331 languages specified in SupportedLanguages. The
332 number of languages supported by a driver is up
333 to the driver writer. Language is specified in
334 RFC 4646 or ISO 639-2 language code format.
336 @param[out] ControllerName A pointer to the Unicode string to return.
337 This Unicode string is the name of the
338 controller specified by ControllerHandle and
339 ChildHandle in the language specified by
340 Language from the point of view of the driver
343 @retval EFI_SUCCESS The Unicode string for the user readable name in
344 the language specified by Language for the
345 driver specified by This was returned in
348 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
350 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
353 @retval EFI_INVALID_PARAMETER Language is NULL.
355 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
357 @retval EFI_UNSUPPORTED The driver specified by This is not currently
358 managing the controller specified by
359 ControllerHandle and ChildHandle.
361 @retval EFI_UNSUPPORTED The driver specified by This does not support
362 the language specified by Language.
367 Ip4ComponentNameGetControllerName (
368 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
369 IN EFI_HANDLE ControllerHandle
,
370 IN EFI_HANDLE ChildHandle OPTIONAL
,
372 OUT CHAR16
**ControllerName
376 EFI_IP4_PROTOCOL
*Ip4
;
379 // Only provide names for child handles.
381 if (ChildHandle
== NULL
) {
382 return EFI_UNSUPPORTED
;
386 // Make sure this driver produced ChildHandle
388 Status
= EfiTestChildHandle (
391 &gEfiManagedNetworkProtocolGuid
393 if (EFI_ERROR (Status
)) {
398 // Retrieve an instance of a produced protocol from ChildHandle
400 Status
= gBS
->OpenProtocol (
402 &gEfiIp4ProtocolGuid
,
406 EFI_OPEN_PROTOCOL_GET_PROTOCOL
408 if (EFI_ERROR (Status
)) {
413 // Update the component name for this child handle.
415 Status
= UpdateName (Ip4
);
416 if (EFI_ERROR (Status
)) {
420 return LookupUnicodeString2 (
422 This
->SupportedLanguages
,
423 gIp4ControllerNameTable
,
425 (BOOLEAN
)(This
== &gIp4ComponentName
)