2 UEFI Component Name(2) protocol implementation for UDP6 driver.
4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 // EFI Component Name Functions
22 Retrieves a Unicode string that is the user-readable name of the driver.
24 This function retrieves the user-readable name of a driver in the form of a
25 Unicode string. If the driver specified by This has a user-readable name in
26 the language specified by Language, then a pointer to the driver name is
27 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
28 by This does not support the language specified by Language,
29 then EFI_UNSUPPORTED is returned.
31 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
32 EFI_COMPONENT_NAME_PROTOCOL instance.
34 @param[in] Language A pointer to a Null-terminated ASCII string
35 array indicating the language. This is the
36 language of the driver name that the caller is
37 requesting, and it must match one of the
38 languages specified in SupportedLanguages. The
39 number of languages supported by a driver is up
40 to the driver writer. Language is specified
41 in RFC 4646 or ISO 639-2 language code format.
43 @param[out] DriverName A pointer to the Unicode string to return.
44 This Unicode string is the name of the
45 driver specified by This in the language
46 specified by Language.
48 @retval EFI_SUCCESS The Unicode string for the Driver specified by
49 This and the language specified by Language was
50 returned in DriverName.
52 @retval EFI_INVALID_PARAMETER Language is NULL.
54 @retval EFI_INVALID_PARAMETER DriverName is NULL.
56 @retval EFI_UNSUPPORTED The driver specified by This does not support
57 the language specified by Language.
62 Udp6ComponentNameGetDriverName (
63 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
65 OUT CHAR16
**DriverName
70 Retrieves a Unicode string that is the user-readable name of the controller
71 that is being managed by a driver.
73 This function retrieves the user-readable name of the controller specified by
74 ControllerHandle and ChildHandle in the form of a Unicode string. If the
75 driver specified by This has a user-readable name in the language specified by
76 Language, then a pointer to the controller name is returned in ControllerName,
77 and EFI_SUCCESS is returned. If the driver specified by This is not currently
78 managing the controller specified by ControllerHandle and ChildHandle,
79 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
80 support the language specified by Language, then EFI_UNSUPPORTED is returned.
82 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
83 EFI_COMPONENT_NAME_PROTOCOL instance.
85 @param[in] ControllerHandle The handle of a controller that the driver
86 specified by This is managing. This handle
87 specifies the controller whose name is to be
90 @param[in] ChildHandle The handle of the child controller to retrieve
91 the name of. This is an optional parameter that
92 may be NULL. It will be NULL for device
93 drivers. It will also be NULL for a bus drivers
94 that wish to retrieve the name of the bus
95 controller. It will not be NULL for a bus
96 driver that wishes to retrieve the name of a
99 @param[in] Language A pointer to a Null-terminated ASCII string
100 array indicating the language. This is the
101 language of the driver name that the caller is
102 requesting, and it must match one of the
103 languages specified in SupportedLanguages. The
104 number of languages supported by a driver is up
105 to the driver writer. Language is specified in
106 RFC 4646 or ISO 639-2 language code format.
108 @param[out] ControllerName A pointer to the Unicode string to return.
109 This Unicode string is the name of the
110 controller specified by ControllerHandle and
111 ChildHandle in the language specified by
112 Language from the point of view of the driver
115 @retval EFI_SUCCESS The Unicode string for the user-readable name in
116 the language specified by Language for the
117 driver specified by This was returned in
120 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
122 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
125 @retval EFI_INVALID_PARAMETER Language is NULL.
127 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
129 @retval EFI_UNSUPPORTED The driver specified by This is not currently
130 managing the controller specified by
131 ControllerHandle and ChildHandle.
133 @retval EFI_UNSUPPORTED The driver specified by This does not support
134 the language specified by Language.
139 Udp6ComponentNameGetControllerName (
140 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
141 IN EFI_HANDLE ControllerHandle
,
142 IN EFI_HANDLE ChildHandle OPTIONAL
,
144 OUT CHAR16
**ControllerName
148 // EFI Component Name Protocol
150 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUdp6ComponentName
= {
151 Udp6ComponentNameGetDriverName
,
152 Udp6ComponentNameGetControllerName
,
157 // EFI Component Name 2 Protocol
159 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUdp6ComponentName2
= {
160 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) Udp6ComponentNameGetDriverName
,
161 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) Udp6ComponentNameGetControllerName
,
166 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUdp6DriverNameTable
[] = {
169 L
"UDP6 Network Service Driver"
177 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gUdp6ControllerNameTable
= NULL
;
180 Retrieves a Unicode string that is the user-readable name of the driver.
182 This function retrieves the user-readable name of a driver in the form of a
183 Unicode string. If the driver specified by This has a user-readable name in
184 the language specified by Language, then a pointer to the driver name is
185 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
186 by This does not support the language specified by Language,
187 then EFI_UNSUPPORTED is returned.
189 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
190 EFI_COMPONENT_NAME_PROTOCOL instance.
192 @param[in] Language A pointer to a Null-terminated ASCII string
193 array indicating the language. This is the
194 language of the driver name that the caller is
195 requesting, and it must match one of the
196 languages specified in SupportedLanguages. The
197 number of languages supported by a driver is up
198 to the driver writer. Language is specified
199 in RFC 4646 or ISO 639-2 language code format.
201 @param[out] DriverName A pointer to the Unicode string to return.
202 This Unicode string is the name of the
203 driver specified by This in the language
204 specified by Language.
206 @retval EFI_SUCCESS The Unicode string for the Driver specified by
207 This and the language specified by Language was
208 returned in DriverName.
210 @retval EFI_INVALID_PARAMETER Language is NULL.
212 @retval EFI_INVALID_PARAMETER DriverName is NULL.
214 @retval EFI_UNSUPPORTED The driver specified by This does not support
215 the language specified by Language.
220 Udp6ComponentNameGetDriverName (
221 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
223 OUT CHAR16
**DriverName
226 return LookupUnicodeString2 (
228 This
->SupportedLanguages
,
229 mUdp6DriverNameTable
,
231 (BOOLEAN
) (This
== &gUdp6ComponentName
)
236 Update the component name for the Udp6 child handle.
238 @param Udp6[in] A pointer to the EFI_UDP6_PROTOCOL.
241 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
242 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
247 IN EFI_UDP6_PROTOCOL
*Udp6
251 CHAR16 HandleName
[64];
252 EFI_UDP6_CONFIG_DATA Udp6ConfigData
;
255 return EFI_INVALID_PARAMETER
;
259 // Format the child name into the string buffer.
261 Status
= Udp6
->GetModeData (Udp6
, &Udp6ConfigData
, NULL
, NULL
, NULL
);
262 if (!EFI_ERROR (Status
)) {
263 UnicodeSPrint (HandleName
, sizeof (HandleName
),
264 L
"UDPv6 (SrcPort=%d, DestPort=%d)",
265 Udp6ConfigData
.StationPort
,
266 Udp6ConfigData
.RemotePort
268 } else if (Status
== EFI_NOT_STARTED
) {
269 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"UDPv6 (Not started)");
271 UnicodeSPrint (HandleName
, sizeof (HandleName
), L
"UDPv6 (%r)", Status
);
274 if (gUdp6ControllerNameTable
!= NULL
) {
275 FreeUnicodeStringTable (gUdp6ControllerNameTable
);
276 gUdp6ControllerNameTable
= NULL
;
279 Status
= AddUnicodeString2 (
281 gUdp6ComponentName
.SupportedLanguages
,
282 &gUdp6ControllerNameTable
,
286 if (EFI_ERROR (Status
)) {
290 return AddUnicodeString2 (
292 gUdp6ComponentName2
.SupportedLanguages
,
293 &gUdp6ControllerNameTable
,
300 Retrieves a Unicode string that is the user-readable name of the controller
301 that is being managed by a driver.
303 This function retrieves the user-readable name of the controller specified by
304 ControllerHandle and ChildHandle in the form of a Unicode string. If the
305 driver specified by This has a user-readable name in the language specified by
306 Language, then a pointer to the controller name is returned in ControllerName,
307 and EFI_SUCCESS is returned. If the driver specified by This is not currently
308 managing the controller specified by ControllerHandle and ChildHandle,
309 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
310 support the language specified by Language, then EFI_UNSUPPORTED is returned.
312 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
313 EFI_COMPONENT_NAME_PROTOCOL instance.
315 @param[in] ControllerHandle The handle of a controller that the driver
316 specified by This is managing. This handle
317 specifies the controller whose name is to be
320 @param[in] ChildHandle The handle of the child controller to retrieve
321 the name of. This is an optional parameter that
322 may be NULL. It will be NULL for device
323 drivers. It will also be NULL for a bus drivers
324 that wish to retrieve the name of the bus
325 controller. It will not be NULL for a bus
326 driver that wishes to retrieve the name of a
329 @param[in] Language A pointer to a Null-terminated ASCII string
330 array indicating the language. This is the
331 language of the driver name that the caller is
332 requesting, and it must match one of the
333 languages specified in SupportedLanguages. The
334 number of languages supported by a driver is up
335 to the driver writer. Language is specified in
336 RFC 4646 or ISO 639-2 language code format.
338 @param[out] ControllerName A pointer to the Unicode string to return.
339 This Unicode string is the name of the
340 controller specified by ControllerHandle and
341 ChildHandle in the language specified by
342 Language from the point of view of the driver
345 @retval EFI_SUCCESS The Unicode string for the user-readable name in
346 the language specified by Language for the
347 driver specified by This was returned in
350 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
352 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
355 @retval EFI_INVALID_PARAMETER Language is NULL.
357 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
359 @retval EFI_UNSUPPORTED The driver specified by This is not currently
360 managing the controller specified by
361 ControllerHandle and ChildHandle.
363 @retval EFI_UNSUPPORTED The driver specified by This does not support
364 the language specified by Language.
369 Udp6ComponentNameGetControllerName (
370 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
371 IN EFI_HANDLE ControllerHandle
,
372 IN EFI_HANDLE ChildHandle OPTIONAL
,
374 OUT CHAR16
**ControllerName
378 EFI_UDP6_PROTOCOL
*Udp6
;
381 // Only provide names for child handles.
383 if (ChildHandle
== NULL
) {
384 return EFI_UNSUPPORTED
;
388 // Make sure this driver produced ChildHandle
390 Status
= EfiTestChildHandle (
395 if (EFI_ERROR (Status
)) {
400 // Retrieve an instance of a produced protocol from ChildHandle
402 Status
= gBS
->OpenProtocol (
404 &gEfiUdp6ProtocolGuid
,
408 EFI_OPEN_PROTOCOL_GET_PROTOCOL
410 if (EFI_ERROR (Status
)) {
415 // Update the component name for this child handle.
417 Status
= UpdateName (Udp6
);
418 if (EFI_ERROR (Status
)) {
422 return LookupUnicodeString2 (
424 This
->SupportedLanguages
,
425 gUdp6ControllerNameTable
,
427 (BOOLEAN
)(This
== &gUdp6ComponentName
)