2 UEFI Component Name(2) protocol implementation for SnpDxe driver.
4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed
6 and made available under the terms and conditions of the BSD License which
7 accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 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 This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
32 EFI_COMPONENT_NAME_PROTOCOL instance.
34 @param Language[in] 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 DriverName[out] 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 SimpleNetworkComponentNameGetDriverName (
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 This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
83 EFI_COMPONENT_NAME_PROTOCOL instance.
85 @param ControllerHandle[in] 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 ChildHandle[in] 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 Language[in] 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 ControllerName[out] 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 SimpleNetworkComponentNameGetControllerName (
140 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
141 IN EFI_HANDLE ControllerHandle
,
142 IN EFI_HANDLE ChildHandle OPTIONAL
,
144 OUT CHAR16
**ControllerName
149 // EFI Component Name Protocol
151 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName
= {
152 SimpleNetworkComponentNameGetDriverName
,
153 SimpleNetworkComponentNameGetControllerName
,
158 // EFI Component Name 2 Protocol
160 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2
= {
161 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) SimpleNetworkComponentNameGetDriverName
,
162 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) SimpleNetworkComponentNameGetControllerName
,
167 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSimpleNetworkDriverNameTable
[] = {
170 L
"Simple Network Protocol Driver"
178 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gSimpleNetworkControllerNameTable
= NULL
;
181 Retrieves a Unicode string that is the user readable name of the driver.
183 This function retrieves the user readable name of a driver in the form of a
184 Unicode string. If the driver specified by This has a user readable name in
185 the language specified by Language, then a pointer to the driver name is
186 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
187 by This does not support the language specified by Language,
188 then EFI_UNSUPPORTED is returned.
190 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
191 EFI_COMPONENT_NAME_PROTOCOL instance.
193 @param Language[in] A pointer to a Null-terminated ASCII string
194 array indicating the language. This is the
195 language of the driver name that the caller is
196 requesting, and it must match one of the
197 languages specified in SupportedLanguages. The
198 number of languages supported by a driver is up
199 to the driver writer. Language is specified
200 in RFC 4646 or ISO 639-2 language code format.
202 @param DriverName[out] A pointer to the Unicode string to return.
203 This Unicode string is the name of the
204 driver specified by This in the language
205 specified by Language.
207 @retval EFI_SUCCESS The Unicode string for the Driver specified by
208 This and the language specified by Language was
209 returned in DriverName.
211 @retval EFI_INVALID_PARAMETER Language is NULL.
213 @retval EFI_INVALID_PARAMETER DriverName is NULL.
215 @retval EFI_UNSUPPORTED The driver specified by This does not support
216 the language specified by Language.
221 SimpleNetworkComponentNameGetDriverName (
222 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
224 OUT CHAR16
**DriverName
227 return LookupUnicodeString2 (
229 This
->SupportedLanguages
,
230 mSimpleNetworkDriverNameTable
,
232 (BOOLEAN
)(This
== &gSimpleNetworkComponentName
)
237 Update the component name for the Snp child handle.
239 @param Snp[in] A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL.
242 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
243 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
248 IN EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
252 CHAR16 HandleName
[80];
257 return EFI_INVALID_PARAMETER
;
261 OffSet
+= UnicodeSPrint (
266 for (Index
= 0; Index
< Snp
->Mode
->HwAddressSize
; Index
++) {
267 OffSet
+= UnicodeSPrint (
269 sizeof (HandleName
) - OffSet
* sizeof (CHAR16
),
271 Snp
->Mode
->CurrentAddress
.Addr
[Index
]
276 // Remove the last '-'
279 OffSet
+= UnicodeSPrint (
281 sizeof (HandleName
) - OffSet
* sizeof (CHAR16
),
284 if (gSimpleNetworkControllerNameTable
!= NULL
) {
285 FreeUnicodeStringTable (gSimpleNetworkControllerNameTable
);
286 gSimpleNetworkControllerNameTable
= NULL
;
289 Status
= AddUnicodeString2 (
291 gSimpleNetworkComponentName
.SupportedLanguages
,
292 &gSimpleNetworkControllerNameTable
,
296 if (EFI_ERROR (Status
)) {
300 return AddUnicodeString2 (
302 gSimpleNetworkComponentName2
.SupportedLanguages
,
303 &gSimpleNetworkControllerNameTable
,
310 Retrieves a Unicode string that is the user readable name of the controller
311 that is being managed by a driver.
313 This function retrieves the user readable name of the controller specified by
314 ControllerHandle and ChildHandle in the form of a Unicode string. If the
315 driver specified by This has a user readable name in the language specified by
316 Language, then a pointer to the controller name is returned in ControllerName,
317 and EFI_SUCCESS is returned. If the driver specified by This is not currently
318 managing the controller specified by ControllerHandle and ChildHandle,
319 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
320 support the language specified by Language, then EFI_UNSUPPORTED is returned.
321 Currently not implemented.
323 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
324 EFI_COMPONENT_NAME_PROTOCOL instance.
326 @param ControllerHandle[in] The handle of a controller that the driver
327 specified by This is managing. This handle
328 specifies the controller whose name is to be
331 @param ChildHandle[in] The handle of the child controller to retrieve
332 the name of. This is an optional parameter that
333 may be NULL. It will be NULL for device
334 drivers. It will also be NULL for a bus drivers
335 that wish to retrieve the name of the bus
336 controller. It will not be NULL for a bus
337 driver that wishes to retrieve the name of a
340 @param Language[in] A pointer to a Null-terminated ASCII string
341 array indicating the language. This is the
342 language of the driver name that the caller is
343 requesting, and it must match one of the
344 languages specified in SupportedLanguages. The
345 number of languages supported by a driver is up
346 to the driver writer. Language is specified in
347 RFC 4646 or ISO 639-2 language code format.
349 @param ControllerName[out] A pointer to the Unicode string to return.
350 This Unicode string is the name of the
351 controller specified by ControllerHandle and
352 ChildHandle in the language specified by
353 Language from the point of view of the driver
356 @retval EFI_SUCCESS The Unicode string for the user readable name in
357 the language specified by Language for the
358 driver specified by This was returned in
361 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
363 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
366 @retval EFI_INVALID_PARAMETER Language is NULL.
368 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
370 @retval EFI_UNSUPPORTED The driver specified by This is not currently
371 managing the controller specified by
372 ControllerHandle and ChildHandle.
374 @retval EFI_UNSUPPORTED The driver specified by This does not support
375 the language specified by Language.
380 SimpleNetworkComponentNameGetControllerName (
381 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
382 IN EFI_HANDLE ControllerHandle
,
383 IN EFI_HANDLE ChildHandle OPTIONAL
,
385 OUT CHAR16
**ControllerName
389 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
391 if (ChildHandle
!= NULL
) {
392 return EFI_UNSUPPORTED
;
396 // Make sure this driver is currently managing ControllHandle
398 Status
= EfiTestManagedDevice (
400 gSimpleNetworkDriverBinding
.DriverBindingHandle
,
401 &gEfiSimpleNetworkProtocolGuid
403 if (EFI_ERROR (Status
)) {
408 // Retrieve an instance of a produced protocol from ControllerHandle
410 Status
= gBS
->OpenProtocol (
412 &gEfiSimpleNetworkProtocolGuid
,
416 EFI_OPEN_PROTOCOL_GET_PROTOCOL
418 if (EFI_ERROR (Status
)) {
422 // Update the component name for this child handle.
424 Status
= UpdateName (Snp
);
425 if (EFI_ERROR (Status
)) {
429 return LookupUnicodeString2 (
431 This
->SupportedLanguages
,
432 gSimpleNetworkControllerNameTable
,
434 (BOOLEAN
)(This
== &gSimpleNetworkComponentName
)