3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 // EFI Component Name Functions
21 Retrieves a Unicode string that is the user readable name of the driver.
23 This function retrieves the user readable name of a driver in the form of a
24 Unicode string. If the driver specified by This has a user readable name in
25 the language specified by Language, then a pointer to the driver name is
26 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
27 by This does not support the language specified by Language,
28 then EFI_UNSUPPORTED is returned.
30 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
31 EFI_COMPONENT_NAME_PROTOCOL instance.
33 @param[in] Language A pointer to a Null-terminated ASCII string
34 array indicating the language. This is the
35 language of the driver name that the caller is
36 requesting, and it must match one of the
37 languages specified in SupportedLanguages. The
38 number of languages supported by a driver is up
39 to the driver writer. Language is specified
40 in RFC 4646 or ISO 639-2 language code format.
42 @param[out] DriverName A pointer to the Unicode string to return.
43 This Unicode string is the name of the
44 driver specified by This in the language
45 specified by Language.
47 @retval EFI_SUCCESS The Unicode string for the Driver specified by
48 This and the language specified by Language was
49 returned in DriverName.
51 @retval EFI_INVALID_PARAMETER Language is NULL.
53 @retval EFI_INVALID_PARAMETER DriverName is NULL.
55 @retval EFI_UNSUPPORTED The driver specified by This does not support
56 the language specified by Language.
61 UdpComponentNameGetDriverName (
62 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
64 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 is NULL.
126 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
128 @retval EFI_UNSUPPORTED The driver specified by This is not currently
129 managing the controller specified by
130 ControllerHandle and ChildHandle.
132 @retval EFI_UNSUPPORTED The driver specified by This does not support
133 the language specified by Language.
138 UdpComponentNameGetControllerName (
139 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
140 IN EFI_HANDLE ControllerHandle
,
141 IN EFI_HANDLE ChildHandle OPTIONAL
,
143 OUT CHAR16
**ControllerName
148 // EFI Component Name Protocol
150 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName
= {
151 UdpComponentNameGetDriverName
,
152 UdpComponentNameGetControllerName
,
157 // EFI Component Name 2 Protocol
159 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2
= {
160 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) UdpComponentNameGetDriverName
,
161 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) UdpComponentNameGetControllerName
,
166 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUdpDriverNameTable
[] = {
169 L
"UDP Network Service Driver"
177 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gUdpControllerNameTable
= 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 UdpComponentNameGetDriverName (
221 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
223 OUT CHAR16
**DriverName
226 return LookupUnicodeString2 (
228 This
->SupportedLanguages
,
231 (BOOLEAN
)(This
== &gUdp4ComponentName
)
236 Update the component name for the Udp4 child handle.
238 @param Udp4[in] A pointer to the EFI_UDP4_PROTOCOL.
241 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
242 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
247 EFI_UDP4_PROTOCOL
*Udp4
251 CHAR16 HandleName
[64];
252 EFI_UDP4_CONFIG_DATA Udp4ConfigData
;
255 return EFI_INVALID_PARAMETER
;
259 // Format the child name into the string buffer as:
260 // UDPv4 (SrcPort=59, DestPort=60)
262 Status
= Udp4
->GetModeData (Udp4
, &Udp4ConfigData
, NULL
, NULL
, NULL
);
263 if (!EFI_ERROR (Status
)) {
264 UnicodeSPrint (HandleName
, sizeof (HandleName
),
265 L
"UDPv4 (SrcPort=%d, DestPort=%d)",
266 Udp4ConfigData
.StationPort
,
267 Udp4ConfigData
.RemotePort
269 } else if (Status
== EFI_NOT_STARTED
) {
273 L
"UDPv4 (Not started)"
279 if (gUdpControllerNameTable
!= NULL
) {
280 FreeUnicodeStringTable (gUdpControllerNameTable
);
281 gUdpControllerNameTable
= NULL
;
284 Status
= AddUnicodeString2 (
286 gUdp4ComponentName
.SupportedLanguages
,
287 &gUdpControllerNameTable
,
291 if (EFI_ERROR (Status
)) {
295 return AddUnicodeString2 (
297 gUdp4ComponentName2
.SupportedLanguages
,
298 &gUdpControllerNameTable
,
305 Retrieves a Unicode string that is the user readable name of the controller
306 that is being managed by a driver.
308 This function retrieves the user readable name of the controller specified by
309 ControllerHandle and ChildHandle in the form of a Unicode string. If the
310 driver specified by This has a user readable name in the language specified by
311 Language, then a pointer to the controller name is returned in ControllerName,
312 and EFI_SUCCESS is returned. If the driver specified by This is not currently
313 managing the controller specified by ControllerHandle and ChildHandle,
314 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
315 support the language specified by Language, then EFI_UNSUPPORTED is returned.
317 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
318 EFI_COMPONENT_NAME_PROTOCOL instance.
320 @param[in] ControllerHandle The handle of a controller that the driver
321 specified by This is managing. This handle
322 specifies the controller whose name is to be
325 @param[in] ChildHandle The handle of the child controller to retrieve
326 the name of. This is an optional parameter that
327 may be NULL. It will be NULL for device
328 drivers. It will also be NULL for a bus drivers
329 that wish to retrieve the name of the bus
330 controller. It will not be NULL for a bus
331 driver that wishes to retrieve the name of a
334 @param[in] Language A pointer to a Null-terminated ASCII string
335 array indicating the language. This is the
336 language of the driver name that the caller is
337 requesting, and it must match one of the
338 languages specified in SupportedLanguages. The
339 number of languages supported by a driver is up
340 to the driver writer. Language is specified in
341 RFC 4646 or ISO 639-2 language code format.
343 @param[out] ControllerName A pointer to the Unicode string to return.
344 This Unicode string is the name of the
345 controller specified by ControllerHandle and
346 ChildHandle in the language specified by
347 Language from the point of view of the driver
350 @retval EFI_SUCCESS The Unicode string for the user readable name in
351 the language specified by Language for the
352 driver specified by This was returned in
355 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
357 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
360 @retval EFI_INVALID_PARAMETER Language is NULL.
362 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
364 @retval EFI_UNSUPPORTED The driver specified by This is not currently
365 managing the controller specified by
366 ControllerHandle and ChildHandle.
368 @retval EFI_UNSUPPORTED The driver specified by This does not support
369 the language specified by Language.
374 UdpComponentNameGetControllerName (
375 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
376 IN EFI_HANDLE ControllerHandle
,
377 IN EFI_HANDLE ChildHandle OPTIONAL
,
379 OUT CHAR16
**ControllerName
383 EFI_UDP4_PROTOCOL
*Udp4
;
386 // Only provide names for child handles.
388 if (ChildHandle
== NULL
) {
389 return EFI_UNSUPPORTED
;
393 // Make sure this driver produced ChildHandle
395 Status
= EfiTestChildHandle (
400 if (EFI_ERROR (Status
)) {
405 // Retrieve an instance of a produced protocol from ChildHandle
407 Status
= gBS
->OpenProtocol (
409 &gEfiUdp4ProtocolGuid
,
413 EFI_OPEN_PROTOCOL_GET_PROTOCOL
415 if (EFI_ERROR (Status
)) {
420 // Update the component name for this child handle.
422 Status
= UpdateName (Udp4
);
423 if (EFI_ERROR (Status
)) {
427 return LookupUnicodeString2 (
429 This
->SupportedLanguages
,
430 gUdpControllerNameTable
,
432 (BOOLEAN
)(This
== &gUdp4ComponentName
)