3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
11 // 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
62 Retrieves a Unicode string that is the user readable name of the controller
63 that is being managed by a driver.
65 This function retrieves the user readable name of the controller specified by
66 ControllerHandle and ChildHandle in the form of a Unicode string. If the
67 driver specified by This has a user readable name in the language specified by
68 Language, then a pointer to the controller name is returned in ControllerName,
69 and EFI_SUCCESS is returned. If the driver specified by This is not currently
70 managing the controller specified by ControllerHandle and ChildHandle,
71 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
72 support the language specified by Language, then EFI_UNSUPPORTED is returned.
74 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
75 EFI_COMPONENT_NAME_PROTOCOL instance.
77 @param[in] ControllerHandle The handle of a controller that the driver
78 specified by This is managing. This handle
79 specifies the controller whose name is to be
82 @param[in] ChildHandle The handle of the child controller to retrieve
83 the name of. This is an optional parameter that
84 may be NULL. It will be NULL for device
85 drivers. It will also be NULL for a bus drivers
86 that wish to retrieve the name of the bus
87 controller. It will not be NULL for a bus
88 driver that wishes to retrieve the name of a
91 @param[in] Language A pointer to a Null-terminated ASCII string
92 array indicating the language. This is the
93 language of the driver name that the caller is
94 requesting, and it must match one of the
95 languages specified in SupportedLanguages. The
96 number of languages supported by a driver is up
97 to the driver writer. Language is specified in
98 RFC 4646 or ISO 639-2 language code format.
100 @param[out] ControllerName A pointer to the Unicode string to return.
101 This Unicode string is the name of the
102 controller specified by ControllerHandle and
103 ChildHandle in the language specified by
104 Language from the point of view of the driver
107 @retval EFI_SUCCESS The Unicode string for the user readable name in
108 the language specified by Language for the
109 driver specified by This was returned in
112 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
114 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
117 @retval EFI_INVALID_PARAMETER Language is NULL.
119 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
121 @retval EFI_UNSUPPORTED The driver specified by This is not currently
122 managing the controller specified by
123 ControllerHandle and ChildHandle.
125 @retval EFI_UNSUPPORTED The driver specified by This does not support
126 the language specified by Language.
131 DhcpComponentNameGetControllerName (
132 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
133 IN EFI_HANDLE ControllerHandle
,
134 IN EFI_HANDLE ChildHandle OPTIONAL
,
136 OUT CHAR16
**ControllerName
140 // EFI Component Name Protocol
142 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName
= {
143 DhcpComponentNameGetDriverName
,
144 DhcpComponentNameGetControllerName
,
149 // EFI Component Name 2 Protocol
151 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2
= {
152 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)DhcpComponentNameGetDriverName
,
153 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)DhcpComponentNameGetControllerName
,
157 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable
[] = {
160 L
"DHCP Protocol Driver"
168 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gDhcpControllerNameTable
= NULL
;
170 CHAR16
*mDhcp4ControllerName
[] = {
171 L
"DHCPv4 (State=0, Stopped)",
172 L
"DHCPv4 (State=1, Init)",
173 L
"DHCPv4 (State=2, Selecting)",
174 L
"DHCPv4 (State=3, Requesting)",
175 L
"DHCPv4 (State=4, Bound)",
176 L
"DHCPv4 (State=5, Renewing)",
177 L
"DHCPv4 (State=6, Rebinding)",
178 L
"DHCPv4 (State=7, InitReboot)",
179 L
"DHCPv4 (State=8, Rebooting)"
183 Retrieves a Unicode string that is the user readable name of the driver.
185 This function retrieves the user readable name of a driver in the form of a
186 Unicode string. If the driver specified by This has a user readable name in
187 the language specified by Language, then a pointer to the driver name is
188 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
189 by This does not support the language specified by Language,
190 then EFI_UNSUPPORTED is returned.
192 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
193 EFI_COMPONENT_NAME_PROTOCOL instance.
195 @param[in] Language A pointer to a Null-terminated ASCII string
196 array indicating the language. This is the
197 language of the driver name that the caller is
198 requesting, and it must match one of the
199 languages specified in SupportedLanguages. The
200 number of languages supported by a driver is up
201 to the driver writer. Language is specified
202 in RFC 4646 or ISO 639-2 language code format.
204 @param[out] DriverName A pointer to the Unicode string to return.
205 This Unicode string is the name of the
206 driver specified by This in the language
207 specified by Language.
209 @retval EFI_SUCCESS The Unicode string for the Driver specified by
210 This and the language specified by Language was
211 returned in DriverName.
213 @retval EFI_INVALID_PARAMETER Language is NULL.
215 @retval EFI_INVALID_PARAMETER DriverName is NULL.
217 @retval EFI_UNSUPPORTED The driver specified by This does not support
218 the language specified by Language.
223 DhcpComponentNameGetDriverName (
224 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
226 OUT CHAR16
**DriverName
229 return LookupUnicodeString2 (
231 This
->SupportedLanguages
,
232 mDhcpDriverNameTable
,
234 (BOOLEAN
)(This
== &gDhcp4ComponentName
)
239 Update the component name for the Dhcp4 child handle.
241 @param Dhcp4[in] A pointer to the EFI_DHCP4_PROTOCOL.
244 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
245 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
246 @retval EFI_DEVICE_ERROR DHCP is in unknown state.
251 IN EFI_DHCP4_PROTOCOL
*Dhcp4
255 EFI_DHCP4_MODE_DATA Dhcp4ModeData
;
258 return EFI_INVALID_PARAMETER
;
262 // Format the child name into the string buffer.
264 Status
= Dhcp4
->GetModeData (Dhcp4
, &Dhcp4ModeData
);
265 if (EFI_ERROR (Status
)) {
269 if (gDhcpControllerNameTable
!= NULL
) {
270 FreeUnicodeStringTable (gDhcpControllerNameTable
);
271 gDhcpControllerNameTable
= NULL
;
274 if (Dhcp4ModeData
.State
> Dhcp4Rebooting
) {
275 return EFI_DEVICE_ERROR
;
278 Status
= AddUnicodeString2 (
280 gDhcp4ComponentName
.SupportedLanguages
,
281 &gDhcpControllerNameTable
,
282 mDhcp4ControllerName
[Dhcp4ModeData
.State
],
285 if (EFI_ERROR (Status
)) {
289 return AddUnicodeString2 (
291 gDhcp4ComponentName2
.SupportedLanguages
,
292 &gDhcpControllerNameTable
,
293 mDhcp4ControllerName
[Dhcp4ModeData
.State
],
299 Retrieves a Unicode string that is the user readable name of the controller
300 that is being managed by a driver.
302 This function retrieves the user readable name of the controller specified by
303 ControllerHandle and ChildHandle in the form of a Unicode string. If the
304 driver specified by This has a user readable name in the language specified by
305 Language, then a pointer to the controller name is returned in ControllerName,
306 and EFI_SUCCESS is returned. If the driver specified by This is not currently
307 managing the controller specified by ControllerHandle and ChildHandle,
308 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
309 support the language specified by Language, then EFI_UNSUPPORTED is returned.
311 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
312 EFI_COMPONENT_NAME_PROTOCOL instance.
314 @param[in] ControllerHandle The handle of a controller that the driver
315 specified by This is managing. This handle
316 specifies the controller whose name is to be
319 @param[in] ChildHandle The handle of the child controller to retrieve
320 the name of. This is an optional parameter that
321 may be NULL. It will be NULL for device
322 drivers. It will also be NULL for a bus drivers
323 that wish to retrieve the name of the bus
324 controller. It will not be NULL for a bus
325 driver that wishes to retrieve the name of a
328 @param[in] Language A pointer to a Null-terminated ASCII string
329 array indicating the language. This is the
330 language of the driver name that the caller is
331 requesting, and it must match one of the
332 languages specified in SupportedLanguages. The
333 number of languages supported by a driver is up
334 to the driver writer. Language is specified in
335 RFC 4646 or ISO 639-2 language code format.
337 @param[out] ControllerName A pointer to the Unicode string to return.
338 This Unicode string is the name of the
339 controller specified by ControllerHandle and
340 ChildHandle in the language specified by
341 Language from the point of view of the driver
344 @retval EFI_SUCCESS The Unicode string for the user readable name in
345 the language specified by Language for the
346 driver specified by This was returned in
349 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
351 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
354 @retval EFI_INVALID_PARAMETER Language is NULL.
356 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
358 @retval EFI_UNSUPPORTED The driver specified by This is not currently
359 managing the controller specified by
360 ControllerHandle and ChildHandle.
362 @retval EFI_UNSUPPORTED The driver specified by This does not support
363 the language specified by Language.
368 DhcpComponentNameGetControllerName (
369 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
370 IN EFI_HANDLE ControllerHandle
,
371 IN EFI_HANDLE ChildHandle OPTIONAL
,
373 OUT CHAR16
**ControllerName
377 EFI_DHCP4_PROTOCOL
*Dhcp4
;
380 // Only provide names for child handles.
382 if (ChildHandle
== NULL
) {
383 return EFI_UNSUPPORTED
;
387 // Make sure this driver produced ChildHandle
389 Status
= EfiTestChildHandle (
392 &gEfiUdp4ProtocolGuid
394 if (EFI_ERROR (Status
)) {
399 // Retrieve an instance of a produced protocol from ChildHandle
401 Status
= gBS
->OpenProtocol (
403 &gEfiDhcp4ProtocolGuid
,
407 EFI_OPEN_PROTOCOL_GET_PROTOCOL
409 if (EFI_ERROR (Status
)) {
414 // Update the component name for this child handle.
416 Status
= UpdateName (Dhcp4
);
417 if (EFI_ERROR (Status
)) {
421 return LookupUnicodeString2 (
423 This
->SupportedLanguages
,
424 gDhcpControllerNameTable
,
426 (BOOLEAN
)(This
== &gDhcp4ComponentName
)