2 UEFI Component Name(2) protocol implementation for UefiPxeBc driver.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "PxeBcImpl.h"
13 Retrieves a Unicode string that is the user-readable name of the driver.
15 This function retrieves the user-readable name of a driver in the form of a
16 Unicode string. If the driver specified by This has a user-readable name in
17 the language specified by Language, then a pointer to the driver name is
18 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
19 by This does not support the language specified by Language,
20 then EFI_UNSUPPORTED is returned.
22 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
23 EFI_COMPONENT_NAME_PROTOCOL instance.
25 @param[in] Language A pointer to a Null-terminated ASCII string
26 array indicating the language. This is the
27 language of the driver name that the caller is
28 requesting, and it must match one of the
29 languages specified in SupportedLanguages. The
30 number of languages supported by a driver is up
31 to the driver writer. Language is specified
32 in RFC 4646 or ISO 639-2 language code format.
34 @param[out] DriverName A pointer to the Unicode string to return.
35 This Unicode string is the name of the
36 driver specified by This in the language
37 specified by Language.
39 @retval EFI_SUCCESS The Unicode string for the Driver specified by
40 This and the language specified by Language was
41 returned in DriverName.
43 @retval EFI_INVALID_PARAMETER Language is NULL.
45 @retval EFI_INVALID_PARAMETER DriverName is NULL.
47 @retval EFI_UNSUPPORTED The driver specified by This does not support
48 the language specified by Language.
53 PxeBcComponentNameGetDriverName (
54 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
56 OUT CHAR16
**DriverName
61 Retrieves a Unicode string that is the user-readable name of the controller
62 that is being managed by a driver.
64 This function retrieves the user-readable name of the controller specified by
65 ControllerHandle and ChildHandle in the form of a Unicode string. If the
66 driver specified by This has a user-readable name in the language specified by
67 Language, then a pointer to the controller name is returned in ControllerName,
68 and EFI_SUCCESS is returned. If the driver specified by This is not currently
69 managing the controller specified by ControllerHandle and ChildHandle,
70 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
71 support the language specified by Language, then EFI_UNSUPPORTED is returned.
73 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
74 EFI_COMPONENT_NAME_PROTOCOL instance.
76 @param[in] ControllerHandle The handle of a controller that the driver
77 specified by This is managing. This handle
78 specifies the controller whose name is to be
81 @param[in] ChildHandle The handle of the child controller to retrieve
82 the name of. This is an optional parameter that
83 may be NULL. It will be NULL for device
84 drivers. It will also be NULL for a bus drivers
85 that wish to retrieve the name of the bus
86 controller. It will not be NULL for a bus
87 driver that wishes to retrieve the name of a
90 @param[in] Language A pointer to a Null-terminated ASCII string
91 array indicating the language. This is the
92 language of the driver name that the caller is
93 requesting, and it must match one of the
94 languages specified in SupportedLanguages. The
95 number of languages supported by a driver is up
96 to the driver writer. Language is specified in
97 RFC 4646 or ISO 639-2 language code format.
99 @param[out] ControllerName A pointer to the Unicode string to return.
100 This Unicode string is the name of the
101 controller specified by ControllerHandle and
102 ChildHandle in the language specified by
103 Language from the point of view of the driver
106 @retval EFI_SUCCESS The Unicode string for the user-readable name in
107 the language specified by Language for the
108 driver specified by This was returned in
111 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
113 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
116 @retval EFI_INVALID_PARAMETER Language is NULL.
118 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
120 @retval EFI_UNSUPPORTED The driver specified by This is not currently
121 managing the controller specified by
122 ControllerHandle and ChildHandle.
124 @retval EFI_UNSUPPORTED The driver specified by This does not support
125 the language specified by Language.
130 PxeBcComponentNameGetControllerName (
131 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
132 IN EFI_HANDLE ControllerHandle
,
133 IN EFI_HANDLE ChildHandle OPTIONAL
,
135 OUT CHAR16
**ControllerName
140 // EFI Component Name Protocol
142 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName
= {
143 PxeBcComponentNameGetDriverName
,
144 PxeBcComponentNameGetControllerName
,
149 // EFI Component Name 2 Protocol
151 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2
= {
152 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) PxeBcComponentNameGetDriverName
,
153 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) PxeBcComponentNameGetControllerName
,
157 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcDriverNameTable
[] = {
160 L
"UEFI PXE Base Code Driver"
168 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcControllerNameTable
[] = {
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 PxeBcComponentNameGetDriverName (
221 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
223 OUT CHAR16
**DriverName
226 return LookupUnicodeString2(
228 This
->SupportedLanguages
,
229 mPxeBcDriverNameTable
,
231 (BOOLEAN
)(This
== &gPxeBcComponentName
)
237 Retrieves a Unicode string that is the user-readable name of the controller
238 that is being managed by a driver.
240 This function retrieves the user-readable name of the controller specified by
241 ControllerHandle and ChildHandle in the form of a Unicode string. If the
242 driver specified by This has a user-readable name in the language specified by
243 Language, then a pointer to the controller name is returned in ControllerName,
244 and EFI_SUCCESS is returned. If the driver specified by This is not currently
245 managing the controller specified by ControllerHandle and ChildHandle,
246 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
247 support the language specified by Language, then EFI_UNSUPPORTED is returned.
249 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
250 EFI_COMPONENT_NAME_PROTOCOL instance.
252 @param[in] ControllerHandle The handle of a controller that the driver
253 specified by This is managing. This handle
254 specifies the controller whose name is to be
257 @param[in] ChildHandle The handle of the child controller to retrieve
258 the name of. This is an optional parameter that
259 may be NULL. It will be NULL for device
260 drivers. It will also be NULL for a bus drivers
261 that wish to retrieve the name of the bus
262 controller. It will not be NULL for a bus
263 driver that wishes to retrieve the name of a
266 @param[in] Language A pointer to a Null-terminated ASCII string
267 array indicating the language. This is the
268 language of the driver name that the caller is
269 requesting, and it must match one of the
270 languages specified in SupportedLanguages. The
271 number of languages supported by a driver is up
272 to the driver writer. Language is specified in
273 RFC 4646 or ISO 639-2 language code format.
275 @param[out] ControllerName A pointer to the Unicode string to return.
276 This Unicode string is the name of the
277 controller specified by ControllerHandle and
278 ChildHandle in the language specified by
279 Language from the point of view of the driver
282 @retval EFI_SUCCESS The Unicode string for the user-readable name in
283 the language specified by Language for the
284 driver specified by This was returned in
287 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
289 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
292 @retval EFI_INVALID_PARAMETER Language is NULL.
294 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
296 @retval EFI_UNSUPPORTED The driver specified by This is not currently
297 managing the controller specified by
298 ControllerHandle and ChildHandle.
300 @retval EFI_UNSUPPORTED The driver specified by This does not support
301 the language specified by Language.
306 PxeBcComponentNameGetControllerName (
307 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
308 IN EFI_HANDLE ControllerHandle
,
309 IN EFI_HANDLE ChildHandle OPTIONAL
,
311 OUT CHAR16
**ControllerName
315 EFI_HANDLE NicHandle
;
316 PXEBC_PRIVATE_PROTOCOL
*Id
;
318 if (ControllerHandle
== NULL
|| ChildHandle
!= NULL
) {
319 return EFI_UNSUPPORTED
;
322 NicHandle
= PxeBcGetNicByIp4Children (ControllerHandle
);
323 if (NicHandle
== NULL
) {
324 NicHandle
= PxeBcGetNicByIp6Children (ControllerHandle
);
325 if (NicHandle
== NULL
) {
326 return EFI_UNSUPPORTED
;
331 // Try to retrieve the private data by PxeBcPrivate protocol.
333 Status
= gBS
->OpenProtocol (
339 EFI_OPEN_PROTOCOL_GET_PROTOCOL
341 if (EFI_ERROR (Status
)) {
345 return LookupUnicodeString2 (
347 This
->SupportedLanguages
,
348 mPxeBcControllerNameTable
,
350 (BOOLEAN
)(This
== &gPxeBcComponentName
)