2 UEFI Component Name(2) protocol implementation for SnpDxe driver.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 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 This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
26 EFI_COMPONENT_NAME_PROTOCOL instance.
28 @param Language[in] 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 DriverName[out] 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 SimpleNetworkComponentNameGetDriverName (
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 This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
77 EFI_COMPONENT_NAME_PROTOCOL instance.
79 @param ControllerHandle[in] 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 ChildHandle[in] 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 Language[in] 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 ControllerName[out] 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 SimpleNetworkComponentNameGetControllerName (
134 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
135 IN EFI_HANDLE ControllerHandle
,
136 IN EFI_HANDLE ChildHandle OPTIONAL
,
138 OUT CHAR16
**ControllerName
143 // EFI Component Name Protocol
145 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName
= {
146 SimpleNetworkComponentNameGetDriverName
,
147 SimpleNetworkComponentNameGetControllerName
,
152 // EFI Component Name 2 Protocol
154 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2
= {
155 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) SimpleNetworkComponentNameGetDriverName
,
156 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) SimpleNetworkComponentNameGetControllerName
,
161 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSimpleNetworkDriverNameTable
[] = {
164 L
"Simple Network Protocol Driver"
172 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gSimpleNetworkControllerNameTable
= NULL
;
175 Retrieves a Unicode string that is the user readable name of the driver.
177 This function retrieves the user readable name of a driver in the form of a
178 Unicode string. If the driver specified by This has a user readable name in
179 the language specified by Language, then a pointer to the driver name is
180 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
181 by This does not support the language specified by Language,
182 then EFI_UNSUPPORTED is returned.
184 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
185 EFI_COMPONENT_NAME_PROTOCOL instance.
187 @param Language[in] A pointer to a Null-terminated ASCII string
188 array indicating the language. This is the
189 language of the driver name that the caller is
190 requesting, and it must match one of the
191 languages specified in SupportedLanguages. The
192 number of languages supported by a driver is up
193 to the driver writer. Language is specified
194 in RFC 4646 or ISO 639-2 language code format.
196 @param DriverName[out] A pointer to the Unicode string to return.
197 This Unicode string is the name of the
198 driver specified by This in the language
199 specified by Language.
201 @retval EFI_SUCCESS The Unicode string for the Driver specified by
202 This and the language specified by Language was
203 returned in DriverName.
205 @retval EFI_INVALID_PARAMETER Language is NULL.
207 @retval EFI_INVALID_PARAMETER DriverName is NULL.
209 @retval EFI_UNSUPPORTED The driver specified by This does not support
210 the language specified by Language.
215 SimpleNetworkComponentNameGetDriverName (
216 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
218 OUT CHAR16
**DriverName
221 return LookupUnicodeString2 (
223 This
->SupportedLanguages
,
224 mSimpleNetworkDriverNameTable
,
226 (BOOLEAN
)(This
== &gSimpleNetworkComponentName
)
231 Update the component name for the Snp child handle.
233 @param Snp[in] A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL.
236 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
237 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
242 IN EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
246 CHAR16 HandleName
[80];
251 return EFI_INVALID_PARAMETER
;
255 OffSet
+= UnicodeSPrint (
260 for (Index
= 0; Index
< Snp
->Mode
->HwAddressSize
; Index
++) {
261 OffSet
+= UnicodeSPrint (
263 sizeof (HandleName
) - OffSet
* sizeof (CHAR16
),
265 Snp
->Mode
->CurrentAddress
.Addr
[Index
]
270 // Remove the last '-'
273 OffSet
+= UnicodeSPrint (
275 sizeof (HandleName
) - OffSet
* sizeof (CHAR16
),
278 if (gSimpleNetworkControllerNameTable
!= NULL
) {
279 FreeUnicodeStringTable (gSimpleNetworkControllerNameTable
);
280 gSimpleNetworkControllerNameTable
= NULL
;
283 Status
= AddUnicodeString2 (
285 gSimpleNetworkComponentName
.SupportedLanguages
,
286 &gSimpleNetworkControllerNameTable
,
290 if (EFI_ERROR (Status
)) {
294 return AddUnicodeString2 (
296 gSimpleNetworkComponentName2
.SupportedLanguages
,
297 &gSimpleNetworkControllerNameTable
,
304 Retrieves a Unicode string that is the user readable name of the controller
305 that is being managed by a driver.
307 This function retrieves the user readable name of the controller specified by
308 ControllerHandle and ChildHandle in the form of a Unicode string. If the
309 driver specified by This has a user readable name in the language specified by
310 Language, then a pointer to the controller name is returned in ControllerName,
311 and EFI_SUCCESS is returned. If the driver specified by This is not currently
312 managing the controller specified by ControllerHandle and ChildHandle,
313 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
314 support the language specified by Language, then EFI_UNSUPPORTED is returned.
315 Currently not implemented.
317 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
318 EFI_COMPONENT_NAME_PROTOCOL instance.
320 @param ControllerHandle[in] 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 ChildHandle[in] 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 Language[in] 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 ControllerName[out] 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 SimpleNetworkComponentNameGetControllerName (
375 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
376 IN EFI_HANDLE ControllerHandle
,
377 IN EFI_HANDLE ChildHandle OPTIONAL
,
379 OUT CHAR16
**ControllerName
383 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
385 if (ChildHandle
!= NULL
) {
386 return EFI_UNSUPPORTED
;
390 // Make sure this driver is currently managing ControllHandle
392 Status
= EfiTestManagedDevice (
394 gSimpleNetworkDriverBinding
.DriverBindingHandle
,
395 &gEfiSimpleNetworkProtocolGuid
397 if (EFI_ERROR (Status
)) {
402 // Retrieve an instance of a produced protocol from ControllerHandle
404 Status
= gBS
->OpenProtocol (
406 &gEfiSimpleNetworkProtocolGuid
,
410 EFI_OPEN_PROTOCOL_GET_PROTOCOL
412 if (EFI_ERROR (Status
)) {
416 // Update the component name for this child handle.
418 Status
= UpdateName (Snp
);
419 if (EFI_ERROR (Status
)) {
423 return LookupUnicodeString2 (
425 This
->SupportedLanguages
,
426 gSimpleNetworkControllerNameTable
,
428 (BOOLEAN
)(This
== &gSimpleNetworkComponentName
)