2 UEFI Component Name(2) protocol implementation for UDP6 driver.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 // EFI Component Name Functions
16 Retrieves a Unicode string that is the user-readable name of the driver.
18 This function retrieves the user-readable name of a driver in the form of a
19 Unicode string. If the driver specified by This has a user-readable name in
20 the language specified by Language, then a pointer to the driver name is
21 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
22 by This does not support the language specified by Language,
23 then EFI_UNSUPPORTED is returned.
25 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
26 EFI_COMPONENT_NAME_PROTOCOL instance.
28 @param[in] Language A pointer to a Null-terminated ASCII string
29 array indicating the language. This is the
30 language of the driver name that the caller is
31 requesting, and it must match one of the
32 languages specified in SupportedLanguages. The
33 number of languages supported by a driver is up
34 to the driver writer. Language is specified
35 in RFC 4646 or ISO 639-2 language code format.
37 @param[out] DriverName A pointer to the Unicode string to return.
38 This Unicode string is the name of the
39 driver specified by This in the language
40 specified by Language.
42 @retval EFI_SUCCESS The Unicode string for the Driver specified by
43 This and the language specified by Language was
44 returned in DriverName.
46 @retval EFI_INVALID_PARAMETER Language is NULL.
48 @retval EFI_INVALID_PARAMETER DriverName is NULL.
50 @retval EFI_UNSUPPORTED The driver specified by This does not support
51 the language specified by Language.
56 Udp6ComponentNameGetDriverName (
57 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
59 OUT CHAR16
**DriverName
64 Retrieves a Unicode string that is the user-readable name of the controller
65 that is being managed by a driver.
67 This function retrieves the user-readable name of the controller specified by
68 ControllerHandle and ChildHandle in the form of a Unicode string. If the
69 driver specified by This has a user-readable name in the language specified by
70 Language, then a pointer to the controller name is returned in ControllerName,
71 and EFI_SUCCESS is returned. If the driver specified by This is not currently
72 managing the controller specified by ControllerHandle and ChildHandle,
73 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
74 support the language specified by Language, then EFI_UNSUPPORTED is returned.
76 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
77 EFI_COMPONENT_NAME_PROTOCOL instance.
79 @param[in] ControllerHandle The handle of a controller that the driver
80 specified by This is managing. This handle
81 specifies the controller whose name is to be
84 @param[in] ChildHandle The handle of the child controller to retrieve
85 the name of. This is an optional parameter that
86 may be NULL. It will be NULL for device
87 drivers. It will also be NULL for a bus drivers
88 that wish to retrieve the name of the bus
89 controller. It will not be NULL for a bus
90 driver that wishes to retrieve the name of a
93 @param[in] Language A pointer to a Null-terminated ASCII string
94 array indicating the language. This is the
95 language of the driver name that the caller is
96 requesting, and it must match one of the
97 languages specified in SupportedLanguages. The
98 number of languages supported by a driver is up
99 to the driver writer. Language is specified in
100 RFC 4646 or ISO 639-2 language code format.
102 @param[out] ControllerName A pointer to the Unicode string to return.
103 This Unicode string is the name of the
104 controller specified by ControllerHandle and
105 ChildHandle in the language specified by
106 Language from the point of view of the driver
109 @retval EFI_SUCCESS The Unicode string for the user-readable name in
110 the language specified by Language for the
111 driver specified by This was returned in
114 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
116 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
119 @retval EFI_INVALID_PARAMETER Language is NULL.
121 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
123 @retval EFI_UNSUPPORTED The driver specified by This is not currently
124 managing the controller specified by
125 ControllerHandle and ChildHandle.
127 @retval EFI_UNSUPPORTED The driver specified by This does not support
128 the language specified by Language.
133 Udp6ComponentNameGetControllerName (
134 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
135 IN EFI_HANDLE ControllerHandle
,
136 IN EFI_HANDLE ChildHandle OPTIONAL
,
138 OUT CHAR16
**ControllerName
142 // EFI Component Name Protocol
144 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUdp6ComponentName
= {
145 Udp6ComponentNameGetDriverName
,
146 Udp6ComponentNameGetControllerName
,
151 // EFI Component Name 2 Protocol
153 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUdp6ComponentName2
= {
154 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Udp6ComponentNameGetDriverName
,
155 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Udp6ComponentNameGetControllerName
,
160 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUdp6DriverNameTable
[] = {
163 L
"UDP6 Network Service Driver"
171 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gUdp6ControllerNameTable
= NULL
;
174 Retrieves a Unicode string that is the user-readable name of the driver.
176 This function retrieves the user-readable name of a driver in the form of a
177 Unicode string. If the driver specified by This has a user-readable name in
178 the language specified by Language, then a pointer to the driver name is
179 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
180 by This does not support the language specified by Language,
181 then EFI_UNSUPPORTED is returned.
183 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
184 EFI_COMPONENT_NAME_PROTOCOL instance.
186 @param[in] Language A pointer to a Null-terminated ASCII string
187 array indicating the language. This is the
188 language of the driver name that the caller is
189 requesting, and it must match one of the
190 languages specified in SupportedLanguages. The
191 number of languages supported by a driver is up
192 to the driver writer. Language is specified
193 in RFC 4646 or ISO 639-2 language code format.
195 @param[out] DriverName A pointer to the Unicode string to return.
196 This Unicode string is the name of the
197 driver specified by This in the language
198 specified by Language.
200 @retval EFI_SUCCESS The Unicode string for the Driver specified by
201 This and the language specified by Language was
202 returned in DriverName.
204 @retval EFI_INVALID_PARAMETER Language is NULL.
206 @retval EFI_INVALID_PARAMETER DriverName is NULL.
208 @retval EFI_UNSUPPORTED The driver specified by This does not support
209 the language specified by Language.
214 Udp6ComponentNameGetDriverName (
215 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
217 OUT CHAR16
**DriverName
220 return LookupUnicodeString2 (
222 This
->SupportedLanguages
,
223 mUdp6DriverNameTable
,
225 (BOOLEAN
) (This
== &gUdp6ComponentName
)
230 Update the component name for the Udp6 child handle.
232 @param Udp6[in] A pointer to the EFI_UDP6_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_UDP6_PROTOCOL
*Udp6
245 CHAR16 HandleName
[64];
246 EFI_UDP6_CONFIG_DATA Udp6ConfigData
;
249 return EFI_INVALID_PARAMETER
;
253 // Format the child name into the string buffer.
255 Status
= Udp6
->GetModeData (Udp6
, &Udp6ConfigData
, NULL
, NULL
, NULL
);
256 if (!EFI_ERROR (Status
)) {
257 UnicodeSPrint (HandleName
, sizeof (HandleName
),
258 L
"UDPv6 (SrcPort=%d, DestPort=%d)",
259 Udp6ConfigData
.StationPort
,
260 Udp6ConfigData
.RemotePort
262 } else if (Status
== EFI_NOT_STARTED
) {
263 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"UDPv6 (Not started)");
265 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"UDPv6 (%r)", Status
);
268 if (gUdp6ControllerNameTable
!= NULL
) {
269 FreeUnicodeStringTable (gUdp6ControllerNameTable
);
270 gUdp6ControllerNameTable
= NULL
;
273 Status
= AddUnicodeString2 (
275 gUdp6ComponentName
.SupportedLanguages
,
276 &gUdp6ControllerNameTable
,
280 if (EFI_ERROR (Status
)) {
284 return AddUnicodeString2 (
286 gUdp6ComponentName2
.SupportedLanguages
,
287 &gUdp6ControllerNameTable
,
294 Retrieves a Unicode string that is the user-readable name of the controller
295 that is being managed by a driver.
297 This function retrieves the user-readable name of the controller specified by
298 ControllerHandle and ChildHandle in the form of a Unicode string. If the
299 driver specified by This has a user-readable name in the language specified by
300 Language, then a pointer to the controller name is returned in ControllerName,
301 and EFI_SUCCESS is returned. If the driver specified by This is not currently
302 managing the controller specified by ControllerHandle and ChildHandle,
303 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
304 support the language specified by Language, then EFI_UNSUPPORTED is returned.
306 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
307 EFI_COMPONENT_NAME_PROTOCOL instance.
309 @param[in] ControllerHandle The handle of a controller that the driver
310 specified by This is managing. This handle
311 specifies the controller whose name is to be
314 @param[in] ChildHandle The handle of the child controller to retrieve
315 the name of. This is an optional parameter that
316 may be NULL. It will be NULL for device
317 drivers. It will also be NULL for a bus drivers
318 that wish to retrieve the name of the bus
319 controller. It will not be NULL for a bus
320 driver that wishes to retrieve the name of a
323 @param[in] Language A pointer to a Null-terminated ASCII string
324 array indicating the language. This is the
325 language of the driver name that the caller is
326 requesting, and it must match one of the
327 languages specified in SupportedLanguages. The
328 number of languages supported by a driver is up
329 to the driver writer. Language is specified in
330 RFC 4646 or ISO 639-2 language code format.
332 @param[out] ControllerName A pointer to the Unicode string to return.
333 This Unicode string is the name of the
334 controller specified by ControllerHandle and
335 ChildHandle in the language specified by
336 Language from the point of view of the driver
339 @retval EFI_SUCCESS The Unicode string for the user-readable name in
340 the language specified by Language for the
341 driver specified by This was returned in
344 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
346 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
349 @retval EFI_INVALID_PARAMETER Language is NULL.
351 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
353 @retval EFI_UNSUPPORTED The driver specified by This is not currently
354 managing the controller specified by
355 ControllerHandle and ChildHandle.
357 @retval EFI_UNSUPPORTED The driver specified by This does not support
358 the language specified by Language.
363 Udp6ComponentNameGetControllerName (
364 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
365 IN EFI_HANDLE ControllerHandle
,
366 IN EFI_HANDLE ChildHandle OPTIONAL
,
368 OUT CHAR16
**ControllerName
372 EFI_UDP6_PROTOCOL
*Udp6
;
375 // Only provide names for child handles.
377 if (ChildHandle
== NULL
) {
378 return EFI_UNSUPPORTED
;
382 // Make sure this driver produced ChildHandle
384 Status
= EfiTestChildHandle (
389 if (EFI_ERROR (Status
)) {
394 // Retrieve an instance of a produced protocol from ChildHandle
396 Status
= gBS
->OpenProtocol (
398 &gEfiUdp6ProtocolGuid
,
402 EFI_OPEN_PROTOCOL_GET_PROTOCOL
404 if (EFI_ERROR (Status
)) {
409 // Update the component name for this child handle.
411 Status
= UpdateName (Udp6
);
412 if (EFI_ERROR (Status
)) {
416 return LookupUnicodeString2 (
418 This
->SupportedLanguages
,
419 gUdp6ControllerNameTable
,
421 (BOOLEAN
)(This
== &gUdp6ComponentName
)