2 Implementation of protocols EFI_COMPONENT_NAME_PROTOCOL and
3 EFI_COMPONENT_NAME2_PROTOCOL.
5 Copyright (c) 2009 - 2015, 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 or DriverName is NULL.
56 @retval EFI_UNSUPPORTED The driver specified by This does not support
57 the language specified by Language.
62 TcpComponentNameGetDriverName (
63 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
65 OUT CHAR16
**DriverName
69 Retrieves a Unicode string that is the user-readable name of the controller
70 that is being managed by a driver.
72 This function retrieves the user-readable name of the controller specified by
73 ControllerHandle and ChildHandle in the form of a Unicode string. If the
74 driver specified by This has a user-readable name in the language specified by
75 Language, then a pointer to the controller name is returned in ControllerName,
76 and EFI_SUCCESS is returned. If the driver specified by This is not currently
77 managing the controller specified by ControllerHandle and ChildHandle,
78 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
79 support the language specified by Language, then EFI_UNSUPPORTED is returned.
81 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
82 EFI_COMPONENT_NAME_PROTOCOL instance.
84 @param[in] ControllerHandle The handle of a controller that the driver
85 specified by This is managing. This handle
86 specifies the controller whose name is to be
89 @param[in] ChildHandle The handle of the child controller to retrieve
90 the name of. This is an optional parameter that
91 may be NULL. It will be NULL for device
92 drivers. It will also be NULL for a bus drivers
93 that wish to retrieve the name of the bus
94 controller. It will not be NULL for a bus
95 driver that wishes to retrieve the name of a
98 @param[in] Language A pointer to a Null-terminated ASCII string
99 array indicating the language. This is the
100 language of the driver name that the caller is
101 requesting, and it must match one of the
102 languages specified in SupportedLanguages. The
103 number of languages supported by a driver is up
104 to the driver writer. Language is specified in
105 RFC 4646 or ISO 639-2 language code format.
107 @param[out] ControllerName A pointer to the Unicode string to return.
108 This Unicode string is the name of the
109 controller specified by ControllerHandle and
110 ChildHandle in the language specified by
111 Language, from the point of view of the driver
114 @retval EFI_SUCCESS The Unicode string for the user-readable name in
115 the language specified by Language for the
116 driver specified by This was returned in
119 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
121 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
124 @retval EFI_INVALID_PARAMETER Language or ControllerName is NULL.
126 @retval EFI_UNSUPPORTED The driver specified by This is not currently
127 managing the controller specified by
128 ControllerHandle and ChildHandle.
130 @retval EFI_UNSUPPORTED The driver specified by This does not support
131 the language specified by Language.
136 TcpComponentNameGetControllerName (
137 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
138 IN EFI_HANDLE ControllerHandle
,
139 IN EFI_HANDLE ChildHandle OPTIONAL
,
141 OUT CHAR16
**ControllerName
145 /// EFI Component Name Protocol
147 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gTcpComponentName
= {
148 TcpComponentNameGetDriverName
,
149 TcpComponentNameGetControllerName
,
154 /// EFI Component Name 2 Protocol
156 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gTcpComponentName2
= {
157 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) TcpComponentNameGetDriverName
,
158 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) TcpComponentNameGetControllerName
,
162 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTcpDriverNameTable
[] = {
165 L
"TCP Network Service Driver"
173 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gTcpControllerNameTable
= NULL
;
176 Retrieves a Unicode string that is the user-readable name of the driver.
178 This function retrieves the user-readable name of a driver in the form of a
179 Unicode string. If the driver specified by This has a user-readable name in
180 the language specified by Language, then a pointer to the driver name is
181 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
182 by This does not support the language specified by Language,
183 then EFI_UNSUPPORTED is returned.
185 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
186 EFI_COMPONENT_NAME_PROTOCOL instance.
188 @param[in] Language A pointer to a Null-terminated ASCII string
189 array indicating the language. This is the
190 language of the driver name that the caller is
191 requesting, and it must match one of the
192 languages specified in SupportedLanguages. The
193 number of languages supported by a driver is up
194 to the driver writer. Language is specified
195 in RFC 4646 or ISO 639-2 language code format.
197 @param[out] DriverName A pointer to the Unicode string to return.
198 This Unicode string is the name of the
199 driver specified by This in the language
200 specified by Language.
202 @retval EFI_SUCCESS The Unicode string for the Driver specified by
203 This, and the language specified by Language was
204 returned in DriverName.
206 @retval EFI_INVALID_PARAMETER Language or DriverName is NULL.
208 @retval EFI_UNSUPPORTED The driver specified by This does not support
209 the language specified by Language.
214 TcpComponentNameGetDriverName (
215 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
217 OUT CHAR16
**DriverName
220 return LookupUnicodeString2 (
222 This
->SupportedLanguages
,
225 (BOOLEAN
) (This
== &gTcpComponentName
)
230 Update the component name for the Tcp4 child handle.
232 @param Tcp4[in] A pointer to the EFI_TCP4_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_TCP4_PROTOCOL
*Tcp4
245 CHAR16 HandleName
[80];
246 EFI_TCP4_CONFIG_DATA Tcp4ConfigData
;
249 return EFI_INVALID_PARAMETER
;
253 // Format the child name into the string buffer as:
254 // TCPv4 (SrcPort=59, DestPort=60, ActiveFlag=TRUE)
256 ZeroMem (&Tcp4ConfigData
, sizeof (Tcp4ConfigData
));
257 Status
= Tcp4
->GetModeData (Tcp4
, NULL
, &Tcp4ConfigData
, NULL
, NULL
, NULL
);
258 if (!EFI_ERROR (Status
)) {
259 UnicodeSPrint (HandleName
, sizeof (HandleName
),
260 L
"TCPv4 (SrcPort=%d, DestPort=%d, ActiveFlag=%s)",
261 Tcp4ConfigData
.AccessPoint
.StationPort
,
262 Tcp4ConfigData
.AccessPoint
.RemotePort
,
263 (Tcp4ConfigData
.AccessPoint
.ActiveFlag
? L
"TRUE" : L
"FALSE")
265 } else if (Status
== EFI_NOT_STARTED
) {
269 L
"TCPv4 (Not started)"
275 if (gTcpControllerNameTable
!= NULL
) {
276 FreeUnicodeStringTable (gTcpControllerNameTable
);
277 gTcpControllerNameTable
= NULL
;
280 Status
= AddUnicodeString2 (
282 gTcpComponentName
.SupportedLanguages
,
283 &gTcpControllerNameTable
,
287 if (EFI_ERROR (Status
)) {
291 return AddUnicodeString2 (
293 gTcpComponentName2
.SupportedLanguages
,
294 &gTcpControllerNameTable
,
301 Update the component name for the Tcp6 child handle.
303 @param Tcp6[in] A pointer to the EFI_TCP6_PROTOCOL.
306 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
307 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
312 IN EFI_TCP6_PROTOCOL
*Tcp6
316 CHAR16 HandleName
[80];
317 EFI_TCP6_CONFIG_DATA Tcp6ConfigData
;
320 return EFI_INVALID_PARAMETER
;
324 // Format the child name into the string buffer.
326 ZeroMem (&Tcp6ConfigData
, sizeof (Tcp6ConfigData
));
327 Status
= Tcp6
->GetModeData (Tcp6
, NULL
, &Tcp6ConfigData
, NULL
, NULL
, NULL
);
328 if (!EFI_ERROR (Status
)) {
329 UnicodeSPrint (HandleName
, sizeof (HandleName
),
330 L
"TCPv6(SrcPort=%d, DestPort=%d, ActiveFlag=%d)",
331 Tcp6ConfigData
.AccessPoint
.StationPort
,
332 Tcp6ConfigData
.AccessPoint
.RemotePort
,
333 Tcp6ConfigData
.AccessPoint
.ActiveFlag
335 } else if (Status
== EFI_NOT_STARTED
) {
336 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"TCPv6(Not started)");
342 if (gTcpControllerNameTable
!= NULL
) {
343 FreeUnicodeStringTable (gTcpControllerNameTable
);
344 gTcpControllerNameTable
= NULL
;
347 Status
= AddUnicodeString2 (
349 gTcpComponentName
.SupportedLanguages
,
350 &gTcpControllerNameTable
,
354 if (EFI_ERROR (Status
)) {
358 return AddUnicodeString2 (
360 gTcpComponentName2
.SupportedLanguages
,
361 &gTcpControllerNameTable
,
368 Retrieves a Unicode string that is the user-readable name of the controller
369 that is being managed by a driver.
371 This function retrieves the user-readable name of the controller specified by
372 ControllerHandle and ChildHandle in the form of a Unicode string. If the
373 driver specified by This has a user-readable name in the language specified by
374 Language, then a pointer to the controller name is returned in ControllerName,
375 and EFI_SUCCESS is returned. If the driver specified by This is not currently
376 managing the controller specified by ControllerHandle and ChildHandle,
377 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
378 support the language specified by Language, then EFI_UNSUPPORTED is returned.
380 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
381 EFI_COMPONENT_NAME_PROTOCOL instance.
383 @param[in] ControllerHandle The handle of a controller that the driver
384 specified by This is managing. This handle
385 specifies the controller whose name is to be
388 @param[in] ChildHandle The handle of the child controller to retrieve
389 the name of. This is an optional parameter that
390 may be NULL. It will be NULL for device
391 drivers. It will also be NULL for a bus drivers
392 that wish to retrieve the name of the bus
393 controller. It will not be NULL for a bus
394 driver that wishes to retrieve the name of a
397 @param[in] Language A pointer to a Null-terminated ASCII string
398 array indicating the language. This is the
399 language of the driver name that the caller is
400 requesting, and it must match one of the
401 languages specified in SupportedLanguages. The
402 number of languages supported by a driver is up
403 to the driver writer. Language is specified in
404 RFC 4646 or ISO 639-2 language code format.
406 @param[out] ControllerName A pointer to the Unicode string to return.
407 This Unicode string is the name of the
408 controller specified by ControllerHandle and
409 ChildHandle in the language specified by
410 Language, from the point of view of the driver
413 @retval EFI_SUCCESS The Unicode string for the user-readable name in
414 the language specified by Language for the
415 driver specified by This was returned in
418 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
420 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
423 @retval EFI_INVALID_PARAMETER Language or ControllerName is NULL.
425 @retval EFI_UNSUPPORTED The driver specified by This is not currently
426 managing the controller specified by
427 ControllerHandle and ChildHandle.
429 @retval EFI_UNSUPPORTED The driver specified by This does not support
430 the language specified by Language.
435 TcpComponentNameGetControllerName (
436 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
437 IN EFI_HANDLE ControllerHandle
,
438 IN EFI_HANDLE ChildHandle OPTIONAL
,
440 OUT CHAR16
**ControllerName
444 EFI_TCP4_PROTOCOL
*Tcp4
;
445 EFI_TCP6_PROTOCOL
*Tcp6
;
448 // Only provide names for child handles.
450 if (ChildHandle
== NULL
) {
451 return EFI_UNSUPPORTED
;
455 // Make sure this driver produced ChildHandle
457 Status
= EfiTestChildHandle (
462 if (!EFI_ERROR (Status
)) {
464 // Retrieve an instance of a produced protocol from ChildHandle
466 Status
= gBS
->OpenProtocol (
468 &gEfiTcp6ProtocolGuid
,
472 EFI_OPEN_PROTOCOL_GET_PROTOCOL
474 if (EFI_ERROR (Status
)) {
479 // Update the component name for this child handle.
481 Status
= UpdateTcp6Name (Tcp6
);
482 if (EFI_ERROR (Status
)) {
488 // Make sure this driver is currently managing ControllHandle
490 Status
= EfiTestChildHandle (
495 if (!EFI_ERROR (Status
)) {
497 // Retrieve an instance of a produced protocol from ChildHandle
499 Status
= gBS
->OpenProtocol (
501 &gEfiTcp4ProtocolGuid
,
505 EFI_OPEN_PROTOCOL_GET_PROTOCOL
507 if (EFI_ERROR (Status
)) {
512 // Update the component name for this child handle.
514 Status
= UpdateTcp4Name (Tcp4
);
515 if (EFI_ERROR (Status
)) {
520 return LookupUnicodeString2 (
522 This
->SupportedLanguages
,
523 gTcpControllerNameTable
,
525 (BOOLEAN
)(This
== &gTcpComponentName
)