3 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at<BR>
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 // EFI Component Name Functions
20 Retrieves a Unicode string that is the user readable name of the driver.
22 This function retrieves the user readable name of a driver in the form of a
23 Unicode string. If the driver specified by This has a user readable name in
24 the language specified by Language, then a pointer to the driver name is
25 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
26 by This does not support the language specified by Language,
27 then EFI_UNSUPPORTED is returned.
29 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
30 EFI_COMPONENT_NAME_PROTOCOL instance.
32 @param[in] Language A pointer to a Null-terminated ASCII string
33 array indicating the language. This is the
34 language of the driver name that the caller is
35 requesting, and it must match one of the
36 languages specified in SupportedLanguages. The
37 number of languages supported by a driver is up
38 to the driver writer. Language is specified
39 in RFC 4646 or ISO 639-2 language code format.
41 @param[out] DriverName A pointer to the Unicode string to return.
42 This Unicode string is the name of the
43 driver specified by This in the language
44 specified by Language.
46 @retval EFI_SUCCESS The Unicode string for the Driver specified by
47 This and the language specified by Language was
48 returned in DriverName.
50 @retval EFI_INVALID_PARAMETER Language is NULL.
52 @retval EFI_INVALID_PARAMETER DriverName is NULL.
54 @retval EFI_UNSUPPORTED The driver specified by This does not support
55 the language specified by Language.
60 Ip4ComponentNameGetDriverName (
61 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
63 OUT CHAR16
**DriverName
68 Retrieves a Unicode string that is the user readable name of the controller
69 that is being managed by a driver.
71 This function retrieves the user readable name of the controller specified by
72 ControllerHandle and ChildHandle in the form of a Unicode string. If the
73 driver specified by This has a user readable name in the language specified by
74 Language, then a pointer to the controller name is returned in ControllerName,
75 and EFI_SUCCESS is returned. If the driver specified by This is not currently
76 managing the controller specified by ControllerHandle and ChildHandle,
77 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
78 support the language specified by Language, then EFI_UNSUPPORTED is returned.
80 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
81 EFI_COMPONENT_NAME_PROTOCOL instance.
83 @param[in] ControllerHandle The handle of a controller that the driver
84 specified by This is managing. This handle
85 specifies the controller whose name is to be
88 @param[in] ChildHandle The handle of the child controller to retrieve
89 the name of. This is an optional parameter that
90 may be NULL. It will be NULL for device
91 drivers. It will also be NULL for a bus drivers
92 that wish to retrieve the name of the bus
93 controller. It will not be NULL for a bus
94 driver that wishes to retrieve the name of a
97 @param[in] Language A pointer to a Null-terminated ASCII string
98 array indicating the language. This is the
99 language of the driver name that the caller is
100 requesting, and it must match one of the
101 languages specified in SupportedLanguages. The
102 number of languages supported by a driver is up
103 to the driver writer. Language is specified in
104 RFC 4646 or ISO 639-2 language code format.
106 @param[out] ControllerName A pointer to the Unicode string to return.
107 This Unicode string is the name of the
108 controller specified by ControllerHandle and
109 ChildHandle in the language specified by
110 Language from the point of view of the driver
113 @retval EFI_SUCCESS The Unicode string for the user readable name in
114 the language specified by Language for the
115 driver specified by This was returned in
118 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
120 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
123 @retval EFI_INVALID_PARAMETER Language is NULL.
125 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
127 @retval EFI_UNSUPPORTED The driver specified by This is not currently
128 managing the controller specified by
129 ControllerHandle and ChildHandle.
131 @retval EFI_UNSUPPORTED The driver specified by This does not support
132 the language specified by Language.
137 Ip4ComponentNameGetControllerName (
138 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
139 IN EFI_HANDLE ControllerHandle
,
140 IN EFI_HANDLE ChildHandle OPTIONAL
,
142 OUT CHAR16
**ControllerName
147 // EFI Component Name Protocol
149 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName
= {
150 Ip4ComponentNameGetDriverName
,
151 Ip4ComponentNameGetControllerName
,
156 // EFI Component Name 2 Protocol
158 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2
= {
159 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Ip4ComponentNameGetDriverName
,
160 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Ip4ComponentNameGetControllerName
,
165 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4DriverNameTable
[] = {
168 L
"IP4 Network Service Driver"
176 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gIp4ControllerNameTable
= NULL
;
179 Retrieves a Unicode string that is the user readable name of the driver.
181 This function retrieves the user readable name of a driver in the form of a
182 Unicode string. If the driver specified by This has a user readable name in
183 the language specified by Language, then a pointer to the driver name is
184 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
185 by This does not support the language specified by Language,
186 then EFI_UNSUPPORTED is returned.
188 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
189 EFI_COMPONENT_NAME_PROTOCOL instance.
191 @param[in] Language A pointer to a Null-terminated ASCII string
192 array indicating the language. This is the
193 language of the driver name that the caller is
194 requesting, and it must match one of the
195 languages specified in SupportedLanguages. The
196 number of languages supported by a driver is up
197 to the driver writer. Language is specified
198 in RFC 4646 or ISO 639-2 language code format.
200 @param[out] DriverName A pointer to the Unicode string to return.
201 This Unicode string is the name of the
202 driver specified by This in the language
203 specified by Language.
205 @retval EFI_SUCCESS The Unicode string for the Driver specified by
206 This and the language specified by Language was
207 returned in DriverName.
209 @retval EFI_INVALID_PARAMETER Language is NULL.
211 @retval EFI_INVALID_PARAMETER DriverName is NULL.
213 @retval EFI_UNSUPPORTED The driver specified by This does not support
214 the language specified by Language.
219 Ip4ComponentNameGetDriverName (
220 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
222 OUT CHAR16
**DriverName
225 return LookupUnicodeString2 (
227 This
->SupportedLanguages
,
230 (BOOLEAN
)(This
== &gIp4ComponentName
)
236 Update the component name for the IP4 child handle.
238 @param Ip4[in] A pointer to the EFI_IP4_PROTOCOL.
241 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
242 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
247 IN EFI_IP4_PROTOCOL
*Ip4
251 CHAR16 HandleName
[80];
252 EFI_IP4_MODE_DATA Ip4ModeData
;
255 return EFI_INVALID_PARAMETER
;
259 // Format the child name into the string buffer as:
260 // IPv4 (SrcIP=127.0.0.1, DestIP=127.0.0.1)
262 Status
= Ip4
->GetModeData (Ip4
, &Ip4ModeData
, NULL
, NULL
);
263 if (EFI_ERROR (Status
)) {
267 if (!Ip4ModeData
.IsStarted
|| !Ip4ModeData
.IsConfigured
) {
268 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"IPv4 (Not started)");
270 UnicodeSPrint (HandleName
, sizeof (HandleName
),
271 L
"IPv4 (SrcIP=%d.%d.%d.%d)",
272 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[0],
273 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[1],
274 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[2],
275 Ip4ModeData
.ConfigData
.StationAddress
.Addr
[3]
279 if (gIp4ControllerNameTable
!= NULL
) {
280 FreeUnicodeStringTable (gIp4ControllerNameTable
);
281 gIp4ControllerNameTable
= NULL
;
283 Status
= AddUnicodeString2 (
285 gIp4ComponentName
.SupportedLanguages
,
286 &gIp4ControllerNameTable
,
290 if (EFI_ERROR (Status
)) {
294 return AddUnicodeString2 (
296 gIp4ComponentName2
.SupportedLanguages
,
297 &gIp4ControllerNameTable
,
304 Retrieves a Unicode string that is the user readable name of the controller
305 that is being managed by a driver.
307 This function retrieves the user readable name of the controller specified by
308 ControllerHandle and ChildHandle in the form of a Unicode string. If the
309 driver specified by This has a user readable name in the language specified by
310 Language, then a pointer to the controller name is returned in ControllerName,
311 and EFI_SUCCESS is returned. If the driver specified by This is not currently
312 managing the controller specified by ControllerHandle and ChildHandle,
313 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
314 support the language specified by Language, then EFI_UNSUPPORTED is returned.
316 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
317 EFI_COMPONENT_NAME_PROTOCOL instance.
319 @param[in] ControllerHandle The handle of a controller that the driver
320 specified by This is managing. This handle
321 specifies the controller whose name is to be
324 @param[in] ChildHandle The handle of the child controller to retrieve
325 the name of. This is an optional parameter that
326 may be NULL. It will be NULL for device
327 drivers. It will also be NULL for a bus drivers
328 that wish to retrieve the name of the bus
329 controller. It will not be NULL for a bus
330 driver that wishes to retrieve the name of a
333 @param[in] Language A pointer to a Null-terminated ASCII string
334 array indicating the language. This is the
335 language of the driver name that the caller is
336 requesting, and it must match one of the
337 languages specified in SupportedLanguages. The
338 number of languages supported by a driver is up
339 to the driver writer. Language is specified in
340 RFC 4646 or ISO 639-2 language code format.
342 @param[out] ControllerName A pointer to the Unicode string to return.
343 This Unicode string is the name of the
344 controller specified by ControllerHandle and
345 ChildHandle in the language specified by
346 Language from the point of view of the driver
349 @retval EFI_SUCCESS The Unicode string for the user readable name in
350 the language specified by Language for the
351 driver specified by This was returned in
354 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
356 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
359 @retval EFI_INVALID_PARAMETER Language is NULL.
361 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
363 @retval EFI_UNSUPPORTED The driver specified by This is not currently
364 managing the controller specified by
365 ControllerHandle and ChildHandle.
367 @retval EFI_UNSUPPORTED The driver specified by This does not support
368 the language specified by Language.
373 Ip4ComponentNameGetControllerName (
374 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
375 IN EFI_HANDLE ControllerHandle
,
376 IN EFI_HANDLE ChildHandle OPTIONAL
,
378 OUT CHAR16
**ControllerName
382 EFI_IP4_PROTOCOL
*Ip4
;
385 // Only provide names for child handles.
387 if (ChildHandle
== NULL
) {
388 return EFI_UNSUPPORTED
;
392 // Make sure this driver produced ChildHandle
394 Status
= EfiTestChildHandle (
397 &gEfiManagedNetworkProtocolGuid
399 if (EFI_ERROR (Status
)) {
404 // Retrieve an instance of a produced protocol from ChildHandle
406 Status
= gBS
->OpenProtocol (
408 &gEfiIp4ProtocolGuid
,
412 EFI_OPEN_PROTOCOL_GET_PROTOCOL
414 if (EFI_ERROR (Status
)) {
419 // Update the component name for this child handle.
421 Status
= UpdateName (Ip4
);
422 if (EFI_ERROR (Status
)) {
426 return LookupUnicodeString2 (
428 This
->SupportedLanguages
,
429 gIp4ControllerNameTable
,
431 (BOOLEAN
)(This
== &gIp4ComponentName
)