2 Implementation of protocols EFI_COMPONENT_NAME_PROTOCOL and
3 EFI_COMPONENT_NAME2_PROTOCOL.
5 Copyright (c) 2009 - 2013, 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 Status
= Tcp4
->GetModeData (Tcp4
, NULL
, &Tcp4ConfigData
, NULL
, NULL
, NULL
);
257 if (!EFI_ERROR (Status
)) {
258 UnicodeSPrint (HandleName
, sizeof (HandleName
),
259 L
"TCPv4 (SrcPort=%d, DestPort=%d, ActiveFlag=%s)",
260 Tcp4ConfigData
.AccessPoint
.StationPort
,
261 Tcp4ConfigData
.AccessPoint
.RemotePort
,
262 (Tcp4ConfigData
.AccessPoint
.ActiveFlag
? L
"TRUE" : L
"FALSE")
264 } if (Status
== EFI_NOT_STARTED
) {
268 L
"TCPv4 (Not started)"
274 if (gTcpControllerNameTable
!= NULL
) {
275 FreeUnicodeStringTable (gTcpControllerNameTable
);
276 gTcpControllerNameTable
= NULL
;
279 Status
= AddUnicodeString2 (
281 gTcpComponentName
.SupportedLanguages
,
282 &gTcpControllerNameTable
,
286 if (EFI_ERROR (Status
)) {
290 return AddUnicodeString2 (
292 gTcpComponentName2
.SupportedLanguages
,
293 &gTcpControllerNameTable
,
300 Update the component name for the Tcp6 child handle.
302 @param Tcp6[in] A pointer to the EFI_TCP6_PROTOCOL.
305 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
306 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
311 IN EFI_TCP6_PROTOCOL
*Tcp6
315 CHAR16 HandleName
[80];
316 EFI_TCP6_CONFIG_DATA Tcp6ConfigData
;
319 return EFI_INVALID_PARAMETER
;
323 // Format the child name into the string buffer.
325 Status
= Tcp6
->GetModeData (Tcp6
, NULL
, &Tcp6ConfigData
, NULL
, NULL
, NULL
);
326 if (!EFI_ERROR (Status
)) {
327 UnicodeSPrint (HandleName
, sizeof (HandleName
),
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)");
340 if (gTcpControllerNameTable
!= NULL
) {
341 FreeUnicodeStringTable (gTcpControllerNameTable
);
342 gTcpControllerNameTable
= NULL
;
345 Status
= AddUnicodeString2 (
347 gTcpComponentName
.SupportedLanguages
,
348 &gTcpControllerNameTable
,
352 if (EFI_ERROR (Status
)) {
356 return AddUnicodeString2 (
358 gTcpComponentName2
.SupportedLanguages
,
359 &gTcpControllerNameTable
,
366 Retrieves a Unicode string that is the user-readable name of the controller
367 that is being managed by a driver.
369 This function retrieves the user-readable name of the controller specified by
370 ControllerHandle and ChildHandle in the form of a Unicode string. If the
371 driver specified by This has a user-readable name in the language specified by
372 Language, then a pointer to the controller name is returned in ControllerName,
373 and EFI_SUCCESS is returned. If the driver specified by This is not currently
374 managing the controller specified by ControllerHandle and ChildHandle,
375 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
376 support the language specified by Language, then EFI_UNSUPPORTED is returned.
378 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
379 EFI_COMPONENT_NAME_PROTOCOL instance.
381 @param[in] ControllerHandle The handle of a controller that the driver
382 specified by This is managing. This handle
383 specifies the controller whose name is to be
386 @param[in] ChildHandle The handle of the child controller to retrieve
387 the name of. This is an optional parameter that
388 may be NULL. It will be NULL for device
389 drivers. It will also be NULL for a bus drivers
390 that wish to retrieve the name of the bus
391 controller. It will not be NULL for a bus
392 driver that wishes to retrieve the name of a
395 @param[in] Language A pointer to a Null-terminated ASCII string
396 array indicating the language. This is the
397 language of the driver name that the caller is
398 requesting, and it must match one of the
399 languages specified in SupportedLanguages. The
400 number of languages supported by a driver is up
401 to the driver writer. Language is specified in
402 RFC 4646 or ISO 639-2 language code format.
404 @param[out] ControllerName A pointer to the Unicode string to return.
405 This Unicode string is the name of the
406 controller specified by ControllerHandle and
407 ChildHandle in the language specified by
408 Language, from the point of view of the driver
411 @retval EFI_SUCCESS The Unicode string for the user-readable name in
412 the language specified by Language for the
413 driver specified by This was returned in
416 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
418 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
421 @retval EFI_INVALID_PARAMETER Language or ControllerName is NULL.
423 @retval EFI_UNSUPPORTED The driver specified by This is not currently
424 managing the controller specified by
425 ControllerHandle and ChildHandle.
427 @retval EFI_UNSUPPORTED The driver specified by This does not support
428 the language specified by Language.
433 TcpComponentNameGetControllerName (
434 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
435 IN EFI_HANDLE ControllerHandle
,
436 IN EFI_HANDLE ChildHandle OPTIONAL
,
438 OUT CHAR16
**ControllerName
442 EFI_TCP4_PROTOCOL
*Tcp4
;
443 EFI_TCP6_PROTOCOL
*Tcp6
;
446 // Only provide names for child handles.
448 if (ChildHandle
== NULL
) {
449 return EFI_UNSUPPORTED
;
453 // Make sure this driver produced ChildHandle
455 Status
= EfiTestChildHandle (
460 if (!EFI_ERROR (Status
)) {
462 // Retrieve an instance of a produced protocol from ChildHandle
464 Status
= gBS
->OpenProtocol (
466 &gEfiTcp6ProtocolGuid
,
470 EFI_OPEN_PROTOCOL_GET_PROTOCOL
472 if (EFI_ERROR (Status
)) {
477 // Update the component name for this child handle.
479 Status
= UpdateTcp6Name (Tcp6
);
480 if (EFI_ERROR (Status
)) {
486 // Make sure this driver is currently managing ControllHandle
488 Status
= EfiTestChildHandle (
493 if (!EFI_ERROR (Status
)) {
495 // Retrieve an instance of a produced protocol from ChildHandle
497 Status
= gBS
->OpenProtocol (
499 &gEfiTcp4ProtocolGuid
,
503 EFI_OPEN_PROTOCOL_GET_PROTOCOL
505 if (EFI_ERROR (Status
)) {
510 // Update the component name for this child handle.
512 Status
= UpdateTcp4Name (Tcp4
);
513 if (EFI_ERROR (Status
)) {
518 return LookupUnicodeString2 (
520 This
->SupportedLanguages
,
521 gTcpControllerNameTable
,
523 (BOOLEAN
)(This
== &gTcpComponentName
)