2 UEFI Component Name(2) protocol implementation for UefiPxeBc 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.
16 #include "PxeBcImpl.h"
19 Retrieves a Unicode string that is the user-readable name of the driver.
21 This function retrieves the user-readable name of a driver in the form of a
22 Unicode string. If the driver specified by This has a user-readable name in
23 the language specified by Language, then a pointer to the driver name is
24 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
25 by This does not support the language specified by Language,
26 then EFI_UNSUPPORTED is returned.
28 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
29 EFI_COMPONENT_NAME_PROTOCOL instance.
31 @param[in] Language A pointer to a Null-terminated ASCII string
32 array indicating the language. This is the
33 language of the driver name that the caller is
34 requesting, and it must match one of the
35 languages specified in SupportedLanguages. The
36 number of languages supported by a driver is up
37 to the driver writer. Language is specified
38 in RFC 4646 or ISO 639-2 language code format.
40 @param[out] DriverName A pointer to the Unicode string to return.
41 This Unicode string is the name of the
42 driver specified by This in the language
43 specified by Language.
45 @retval EFI_SUCCESS The Unicode string for the Driver specified by
46 This and the language specified by Language was
47 returned in DriverName.
49 @retval EFI_INVALID_PARAMETER Language is NULL.
51 @retval EFI_INVALID_PARAMETER DriverName is NULL.
53 @retval EFI_UNSUPPORTED The driver specified by This does not support
54 the language specified by Language.
59 PxeBcComponentNameGetDriverName (
60 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
62 OUT CHAR16
**DriverName
67 Retrieves a Unicode string that is the user-readable name of the controller
68 that is being managed by a driver.
70 This function retrieves the user-readable name of the controller specified by
71 ControllerHandle and ChildHandle in the form of a Unicode string. If the
72 driver specified by This has a user-readable name in the language specified by
73 Language, then a pointer to the controller name is returned in ControllerName,
74 and EFI_SUCCESS is returned. If the driver specified by This is not currently
75 managing the controller specified by ControllerHandle and ChildHandle,
76 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
77 support the language specified by Language, then EFI_UNSUPPORTED is returned.
79 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
80 EFI_COMPONENT_NAME_PROTOCOL instance.
82 @param[in] ControllerHandle The handle of a controller that the driver
83 specified by This is managing. This handle
84 specifies the controller whose name is to be
87 @param[in] ChildHandle The handle of the child controller to retrieve
88 the name of. This is an optional parameter that
89 may be NULL. It will be NULL for device
90 drivers. It will also be NULL for a bus drivers
91 that wish to retrieve the name of the bus
92 controller. It will not be NULL for a bus
93 driver that wishes to retrieve the name of a
96 @param[in] Language A pointer to a Null-terminated ASCII string
97 array indicating the language. This is the
98 language of the driver name that the caller is
99 requesting, and it must match one of the
100 languages specified in SupportedLanguages. The
101 number of languages supported by a driver is up
102 to the driver writer. Language is specified in
103 RFC 4646 or ISO 639-2 language code format.
105 @param[out] ControllerName A pointer to the Unicode string to return.
106 This Unicode string is the name of the
107 controller specified by ControllerHandle and
108 ChildHandle in the language specified by
109 Language from the point of view of the driver
112 @retval EFI_SUCCESS The Unicode string for the user-readable name in
113 the language specified by Language for the
114 driver specified by This was returned in
117 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
119 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
122 @retval EFI_INVALID_PARAMETER Language is NULL.
124 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
126 @retval EFI_UNSUPPORTED The driver specified by This is not currently
127 managing the controller specified by
128 ControllerHandle and ChildHandle.
130 @retval EFI_UNSUPPORTED The driver specified by This does not support
131 the language specified by Language.
136 PxeBcComponentNameGetControllerName (
137 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
138 IN EFI_HANDLE ControllerHandle
,
139 IN EFI_HANDLE ChildHandle OPTIONAL
,
141 OUT CHAR16
**ControllerName
146 // EFI Component Name Protocol
148 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName
= {
149 PxeBcComponentNameGetDriverName
,
150 PxeBcComponentNameGetControllerName
,
155 // EFI Component Name 2 Protocol
157 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2
= {
158 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) PxeBcComponentNameGetDriverName
,
159 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) PxeBcComponentNameGetControllerName
,
163 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcDriverNameTable
[] = {
166 L
"UEFI PXE Base Code Driver"
174 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcControllerNameTable
[] = {
186 Retrieves a Unicode string that is the user-readable name of the driver.
188 This function retrieves the user-readable name of a driver in the form of a
189 Unicode string. If the driver specified by This has a user-readable name in
190 the language specified by Language, then a pointer to the driver name is
191 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
192 by This does not support the language specified by Language,
193 then EFI_UNSUPPORTED is returned.
195 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
196 EFI_COMPONENT_NAME_PROTOCOL instance.
198 @param[in] Language A pointer to a Null-terminated ASCII string
199 array indicating the language. This is the
200 language of the driver name that the caller is
201 requesting, and it must match one of the
202 languages specified in SupportedLanguages. The
203 number of languages supported by a driver is up
204 to the driver writer. Language is specified
205 in RFC 4646 or ISO 639-2 language code format.
207 @param[out] DriverName A pointer to the Unicode string to return.
208 This Unicode string is the name of the
209 driver specified by This in the language
210 specified by Language.
212 @retval EFI_SUCCESS The Unicode string for the Driver specified by
213 This and the language specified by Language was
214 returned in DriverName.
216 @retval EFI_INVALID_PARAMETER Language is NULL.
218 @retval EFI_INVALID_PARAMETER DriverName is NULL.
220 @retval EFI_UNSUPPORTED The driver specified by This does not support
221 the language specified by Language.
226 PxeBcComponentNameGetDriverName (
227 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
229 OUT CHAR16
**DriverName
232 return LookupUnicodeString2(
234 This
->SupportedLanguages
,
235 mPxeBcDriverNameTable
,
237 (BOOLEAN
)(This
== &gPxeBcComponentName
)
243 Retrieves a Unicode string that is the user-readable name of the controller
244 that is being managed by a driver.
246 This function retrieves the user-readable name of the controller specified by
247 ControllerHandle and ChildHandle in the form of a Unicode string. If the
248 driver specified by This has a user-readable name in the language specified by
249 Language, then a pointer to the controller name is returned in ControllerName,
250 and EFI_SUCCESS is returned. If the driver specified by This is not currently
251 managing the controller specified by ControllerHandle and ChildHandle,
252 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
253 support the language specified by Language, then EFI_UNSUPPORTED is returned.
255 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
256 EFI_COMPONENT_NAME_PROTOCOL instance.
258 @param[in] ControllerHandle The handle of a controller that the driver
259 specified by This is managing. This handle
260 specifies the controller whose name is to be
263 @param[in] ChildHandle The handle of the child controller to retrieve
264 the name of. This is an optional parameter that
265 may be NULL. It will be NULL for device
266 drivers. It will also be NULL for a bus drivers
267 that wish to retrieve the name of the bus
268 controller. It will not be NULL for a bus
269 driver that wishes to retrieve the name of a
272 @param[in] Language A pointer to a Null-terminated ASCII string
273 array indicating the language. This is the
274 language of the driver name that the caller is
275 requesting, and it must match one of the
276 languages specified in SupportedLanguages. The
277 number of languages supported by a driver is up
278 to the driver writer. Language is specified in
279 RFC 4646 or ISO 639-2 language code format.
281 @param[out] ControllerName A pointer to the Unicode string to return.
282 This Unicode string is the name of the
283 controller specified by ControllerHandle and
284 ChildHandle in the language specified by
285 Language from the point of view of the driver
288 @retval EFI_SUCCESS The Unicode string for the user-readable name in
289 the language specified by Language for the
290 driver specified by This was returned in
293 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
295 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
298 @retval EFI_INVALID_PARAMETER Language is NULL.
300 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
302 @retval EFI_UNSUPPORTED The driver specified by This is not currently
303 managing the controller specified by
304 ControllerHandle and ChildHandle.
306 @retval EFI_UNSUPPORTED The driver specified by This does not support
307 the language specified by Language.
312 PxeBcComponentNameGetControllerName (
313 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
314 IN EFI_HANDLE ControllerHandle
,
315 IN EFI_HANDLE ChildHandle OPTIONAL
,
317 OUT CHAR16
**ControllerName
321 EFI_HANDLE NicHandle
;
322 PXEBC_PRIVATE_PROTOCOL
*Id
;
324 if (ControllerHandle
== NULL
|| ChildHandle
!= NULL
) {
325 return EFI_UNSUPPORTED
;
328 NicHandle
= PxeBcGetNicByIp4Children (ControllerHandle
);
329 if (NicHandle
== NULL
) {
330 NicHandle
= PxeBcGetNicByIp6Children (ControllerHandle
);
331 if (NicHandle
== NULL
) {
332 return EFI_UNSUPPORTED
;
337 // Try to retrieve the private data by PxeBcPrivate protocol.
339 Status
= gBS
->OpenProtocol (
345 EFI_OPEN_PROTOCOL_GET_PROTOCOL
347 if (EFI_ERROR (Status
)) {
351 return LookupUnicodeString2 (
353 This
->SupportedLanguages
,
354 mPxeBcControllerNameTable
,
356 (BOOLEAN
)(This
== &gPxeBcComponentName
)