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
17 Retrieves a Unicode string that is the user-readable name of the driver.
19 This function retrieves the user-readable name of a driver in the form of a
20 Unicode string. If the driver specified by This has a user-readable name in
21 the language specified by Language, then a pointer to the driver name is
22 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
23 by This does not support the language specified by Language,
24 then EFI_UNSUPPORTED is returned.
26 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
27 EFI_COMPONENT_NAME_PROTOCOL instance.
29 @param[in] Language A pointer to a Null-terminated ASCII string
30 array indicating the language. This is the
31 language of the driver name that the caller is
32 requesting, and it must match one of the
33 languages specified in SupportedLanguages. The
34 number of languages supported by a driver is up
35 to the driver writer. Language is specified
36 in RFC 4646 or ISO 639-2 language code format.
38 @param[out] DriverName A pointer to the Unicode string to return.
39 This Unicode string is the name of the
40 driver specified by This in the language
41 specified by Language.
43 @retval EFI_SUCCESS The Unicode string for the Driver specified by
44 This and the language specified by Language was
45 returned in DriverName.
47 @retval EFI_INVALID_PARAMETER Language is NULL.
49 @retval EFI_INVALID_PARAMETER DriverName is NULL.
51 @retval EFI_UNSUPPORTED The driver specified by This does not support
52 the language specified by Language.
57 Udp6ComponentNameGetDriverName (
58 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
60 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
,
159 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUdp6DriverNameTable
[] = {
162 L
"UDP6 Network Service Driver"
170 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gUdp6ControllerNameTable
= NULL
;
173 Retrieves a Unicode string that is the user-readable name of the driver.
175 This function retrieves the user-readable name of a driver in the form of a
176 Unicode string. If the driver specified by This has a user-readable name in
177 the language specified by Language, then a pointer to the driver name is
178 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
179 by This does not support the language specified by Language,
180 then EFI_UNSUPPORTED is returned.
182 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
183 EFI_COMPONENT_NAME_PROTOCOL instance.
185 @param[in] Language A pointer to a Null-terminated ASCII string
186 array indicating the language. This is the
187 language of the driver name that the caller is
188 requesting, and it must match one of the
189 languages specified in SupportedLanguages. The
190 number of languages supported by a driver is up
191 to the driver writer. Language is specified
192 in RFC 4646 or ISO 639-2 language code format.
194 @param[out] DriverName A pointer to the Unicode string to return.
195 This Unicode string is the name of the
196 driver specified by This in the language
197 specified by Language.
199 @retval EFI_SUCCESS The Unicode string for the Driver specified by
200 This and the language specified by Language was
201 returned in DriverName.
203 @retval EFI_INVALID_PARAMETER Language is NULL.
205 @retval EFI_INVALID_PARAMETER DriverName is NULL.
207 @retval EFI_UNSUPPORTED The driver specified by This does not support
208 the language specified by Language.
213 Udp6ComponentNameGetDriverName (
214 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
216 OUT CHAR16
**DriverName
219 return LookupUnicodeString2 (
221 This
->SupportedLanguages
,
222 mUdp6DriverNameTable
,
224 (BOOLEAN
)(This
== &gUdp6ComponentName
)
229 Update the component name for the Udp6 child handle.
231 @param Udp6[in] A pointer to the EFI_UDP6_PROTOCOL.
234 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
235 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
240 IN EFI_UDP6_PROTOCOL
*Udp6
244 CHAR16 HandleName
[64];
245 EFI_UDP6_CONFIG_DATA Udp6ConfigData
;
248 return EFI_INVALID_PARAMETER
;
252 // Format the child name into the string buffer.
254 Status
= Udp6
->GetModeData (Udp6
, &Udp6ConfigData
, NULL
, NULL
, NULL
);
255 if (!EFI_ERROR (Status
)) {
259 L
"UDPv6 (SrcPort=%d, DestPort=%d)",
260 Udp6ConfigData
.StationPort
,
261 Udp6ConfigData
.RemotePort
263 } else if (Status
== EFI_NOT_STARTED
) {
264 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"UDPv6 (Not started)");
266 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"UDPv6 (%r)", Status
);
269 if (gUdp6ControllerNameTable
!= NULL
) {
270 FreeUnicodeStringTable (gUdp6ControllerNameTable
);
271 gUdp6ControllerNameTable
= NULL
;
274 Status
= AddUnicodeString2 (
276 gUdp6ComponentName
.SupportedLanguages
,
277 &gUdp6ControllerNameTable
,
281 if (EFI_ERROR (Status
)) {
285 return AddUnicodeString2 (
287 gUdp6ComponentName2
.SupportedLanguages
,
288 &gUdp6ControllerNameTable
,
295 Retrieves a Unicode string that is the user-readable name of the controller
296 that is being managed by a driver.
298 This function retrieves the user-readable name of the controller specified by
299 ControllerHandle and ChildHandle in the form of a Unicode string. If the
300 driver specified by This has a user-readable name in the language specified by
301 Language, then a pointer to the controller name is returned in ControllerName,
302 and EFI_SUCCESS is returned. If the driver specified by This is not currently
303 managing the controller specified by ControllerHandle and ChildHandle,
304 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
305 support the language specified by Language, then EFI_UNSUPPORTED is returned.
307 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
308 EFI_COMPONENT_NAME_PROTOCOL instance.
310 @param[in] ControllerHandle The handle of a controller that the driver
311 specified by This is managing. This handle
312 specifies the controller whose name is to be
315 @param[in] ChildHandle The handle of the child controller to retrieve
316 the name of. This is an optional parameter that
317 may be NULL. It will be NULL for device
318 drivers. It will also be NULL for a bus drivers
319 that wish to retrieve the name of the bus
320 controller. It will not be NULL for a bus
321 driver that wishes to retrieve the name of a
324 @param[in] Language A pointer to a Null-terminated ASCII string
325 array indicating the language. This is the
326 language of the driver name that the caller is
327 requesting, and it must match one of the
328 languages specified in SupportedLanguages. The
329 number of languages supported by a driver is up
330 to the driver writer. Language is specified in
331 RFC 4646 or ISO 639-2 language code format.
333 @param[out] ControllerName A pointer to the Unicode string to return.
334 This Unicode string is the name of the
335 controller specified by ControllerHandle and
336 ChildHandle in the language specified by
337 Language from the point of view of the driver
340 @retval EFI_SUCCESS The Unicode string for the user-readable name in
341 the language specified by Language for the
342 driver specified by This was returned in
345 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
347 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
350 @retval EFI_INVALID_PARAMETER Language is NULL.
352 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
354 @retval EFI_UNSUPPORTED The driver specified by This is not currently
355 managing the controller specified by
356 ControllerHandle and ChildHandle.
358 @retval EFI_UNSUPPORTED The driver specified by This does not support
359 the language specified by Language.
364 Udp6ComponentNameGetControllerName (
365 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
366 IN EFI_HANDLE ControllerHandle
,
367 IN EFI_HANDLE ChildHandle OPTIONAL
,
369 OUT CHAR16
**ControllerName
373 EFI_UDP6_PROTOCOL
*Udp6
;
376 // Only provide names for child handles.
378 if (ChildHandle
== NULL
) {
379 return EFI_UNSUPPORTED
;
383 // Make sure this driver produced ChildHandle
385 Status
= EfiTestChildHandle (
390 if (EFI_ERROR (Status
)) {
395 // Retrieve an instance of a produced protocol from ChildHandle
397 Status
= gBS
->OpenProtocol (
399 &gEfiUdp6ProtocolGuid
,
403 EFI_OPEN_PROTOCOL_GET_PROTOCOL
405 if (EFI_ERROR (Status
)) {
410 // Update the component name for this child handle.
412 Status
= UpdateName (Udp6
);
413 if (EFI_ERROR (Status
)) {
417 return LookupUnicodeString2 (
419 This
->SupportedLanguages
,
420 gUdp6ControllerNameTable
,
422 (BOOLEAN
)(This
== &gUdp6ComponentName
)