3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
12 // EFI Component Name Functions
15 Retrieves a Unicode string that is the user readable name of the driver.
17 This function retrieves the user readable name of a driver in the form of a
18 Unicode string. If the driver specified by This has a user readable name in
19 the language specified by Language, then a pointer to the driver name is
20 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
21 by This does not support the language specified by Language,
22 then EFI_UNSUPPORTED is returned.
24 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
25 EFI_COMPONENT_NAME_PROTOCOL instance.
27 @param[in] Language A pointer to a Null-terminated ASCII string
28 array indicating the language. This is the
29 language of the driver name that the caller is
30 requesting, and it must match one of the
31 languages specified in SupportedLanguages. The
32 number of languages supported by a driver is up
33 to the driver writer. Language is specified
34 in RFC 4646 or ISO 639-2 language code format.
36 @param[out] DriverName A pointer to the Unicode string to return.
37 This Unicode string is the name of the
38 driver specified by This in the language
39 specified by Language.
41 @retval EFI_SUCCESS The Unicode string for the Driver specified by
42 This and the language specified by Language was
43 returned in DriverName.
45 @retval EFI_INVALID_PARAMETER Language is NULL.
47 @retval EFI_INVALID_PARAMETER DriverName is NULL.
49 @retval EFI_UNSUPPORTED The driver specified by This does not support
50 the language specified by Language.
55 DhcpComponentNameGetDriverName (
56 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
58 OUT CHAR16
**DriverName
63 Retrieves a Unicode string that is the user readable name of the controller
64 that is being managed by a driver.
66 This function retrieves the user readable name of the controller specified by
67 ControllerHandle and ChildHandle in the form of a Unicode string. If the
68 driver specified by This has a user readable name in the language specified by
69 Language, then a pointer to the controller name is returned in ControllerName,
70 and EFI_SUCCESS is returned. If the driver specified by This is not currently
71 managing the controller specified by ControllerHandle and ChildHandle,
72 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
73 support the language specified by Language, then EFI_UNSUPPORTED is returned.
75 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
76 EFI_COMPONENT_NAME_PROTOCOL instance.
78 @param[in] ControllerHandle The handle of a controller that the driver
79 specified by This is managing. This handle
80 specifies the controller whose name is to be
83 @param[in] ChildHandle The handle of the child controller to retrieve
84 the name of. This is an optional parameter that
85 may be NULL. It will be NULL for device
86 drivers. It will also be NULL for a bus drivers
87 that wish to retrieve the name of the bus
88 controller. It will not be NULL for a bus
89 driver that wishes to retrieve the name of a
92 @param[in] Language A pointer to a Null-terminated ASCII string
93 array indicating the language. This is the
94 language of the driver name that the caller is
95 requesting, and it must match one of the
96 languages specified in SupportedLanguages. The
97 number of languages supported by a driver is up
98 to the driver writer. Language is specified in
99 RFC 4646 or ISO 639-2 language code format.
101 @param[out] ControllerName A pointer to the Unicode string to return.
102 This Unicode string is the name of the
103 controller specified by ControllerHandle and
104 ChildHandle in the language specified by
105 Language from the point of view of the driver
108 @retval EFI_SUCCESS The Unicode string for the user readable name in
109 the language specified by Language for the
110 driver specified by This was returned in
113 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
115 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
118 @retval EFI_INVALID_PARAMETER Language is NULL.
120 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
122 @retval EFI_UNSUPPORTED The driver specified by This is not currently
123 managing the controller specified by
124 ControllerHandle and ChildHandle.
126 @retval EFI_UNSUPPORTED The driver specified by This does not support
127 the language specified by Language.
132 DhcpComponentNameGetControllerName (
133 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
134 IN EFI_HANDLE ControllerHandle
,
135 IN EFI_HANDLE ChildHandle OPTIONAL
,
137 OUT CHAR16
**ControllerName
142 // EFI Component Name Protocol
144 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName
= {
145 DhcpComponentNameGetDriverName
,
146 DhcpComponentNameGetControllerName
,
151 // EFI Component Name 2 Protocol
153 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2
= {
154 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) DhcpComponentNameGetDriverName
,
155 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) DhcpComponentNameGetControllerName
,
160 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable
[] = {
163 L
"DHCP Protocol Driver"
171 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gDhcpControllerNameTable
= NULL
;
173 CHAR16
*mDhcp4ControllerName
[] = {
174 L
"DHCPv4 (State=0, Stopped)",
175 L
"DHCPv4 (State=1, Init)",
176 L
"DHCPv4 (State=2, Selecting)",
177 L
"DHCPv4 (State=3, Requesting)",
178 L
"DHCPv4 (State=4, Bound)",
179 L
"DHCPv4 (State=5, Renewing)",
180 L
"DHCPv4 (State=6, Rebinding)",
181 L
"DHCPv4 (State=7, InitReboot)",
182 L
"DHCPv4 (State=8, Rebooting)"
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 DhcpComponentNameGetDriverName (
227 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
229 OUT CHAR16
**DriverName
232 return LookupUnicodeString2 (
234 This
->SupportedLanguages
,
235 mDhcpDriverNameTable
,
237 (BOOLEAN
)(This
== &gDhcp4ComponentName
)
242 Update the component name for the Dhcp4 child handle.
244 @param Dhcp4[in] A pointer to the EFI_DHCP4_PROTOCOL.
247 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
248 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
249 @retval EFI_DEVICE_ERROR DHCP is in unknown state.
254 IN EFI_DHCP4_PROTOCOL
*Dhcp4
258 EFI_DHCP4_MODE_DATA Dhcp4ModeData
;
261 return EFI_INVALID_PARAMETER
;
265 // Format the child name into the string buffer.
267 Status
= Dhcp4
->GetModeData (Dhcp4
, &Dhcp4ModeData
);
268 if (EFI_ERROR (Status
)) {
272 if (gDhcpControllerNameTable
!= NULL
) {
273 FreeUnicodeStringTable (gDhcpControllerNameTable
);
274 gDhcpControllerNameTable
= NULL
;
277 if (Dhcp4ModeData
.State
> Dhcp4Rebooting
) {
278 return EFI_DEVICE_ERROR
;
281 Status
= AddUnicodeString2 (
283 gDhcp4ComponentName
.SupportedLanguages
,
284 &gDhcpControllerNameTable
,
285 mDhcp4ControllerName
[Dhcp4ModeData
.State
],
288 if (EFI_ERROR (Status
)) {
292 return AddUnicodeString2 (
294 gDhcp4ComponentName2
.SupportedLanguages
,
295 &gDhcpControllerNameTable
,
296 mDhcp4ControllerName
[Dhcp4ModeData
.State
],
302 Retrieves a Unicode string that is the user readable name of the controller
303 that is being managed by a driver.
305 This function retrieves the user readable name of the controller specified by
306 ControllerHandle and ChildHandle in the form of a Unicode string. If the
307 driver specified by This has a user readable name in the language specified by
308 Language, then a pointer to the controller name is returned in ControllerName,
309 and EFI_SUCCESS is returned. If the driver specified by This is not currently
310 managing the controller specified by ControllerHandle and ChildHandle,
311 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
312 support the language specified by Language, then EFI_UNSUPPORTED is returned.
314 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
315 EFI_COMPONENT_NAME_PROTOCOL instance.
317 @param[in] ControllerHandle The handle of a controller that the driver
318 specified by This is managing. This handle
319 specifies the controller whose name is to be
322 @param[in] ChildHandle The handle of the child controller to retrieve
323 the name of. This is an optional parameter that
324 may be NULL. It will be NULL for device
325 drivers. It will also be NULL for a bus drivers
326 that wish to retrieve the name of the bus
327 controller. It will not be NULL for a bus
328 driver that wishes to retrieve the name of a
331 @param[in] Language A pointer to a Null-terminated ASCII string
332 array indicating the language. This is the
333 language of the driver name that the caller is
334 requesting, and it must match one of the
335 languages specified in SupportedLanguages. The
336 number of languages supported by a driver is up
337 to the driver writer. Language is specified in
338 RFC 4646 or ISO 639-2 language code format.
340 @param[out] ControllerName A pointer to the Unicode string to return.
341 This Unicode string is the name of the
342 controller specified by ControllerHandle and
343 ChildHandle in the language specified by
344 Language from the point of view of the driver
347 @retval EFI_SUCCESS The Unicode string for the user readable name in
348 the language specified by Language for the
349 driver specified by This was returned in
352 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
354 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
357 @retval EFI_INVALID_PARAMETER Language is NULL.
359 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
361 @retval EFI_UNSUPPORTED The driver specified by This is not currently
362 managing the controller specified by
363 ControllerHandle and ChildHandle.
365 @retval EFI_UNSUPPORTED The driver specified by This does not support
366 the language specified by Language.
371 DhcpComponentNameGetControllerName (
372 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
373 IN EFI_HANDLE ControllerHandle
,
374 IN EFI_HANDLE ChildHandle OPTIONAL
,
376 OUT CHAR16
**ControllerName
380 EFI_DHCP4_PROTOCOL
*Dhcp4
;
383 // Only provide names for child handles.
385 if (ChildHandle
== NULL
) {
386 return EFI_UNSUPPORTED
;
390 // Make sure this driver produced ChildHandle
392 Status
= EfiTestChildHandle (
395 &gEfiUdp4ProtocolGuid
397 if (EFI_ERROR (Status
)) {
402 // Retrieve an instance of a produced protocol from ChildHandle
404 Status
= gBS
->OpenProtocol (
406 &gEfiDhcp4ProtocolGuid
,
410 EFI_OPEN_PROTOCOL_GET_PROTOCOL
412 if (EFI_ERROR (Status
)) {
417 // Update the component name for this child handle.
419 Status
= UpdateName (Dhcp4
);
420 if (EFI_ERROR (Status
)) {
424 return LookupUnicodeString2 (
426 This
->SupportedLanguages
,
427 gDhcpControllerNameTable
,
429 (BOOLEAN
)(This
== &gDhcp4ComponentName
)