3 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "Dhcp4Impl.h"
18 // EFI Component Name Functions
21 Retrieves a Unicode string that is the user readable name of the driver.
23 This function retrieves the user readable name of a driver in the form of a
24 Unicode string. If the driver specified by This has a user readable name in
25 the language specified by Language, then a pointer to the driver name is
26 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
27 by This does not support the language specified by Language,
28 then EFI_UNSUPPORTED is returned.
30 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
31 EFI_COMPONENT_NAME_PROTOCOL instance.
33 @param[in] Language A pointer to a Null-terminated ASCII string
34 array indicating the language. This is the
35 language of the driver name that the caller is
36 requesting, and it must match one of the
37 languages specified in SupportedLanguages. The
38 number of languages supported by a driver is up
39 to the driver writer. Language is specified
40 in RFC 4646 or ISO 639-2 language code format.
42 @param[out] DriverName A pointer to the Unicode string to return.
43 This Unicode string is the name of the
44 driver specified by This in the language
45 specified by Language.
47 @retval EFI_SUCCESS The Unicode string for the Driver specified by
48 This and the language specified by Language was
49 returned in DriverName.
51 @retval EFI_INVALID_PARAMETER Language is NULL.
53 @retval EFI_INVALID_PARAMETER DriverName is NULL.
55 @retval EFI_UNSUPPORTED The driver specified by This does not support
56 the language specified by Language.
61 DhcpComponentNameGetDriverName (
62 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
64 OUT CHAR16
**DriverName
69 Retrieves a Unicode string that is the user readable name of the controller
70 that is being managed by a driver.
72 This function retrieves the user readable name of the controller specified by
73 ControllerHandle and ChildHandle in the form of a Unicode string. If the
74 driver specified by This has a user readable name in the language specified by
75 Language, then a pointer to the controller name is returned in ControllerName,
76 and EFI_SUCCESS is returned. If the driver specified by This is not currently
77 managing the controller specified by ControllerHandle and ChildHandle,
78 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
79 support the language specified by Language, then EFI_UNSUPPORTED is returned.
81 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
82 EFI_COMPONENT_NAME_PROTOCOL instance.
84 @param[in] ControllerHandle The handle of a controller that the driver
85 specified by This is managing. This handle
86 specifies the controller whose name is to be
89 @param[in] ChildHandle The handle of the child controller to retrieve
90 the name of. This is an optional parameter that
91 may be NULL. It will be NULL for device
92 drivers. It will also be NULL for a bus drivers
93 that wish to retrieve the name of the bus
94 controller. It will not be NULL for a bus
95 driver that wishes to retrieve the name of a
98 @param[in] Language A pointer to a Null-terminated ASCII string
99 array indicating the language. This is the
100 language of the driver name that the caller is
101 requesting, and it must match one of the
102 languages specified in SupportedLanguages. The
103 number of languages supported by a driver is up
104 to the driver writer. Language is specified in
105 RFC 4646 or ISO 639-2 language code format.
107 @param[out] ControllerName A pointer to the Unicode string to return.
108 This Unicode string is the name of the
109 controller specified by ControllerHandle and
110 ChildHandle in the language specified by
111 Language from the point of view of the driver
114 @retval EFI_SUCCESS The Unicode string for the user readable name in
115 the language specified by Language for the
116 driver specified by This was returned in
119 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
121 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
124 @retval EFI_INVALID_PARAMETER Language is NULL.
126 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
128 @retval EFI_UNSUPPORTED The driver specified by This is not currently
129 managing the controller specified by
130 ControllerHandle and ChildHandle.
132 @retval EFI_UNSUPPORTED The driver specified by This does not support
133 the language specified by Language.
138 DhcpComponentNameGetControllerName (
139 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
140 IN EFI_HANDLE ControllerHandle
,
141 IN EFI_HANDLE ChildHandle OPTIONAL
,
143 OUT CHAR16
**ControllerName
148 // EFI Component Name Protocol
150 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName
= {
151 DhcpComponentNameGetDriverName
,
152 DhcpComponentNameGetControllerName
,
157 // EFI Component Name 2 Protocol
159 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2
= {
160 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) DhcpComponentNameGetDriverName
,
161 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) DhcpComponentNameGetControllerName
,
166 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable
[] = {
169 L
"DHCP Protocol Driver"
177 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gDhcpControllerNameTable
= NULL
;
179 CHAR16
*mDhcp4ControllerName
[] = {
180 L
"DHCPv4 (State=0, Stopped)",
181 L
"DHCPv4 (State=1, Init)",
182 L
"DHCPv4 (State=2, Selecting)",
183 L
"DHCPv4 (State=3, Requesting)",
184 L
"DHCPv4 (State=4, Bound)",
185 L
"DHCPv4 (State=5, Renewing)",
186 L
"DHCPv4 (State=6, Rebinding)",
187 L
"DHCPv4 (State=7, InitReboot)",
188 L
"DHCPv4 (State=8, Rebooting)"
192 Retrieves a Unicode string that is the user readable name of the driver.
194 This function retrieves the user readable name of a driver in the form of a
195 Unicode string. If the driver specified by This has a user readable name in
196 the language specified by Language, then a pointer to the driver name is
197 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
198 by This does not support the language specified by Language,
199 then EFI_UNSUPPORTED is returned.
201 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
202 EFI_COMPONENT_NAME_PROTOCOL instance.
204 @param[in] Language A pointer to a Null-terminated ASCII string
205 array indicating the language. This is the
206 language of the driver name that the caller is
207 requesting, and it must match one of the
208 languages specified in SupportedLanguages. The
209 number of languages supported by a driver is up
210 to the driver writer. Language is specified
211 in RFC 4646 or ISO 639-2 language code format.
213 @param[out] DriverName A pointer to the Unicode string to return.
214 This Unicode string is the name of the
215 driver specified by This in the language
216 specified by Language.
218 @retval EFI_SUCCESS The Unicode string for the Driver specified by
219 This and the language specified by Language was
220 returned in DriverName.
222 @retval EFI_INVALID_PARAMETER Language is NULL.
224 @retval EFI_INVALID_PARAMETER DriverName is NULL.
226 @retval EFI_UNSUPPORTED The driver specified by This does not support
227 the language specified by Language.
232 DhcpComponentNameGetDriverName (
233 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
235 OUT CHAR16
**DriverName
238 return LookupUnicodeString2 (
240 This
->SupportedLanguages
,
241 mDhcpDriverNameTable
,
243 (BOOLEAN
)(This
== &gDhcp4ComponentName
)
248 Update the component name for the Dhcp4 child handle.
250 @param Dhcp4[in] A pointer to the EFI_DHCP4_PROTOCOL.
253 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
254 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
255 @retval EFI_DEVICE_ERROR DHCP is in unknown state.
260 IN EFI_DHCP4_PROTOCOL
*Dhcp4
264 EFI_DHCP4_MODE_DATA Dhcp4ModeData
;
267 return EFI_INVALID_PARAMETER
;
271 // Format the child name into the string buffer.
273 Status
= Dhcp4
->GetModeData (Dhcp4
, &Dhcp4ModeData
);
274 if (EFI_ERROR (Status
)) {
278 if (gDhcpControllerNameTable
!= NULL
) {
279 FreeUnicodeStringTable (gDhcpControllerNameTable
);
280 gDhcpControllerNameTable
= NULL
;
283 if (Dhcp4ModeData
.State
> Dhcp4Rebooting
) {
284 return EFI_DEVICE_ERROR
;
287 Status
= AddUnicodeString2 (
289 gDhcp4ComponentName
.SupportedLanguages
,
290 &gDhcpControllerNameTable
,
291 mDhcp4ControllerName
[Dhcp4ModeData
.State
],
294 if (EFI_ERROR (Status
)) {
298 return AddUnicodeString2 (
300 gDhcp4ComponentName2
.SupportedLanguages
,
301 &gDhcpControllerNameTable
,
302 mDhcp4ControllerName
[Dhcp4ModeData
.State
],
308 Retrieves a Unicode string that is the user readable name of the controller
309 that is being managed by a driver.
311 This function retrieves the user readable name of the controller specified by
312 ControllerHandle and ChildHandle in the form of a Unicode string. If the
313 driver specified by This has a user readable name in the language specified by
314 Language, then a pointer to the controller name is returned in ControllerName,
315 and EFI_SUCCESS is returned. If the driver specified by This is not currently
316 managing the controller specified by ControllerHandle and ChildHandle,
317 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
318 support the language specified by Language, then EFI_UNSUPPORTED is returned.
320 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
321 EFI_COMPONENT_NAME_PROTOCOL instance.
323 @param[in] ControllerHandle The handle of a controller that the driver
324 specified by This is managing. This handle
325 specifies the controller whose name is to be
328 @param[in] ChildHandle The handle of the child controller to retrieve
329 the name of. This is an optional parameter that
330 may be NULL. It will be NULL for device
331 drivers. It will also be NULL for a bus drivers
332 that wish to retrieve the name of the bus
333 controller. It will not be NULL for a bus
334 driver that wishes to retrieve the name of a
337 @param[in] Language A pointer to a Null-terminated ASCII string
338 array indicating the language. This is the
339 language of the driver name that the caller is
340 requesting, and it must match one of the
341 languages specified in SupportedLanguages. The
342 number of languages supported by a driver is up
343 to the driver writer. Language is specified in
344 RFC 4646 or ISO 639-2 language code format.
346 @param[out] ControllerName A pointer to the Unicode string to return.
347 This Unicode string is the name of the
348 controller specified by ControllerHandle and
349 ChildHandle in the language specified by
350 Language from the point of view of the driver
353 @retval EFI_SUCCESS The Unicode string for the user readable name in
354 the language specified by Language for the
355 driver specified by This was returned in
358 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
360 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
363 @retval EFI_INVALID_PARAMETER Language is NULL.
365 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
367 @retval EFI_UNSUPPORTED The driver specified by This is not currently
368 managing the controller specified by
369 ControllerHandle and ChildHandle.
371 @retval EFI_UNSUPPORTED The driver specified by This does not support
372 the language specified by Language.
377 DhcpComponentNameGetControllerName (
378 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
379 IN EFI_HANDLE ControllerHandle
,
380 IN EFI_HANDLE ChildHandle OPTIONAL
,
382 OUT CHAR16
**ControllerName
386 EFI_DHCP4_PROTOCOL
*Dhcp4
;
389 // Only provide names for child handles.
391 if (ChildHandle
== NULL
) {
392 return EFI_UNSUPPORTED
;
396 // Make sure this driver produced ChildHandle
398 Status
= EfiTestChildHandle (
401 &gEfiUdp4ProtocolGuid
403 if (EFI_ERROR (Status
)) {
408 // Retrieve an instance of a produced protocol from ChildHandle
410 Status
= gBS
->OpenProtocol (
412 &gEfiDhcp4ProtocolGuid
,
416 EFI_OPEN_PROTOCOL_GET_PROTOCOL
418 if (EFI_ERROR (Status
)) {
423 // Update the component name for this child handle.
425 Status
= UpdateName (Dhcp4
);
426 if (EFI_ERROR (Status
)) {
430 return LookupUnicodeString2 (
432 This
->SupportedLanguages
,
433 gDhcpControllerNameTable
,
435 (BOOLEAN
)(This
== &gDhcp4ComponentName
)