2 Implementation of protocols EFI_COMPONENT_NAME_PROTOCOL and
3 EFI_COMPONENT_NAME2_PROTOCOL.
5 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
14 // EFI Component Name Functions
18 Retrieves a Unicode string that is the user-readable name of the driver.
20 This function retrieves the user-readable name of a driver in the form of a
21 Unicode string. If the driver specified by This has a user-readable name in
22 the language specified by Language, then a pointer to the driver name is
23 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
24 by This does not support the language specified by Language,
25 then EFI_UNSUPPORTED is returned.
27 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
28 EFI_COMPONENT_NAME_PROTOCOL instance.
30 @param[in] Language A pointer to a Null-terminated ASCII string
31 array indicating the language. This is the
32 language of the driver name that the caller is
33 requesting, and it must match one of the
34 languages specified in SupportedLanguages. The
35 number of languages supported by a driver is up
36 to the driver writer. Language is specified
37 in RFC 4646 or ISO 639-2 language code format.
39 @param[out] DriverName A pointer to the Unicode string to return.
40 This Unicode string is the name of the
41 driver specified by This in the language
42 specified by Language.
44 @retval EFI_SUCCESS The Unicode string for the Driver specified by
45 This, and the language specified by Language was
46 returned in DriverName.
48 @retval EFI_INVALID_PARAMETER Language or DriverName is NULL.
50 @retval EFI_UNSUPPORTED The driver specified by This does not support
51 the language specified by Language.
56 TcpComponentNameGetDriverName (
57 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
59 OUT CHAR16
**DriverName
63 Retrieves a Unicode string that is the user-readable name of the controller
64 that is being managed by a driver.
66 This function retrieves the user-readable name of the controller specified by
67 ControllerHandle and ChildHandle in the form of a Unicode string. If the
68 driver specified by This has a user-readable name in the language specified by
69 Language, then a pointer to the controller name is returned in ControllerName,
70 and EFI_SUCCESS is returned. If the driver specified by This is not currently
71 managing the controller specified by ControllerHandle and ChildHandle,
72 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
73 support the language specified by Language, then EFI_UNSUPPORTED is returned.
75 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
76 EFI_COMPONENT_NAME_PROTOCOL instance.
78 @param[in] ControllerHandle The handle of a controller that the driver
79 specified by This is managing. This handle
80 specifies the controller whose name is to be
83 @param[in] ChildHandle The handle of the child controller to retrieve
84 the name of. This is an optional parameter that
85 may be NULL. It will be NULL for device
86 drivers. It will also be NULL for a bus drivers
87 that wish to retrieve the name of the bus
88 controller. It will not be NULL for a bus
89 driver that wishes to retrieve the name of a
92 @param[in] Language A pointer to a Null-terminated ASCII string
93 array indicating the language. This is the
94 language of the driver name that the caller is
95 requesting, and it must match one of the
96 languages specified in SupportedLanguages. The
97 number of languages supported by a driver is up
98 to the driver writer. Language is specified in
99 RFC 4646 or ISO 639-2 language code format.
101 @param[out] ControllerName A pointer to the Unicode string to return.
102 This Unicode string is the name of the
103 controller specified by ControllerHandle and
104 ChildHandle in the language specified by
105 Language, from the point of view of the driver
108 @retval EFI_SUCCESS The Unicode string for the user-readable name in
109 the language specified by Language for the
110 driver specified by This was returned in
113 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
115 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
118 @retval EFI_INVALID_PARAMETER Language or ControllerName is NULL.
120 @retval EFI_UNSUPPORTED The driver specified by This is not currently
121 managing the controller specified by
122 ControllerHandle and ChildHandle.
124 @retval EFI_UNSUPPORTED The driver specified by This does not support
125 the language specified by Language.
130 TcpComponentNameGetControllerName (
131 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
132 IN EFI_HANDLE ControllerHandle
,
133 IN EFI_HANDLE ChildHandle OPTIONAL
,
135 OUT CHAR16
**ControllerName
139 /// EFI Component Name Protocol
141 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gTcpComponentName
= {
142 TcpComponentNameGetDriverName
,
143 TcpComponentNameGetControllerName
,
148 /// EFI Component Name 2 Protocol
150 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gTcpComponentName2
= {
151 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) TcpComponentNameGetDriverName
,
152 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) TcpComponentNameGetControllerName
,
156 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTcpDriverNameTable
[] = {
159 L
"TCP Network Service Driver"
167 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gTcpControllerNameTable
= NULL
;
170 Retrieves a Unicode string that is the user-readable name of the driver.
172 This function retrieves the user-readable name of a driver in the form of a
173 Unicode string. If the driver specified by This has a user-readable name in
174 the language specified by Language, then a pointer to the driver name is
175 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
176 by This does not support the language specified by Language,
177 then EFI_UNSUPPORTED is returned.
179 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
180 EFI_COMPONENT_NAME_PROTOCOL instance.
182 @param[in] Language A pointer to a Null-terminated ASCII string
183 array indicating the language. This is the
184 language of the driver name that the caller is
185 requesting, and it must match one of the
186 languages specified in SupportedLanguages. The
187 number of languages supported by a driver is up
188 to the driver writer. Language is specified
189 in RFC 4646 or ISO 639-2 language code format.
191 @param[out] DriverName A pointer to the Unicode string to return.
192 This Unicode string is the name of the
193 driver specified by This in the language
194 specified by Language.
196 @retval EFI_SUCCESS The Unicode string for the Driver specified by
197 This, and the language specified by Language was
198 returned in DriverName.
200 @retval EFI_INVALID_PARAMETER Language or DriverName is NULL.
202 @retval EFI_UNSUPPORTED The driver specified by This does not support
203 the language specified by Language.
208 TcpComponentNameGetDriverName (
209 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
211 OUT CHAR16
**DriverName
214 return LookupUnicodeString2 (
216 This
->SupportedLanguages
,
219 (BOOLEAN
) (This
== &gTcpComponentName
)
224 Update the component name for the Tcp4 child handle.
226 @param Tcp4[in] A pointer to the EFI_TCP4_PROTOCOL.
229 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
230 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
235 IN EFI_TCP4_PROTOCOL
*Tcp4
239 CHAR16 HandleName
[80];
240 EFI_TCP4_CONFIG_DATA Tcp4ConfigData
;
243 return EFI_INVALID_PARAMETER
;
247 // Format the child name into the string buffer as:
248 // TCPv4 (SrcPort=59, DestPort=60, ActiveFlag=TRUE)
250 ZeroMem (&Tcp4ConfigData
, sizeof (Tcp4ConfigData
));
251 Status
= Tcp4
->GetModeData (Tcp4
, NULL
, &Tcp4ConfigData
, NULL
, NULL
, NULL
);
252 if (!EFI_ERROR (Status
)) {
253 UnicodeSPrint (HandleName
, sizeof (HandleName
),
254 L
"TCPv4 (SrcPort=%d, DestPort=%d, ActiveFlag=%s)",
255 Tcp4ConfigData
.AccessPoint
.StationPort
,
256 Tcp4ConfigData
.AccessPoint
.RemotePort
,
257 (Tcp4ConfigData
.AccessPoint
.ActiveFlag
? L
"TRUE" : L
"FALSE")
259 } else if (Status
== EFI_NOT_STARTED
) {
263 L
"TCPv4 (Not started)"
269 if (gTcpControllerNameTable
!= NULL
) {
270 FreeUnicodeStringTable (gTcpControllerNameTable
);
271 gTcpControllerNameTable
= NULL
;
274 Status
= AddUnicodeString2 (
276 gTcpComponentName
.SupportedLanguages
,
277 &gTcpControllerNameTable
,
281 if (EFI_ERROR (Status
)) {
285 return AddUnicodeString2 (
287 gTcpComponentName2
.SupportedLanguages
,
288 &gTcpControllerNameTable
,
295 Update the component name for the Tcp6 child handle.
297 @param Tcp6[in] A pointer to the EFI_TCP6_PROTOCOL.
300 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
301 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
306 IN EFI_TCP6_PROTOCOL
*Tcp6
310 CHAR16 HandleName
[80];
311 EFI_TCP6_CONFIG_DATA Tcp6ConfigData
;
314 return EFI_INVALID_PARAMETER
;
318 // Format the child name into the string buffer.
320 ZeroMem (&Tcp6ConfigData
, sizeof (Tcp6ConfigData
));
321 Status
= Tcp6
->GetModeData (Tcp6
, NULL
, &Tcp6ConfigData
, NULL
, NULL
, NULL
);
322 if (!EFI_ERROR (Status
)) {
323 UnicodeSPrint (HandleName
, sizeof (HandleName
),
324 L
"TCPv6(SrcPort=%d, DestPort=%d, ActiveFlag=%d)",
325 Tcp6ConfigData
.AccessPoint
.StationPort
,
326 Tcp6ConfigData
.AccessPoint
.RemotePort
,
327 Tcp6ConfigData
.AccessPoint
.ActiveFlag
329 } else if (Status
== EFI_NOT_STARTED
) {
330 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"TCPv6(Not started)");
336 if (gTcpControllerNameTable
!= NULL
) {
337 FreeUnicodeStringTable (gTcpControllerNameTable
);
338 gTcpControllerNameTable
= NULL
;
341 Status
= AddUnicodeString2 (
343 gTcpComponentName
.SupportedLanguages
,
344 &gTcpControllerNameTable
,
348 if (EFI_ERROR (Status
)) {
352 return AddUnicodeString2 (
354 gTcpComponentName2
.SupportedLanguages
,
355 &gTcpControllerNameTable
,
362 Retrieves a Unicode string that is the user-readable name of the controller
363 that is being managed by a driver.
365 This function retrieves the user-readable name of the controller specified by
366 ControllerHandle and ChildHandle in the form of a Unicode string. If the
367 driver specified by This has a user-readable name in the language specified by
368 Language, then a pointer to the controller name is returned in ControllerName,
369 and EFI_SUCCESS is returned. If the driver specified by This is not currently
370 managing the controller specified by ControllerHandle and ChildHandle,
371 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
372 support the language specified by Language, then EFI_UNSUPPORTED is returned.
374 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
375 EFI_COMPONENT_NAME_PROTOCOL instance.
377 @param[in] ControllerHandle The handle of a controller that the driver
378 specified by This is managing. This handle
379 specifies the controller whose name is to be
382 @param[in] ChildHandle The handle of the child controller to retrieve
383 the name of. This is an optional parameter that
384 may be NULL. It will be NULL for device
385 drivers. It will also be NULL for a bus drivers
386 that wish to retrieve the name of the bus
387 controller. It will not be NULL for a bus
388 driver that wishes to retrieve the name of a
391 @param[in] Language A pointer to a Null-terminated ASCII string
392 array indicating the language. This is the
393 language of the driver name that the caller is
394 requesting, and it must match one of the
395 languages specified in SupportedLanguages. The
396 number of languages supported by a driver is up
397 to the driver writer. Language is specified in
398 RFC 4646 or ISO 639-2 language code format.
400 @param[out] ControllerName A pointer to the Unicode string to return.
401 This Unicode string is the name of the
402 controller specified by ControllerHandle and
403 ChildHandle in the language specified by
404 Language, from the point of view of the driver
407 @retval EFI_SUCCESS The Unicode string for the user-readable name in
408 the language specified by Language for the
409 driver specified by This was returned in
412 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
414 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
417 @retval EFI_INVALID_PARAMETER Language or ControllerName is NULL.
419 @retval EFI_UNSUPPORTED The driver specified by This is not currently
420 managing the controller specified by
421 ControllerHandle and ChildHandle.
423 @retval EFI_UNSUPPORTED The driver specified by This does not support
424 the language specified by Language.
429 TcpComponentNameGetControllerName (
430 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
431 IN EFI_HANDLE ControllerHandle
,
432 IN EFI_HANDLE ChildHandle OPTIONAL
,
434 OUT CHAR16
**ControllerName
438 EFI_TCP4_PROTOCOL
*Tcp4
;
439 EFI_TCP6_PROTOCOL
*Tcp6
;
442 // Only provide names for child handles.
444 if (ChildHandle
== NULL
) {
445 return EFI_UNSUPPORTED
;
449 // Make sure this driver produced ChildHandle
451 Status
= EfiTestChildHandle (
456 if (!EFI_ERROR (Status
)) {
458 // Retrieve an instance of a produced protocol from ChildHandle
460 Status
= gBS
->OpenProtocol (
462 &gEfiTcp6ProtocolGuid
,
466 EFI_OPEN_PROTOCOL_GET_PROTOCOL
468 if (EFI_ERROR (Status
)) {
473 // Update the component name for this child handle.
475 Status
= UpdateTcp6Name (Tcp6
);
476 if (EFI_ERROR (Status
)) {
482 // Make sure this driver is currently managing ControllHandle
484 Status
= EfiTestChildHandle (
489 if (!EFI_ERROR (Status
)) {
491 // Retrieve an instance of a produced protocol from ChildHandle
493 Status
= gBS
->OpenProtocol (
495 &gEfiTcp4ProtocolGuid
,
499 EFI_OPEN_PROTOCOL_GET_PROTOCOL
501 if (EFI_ERROR (Status
)) {
506 // Update the component name for this child handle.
508 Status
= UpdateTcp4Name (Tcp4
);
509 if (EFI_ERROR (Status
)) {
514 return LookupUnicodeString2 (
516 This
->SupportedLanguages
,
517 gTcpControllerNameTable
,
519 (BOOLEAN
)(This
== &gTcpComponentName
)