3 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
11 // EFI Component Name Functions
15 Retrieves a Unicode string that is the user readable name of the driver.
17 This function retrieves the user readable name of a driver in the form of a
18 Unicode string. If the driver specified by This has a user readable name in
19 the language specified by Language, then a pointer to the driver name is
20 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
21 by This does not support the language specified by Language,
22 then EFI_UNSUPPORTED is returned.
24 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
25 EFI_COMPONENT_NAME_PROTOCOL instance.
27 @param[in] Language A pointer to a Null-terminated ASCII string
28 array indicating the language. This is the
29 language of the driver name that the caller is
30 requesting, and it must match one of the
31 languages specified in SupportedLanguages. The
32 number of languages supported by a driver is up
33 to the driver writer. Language is specified
34 in RFC 4646 or ISO 639-2 language code format.
36 @param[out] DriverName A pointer to the Unicode string to return.
37 This Unicode string is the name of the
38 driver specified by This in the language
39 specified by Language.
41 @retval EFI_SUCCESS The Unicode string for the Driver specified by
42 This and the language specified by Language was
43 returned in DriverName.
45 @retval EFI_INVALID_PARAMETER Language is NULL.
47 @retval EFI_INVALID_PARAMETER DriverName is NULL.
49 @retval EFI_UNSUPPORTED The driver specified by This does not support
50 the language specified by Language.
55 Ip4ComponentNameGetDriverName (
56 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
58 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
140 // EFI Component Name Protocol
142 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName
= {
143 Ip4ComponentNameGetDriverName
,
144 Ip4ComponentNameGetControllerName
,
149 // EFI Component Name 2 Protocol
151 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2
= {
152 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)Ip4ComponentNameGetDriverName
,
153 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)Ip4ComponentNameGetControllerName
,
157 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4DriverNameTable
[] = {
160 L
"IP4 Network Service Driver"
168 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gIp4ControllerNameTable
= NULL
;
171 Retrieves a Unicode string that is the user readable name of the driver.
173 This function retrieves the user readable name of a driver in the form of a
174 Unicode string. If the driver specified by This has a user readable name in
175 the language specified by Language, then a pointer to the driver name is
176 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
177 by This does not support the language specified by Language,
178 then EFI_UNSUPPORTED is returned.
180 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
181 EFI_COMPONENT_NAME_PROTOCOL instance.
183 @param[in] Language A pointer to a Null-terminated ASCII string
184 array indicating the language. This is the
185 language of the driver name that the caller is
186 requesting, and it must match one of the
187 languages specified in SupportedLanguages. The
188 number of languages supported by a driver is up
189 to the driver writer. Language is specified
190 in RFC 4646 or ISO 639-2 language code format.
192 @param[out] DriverName A pointer to the Unicode string to return.
193 This Unicode string is the name of the
194 driver specified by This in the language
195 specified by Language.
197 @retval EFI_SUCCESS The Unicode string for the Driver specified by
198 This and the language specified by Language was
199 returned in DriverName.
201 @retval EFI_INVALID_PARAMETER Language is NULL.
203 @retval EFI_INVALID_PARAMETER DriverName is NULL.
205 @retval EFI_UNSUPPORTED The driver specified by This does not support
206 the language specified by Language.
211 Ip4ComponentNameGetDriverName (
212 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
214 OUT CHAR16
**DriverName
217 return LookupUnicodeString2 (
219 This
->SupportedLanguages
,
222 (BOOLEAN
)(This
== &gIp4ComponentName
)
227 Update the component name for the IP4 child handle.
229 @param Ip4[in] A pointer to the EFI_IP4_PROTOCOL.
232 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
233 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
238 IN EFI_IP4_PROTOCOL
*Ip4
242 CHAR16 HandleName
[80];
243 EFI_IP4_MODE_DATA Ip4ModeData
;
246 return EFI_INVALID_PARAMETER
;
250 // Format the child name into the string buffer as:
251 // IPv4 (SrcIP=127.0.0.1, DestIP=127.0.0.1)
253 Status
= Ip4
->GetModeData (Ip4
, &Ip4ModeData
, NULL
, NULL
);
254 if (EFI_ERROR (Status
)) {
258 if (!Ip4ModeData
.IsStarted
|| !Ip4ModeData
.IsConfigured
) {
259 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"IPv4 (Not started)");
264 L
"IPv4 (SrcIP=%d.%d.%d.%d)",
265 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[0],
266 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[1],
267 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[2],
268 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[3]
272 if (gIp4ControllerNameTable
!= NULL
) {
273 FreeUnicodeStringTable (gIp4ControllerNameTable
);
274 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
)