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
)) {
256 L
"TCPv4 (SrcPort=%d, DestPort=%d, ActiveFlag=%s)",
257 Tcp4ConfigData
.AccessPoint
.StationPort
,
258 Tcp4ConfigData
.AccessPoint
.RemotePort
,
259 (Tcp4ConfigData
.AccessPoint
.ActiveFlag
? L
"TRUE" : L
"FALSE")
261 } else if (Status
== EFI_NOT_STARTED
) {
265 L
"TCPv4 (Not started)"
271 if (gTcpControllerNameTable
!= NULL
) {
272 FreeUnicodeStringTable (gTcpControllerNameTable
);
273 gTcpControllerNameTable
= NULL
;
276 Status
= AddUnicodeString2 (
278 gTcpComponentName
.SupportedLanguages
,
279 &gTcpControllerNameTable
,
283 if (EFI_ERROR (Status
)) {
287 return AddUnicodeString2 (
289 gTcpComponentName2
.SupportedLanguages
,
290 &gTcpControllerNameTable
,
297 Update the component name for the Tcp6 child handle.
299 @param Tcp6[in] A pointer to the EFI_TCP6_PROTOCOL.
302 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
303 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
308 IN EFI_TCP6_PROTOCOL
*Tcp6
312 CHAR16 HandleName
[80];
313 EFI_TCP6_CONFIG_DATA Tcp6ConfigData
;
316 return EFI_INVALID_PARAMETER
;
320 // Format the child name into the string buffer.
322 ZeroMem (&Tcp6ConfigData
, sizeof (Tcp6ConfigData
));
323 Status
= Tcp6
->GetModeData (Tcp6
, NULL
, &Tcp6ConfigData
, NULL
, NULL
, NULL
);
324 if (!EFI_ERROR (Status
)) {
328 L
"TCPv6(SrcPort=%d, DestPort=%d, ActiveFlag=%d)",
329 Tcp6ConfigData
.AccessPoint
.StationPort
,
330 Tcp6ConfigData
.AccessPoint
.RemotePort
,
331 Tcp6ConfigData
.AccessPoint
.ActiveFlag
333 } else if (Status
== EFI_NOT_STARTED
) {
334 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"TCPv6(Not started)");
339 if (gTcpControllerNameTable
!= NULL
) {
340 FreeUnicodeStringTable (gTcpControllerNameTable
);
341 gTcpControllerNameTable
= NULL
;
344 Status
= AddUnicodeString2 (
346 gTcpComponentName
.SupportedLanguages
,
347 &gTcpControllerNameTable
,
351 if (EFI_ERROR (Status
)) {
355 return AddUnicodeString2 (
357 gTcpComponentName2
.SupportedLanguages
,
358 &gTcpControllerNameTable
,
365 Retrieves a Unicode string that is the user-readable name of the controller
366 that is being managed by a driver.
368 This function retrieves the user-readable name of the controller specified by
369 ControllerHandle and ChildHandle in the form of a Unicode string. If the
370 driver specified by This has a user-readable name in the language specified by
371 Language, then a pointer to the controller name is returned in ControllerName,
372 and EFI_SUCCESS is returned. If the driver specified by This is not currently
373 managing the controller specified by ControllerHandle and ChildHandle,
374 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
375 support the language specified by Language, then EFI_UNSUPPORTED is returned.
377 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
378 EFI_COMPONENT_NAME_PROTOCOL instance.
380 @param[in] ControllerHandle The handle of a controller that the driver
381 specified by This is managing. This handle
382 specifies the controller whose name is to be
385 @param[in] ChildHandle The handle of the child controller to retrieve
386 the name of. This is an optional parameter that
387 may be NULL. It will be NULL for device
388 drivers. It will also be NULL for a bus drivers
389 that wish to retrieve the name of the bus
390 controller. It will not be NULL for a bus
391 driver that wishes to retrieve the name of a
394 @param[in] Language A pointer to a Null-terminated ASCII string
395 array indicating the language. This is the
396 language of the driver name that the caller is
397 requesting, and it must match one of the
398 languages specified in SupportedLanguages. The
399 number of languages supported by a driver is up
400 to the driver writer. Language is specified in
401 RFC 4646 or ISO 639-2 language code format.
403 @param[out] ControllerName A pointer to the Unicode string to return.
404 This Unicode string is the name of the
405 controller specified by ControllerHandle and
406 ChildHandle in the language specified by
407 Language, from the point of view of the driver
410 @retval EFI_SUCCESS The Unicode string for the user-readable name in
411 the language specified by Language for the
412 driver specified by This was returned in
415 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
417 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
420 @retval EFI_INVALID_PARAMETER Language or ControllerName is NULL.
422 @retval EFI_UNSUPPORTED The driver specified by This is not currently
423 managing the controller specified by
424 ControllerHandle and ChildHandle.
426 @retval EFI_UNSUPPORTED The driver specified by This does not support
427 the language specified by Language.
432 TcpComponentNameGetControllerName (
433 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
434 IN EFI_HANDLE ControllerHandle
,
435 IN EFI_HANDLE ChildHandle OPTIONAL
,
437 OUT CHAR16
**ControllerName
441 EFI_TCP4_PROTOCOL
*Tcp4
;
442 EFI_TCP6_PROTOCOL
*Tcp6
;
445 // Only provide names for child handles.
447 if (ChildHandle
== NULL
) {
448 return EFI_UNSUPPORTED
;
452 // Make sure this driver produced ChildHandle
454 Status
= EfiTestChildHandle (
459 if (!EFI_ERROR (Status
)) {
461 // Retrieve an instance of a produced protocol from ChildHandle
463 Status
= gBS
->OpenProtocol (
465 &gEfiTcp6ProtocolGuid
,
469 EFI_OPEN_PROTOCOL_GET_PROTOCOL
471 if (EFI_ERROR (Status
)) {
476 // Update the component name for this child handle.
478 Status
= UpdateTcp6Name (Tcp6
);
479 if (EFI_ERROR (Status
)) {
485 // Make sure this driver is currently managing ControllHandle
487 Status
= EfiTestChildHandle (
492 if (!EFI_ERROR (Status
)) {
494 // Retrieve an instance of a produced protocol from ChildHandle
496 Status
= gBS
->OpenProtocol (
498 &gEfiTcp4ProtocolGuid
,
502 EFI_OPEN_PROTOCOL_GET_PROTOCOL
504 if (EFI_ERROR (Status
)) {
509 // Update the component name for this child handle.
511 Status
= UpdateTcp4Name (Tcp4
);
512 if (EFI_ERROR (Status
)) {
517 return LookupUnicodeString2 (
519 This
->SupportedLanguages
,
520 gTcpControllerNameTable
,
522 (BOOLEAN
)(This
== &gTcpComponentName
)