3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. 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.
23 // PXE DHCP Protocol Interface
25 EFI_DRIVER_BINDING_PROTOCOL gPxeDhcp4DriverBinding
= {
26 PxeDhcp4DriverBindingSupported
,
27 PxeDhcp4DriverBindingStart
,
28 PxeDhcp4DriverBindingStop
,
34 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37 PxeDhcp4DriverBindingSupported (
38 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
39 IN EFI_HANDLE ControllerHandle
,
40 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
45 Test to see if this driver supports ControllerHandle. Any
46 ControllerHandle that contains a PxeBaseCode protocol can be
50 This - Protocol instance pointer.
51 ControllerHandle - Handle of device to test.
52 RemainingDevicePath - Not used.
55 EFI_SUCCESS - This driver supports this device.
56 EFI_ALREADY_STARTED - This driver is already running on this
58 other - This driver does not support this device.
63 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
66 // Open the IO Abstraction(s) needed to perform the supported test.
68 Status
= gBS
->OpenProtocol (
70 &gEfiPxeBaseCodeProtocolGuid
,
72 This
->DriverBindingHandle
,
74 EFI_OPEN_PROTOCOL_BY_DRIVER
77 if (EFI_ERROR (Status
)) {
81 // Close the I/O Abstraction(s) used to perform the supported test.
83 return gBS
->CloseProtocol (
85 &gEfiPxeBaseCodeProtocolGuid
,
86 This
->DriverBindingHandle
,
91 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
94 PxeDhcp4DriverBindingStart (
95 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
96 IN EFI_HANDLE ControllerHandle
,
97 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
102 Start this driver on ControllerHandle by opening a PxeBaseCode
103 protocol and installing a PxeDhcp4 protocol on ControllerHandle.
106 This - Protocol instance pointer.
107 ControllerHandle - Handle of device to bind driver to.
108 RemainingDevicePath - Not used, always produce all possible
112 EFI_SUCCESS - This driver is added to ControllerHandle.
113 EFI_ALREADY_STARTED - This driver is already running on
115 other - This driver does not support this device.
120 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
121 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
122 PXE_DHCP4_PRIVATE_DATA
*Private
;
125 // Connect to the PxeBaseCode interface on ControllerHandle.
127 Status
= gBS
->OpenProtocol (
129 &gEfiPxeBaseCodeProtocolGuid
,
131 This
->DriverBindingHandle
,
133 EFI_OPEN_PROTOCOL_BY_DRIVER
136 if (EFI_ERROR (Status
)) {
140 // BaseCode has already grabbed the SimpleNetwork interface
141 // so just do a HandleProtocol() to get it.
143 Status
= gBS
->HandleProtocol (
145 &gEfiSimpleNetworkProtocolGuid
,
149 if (EFI_ERROR (Status
)) {
156 // Initialize the PXE DHCP device instance.
158 Private
= AllocateZeroPool (sizeof (PXE_DHCP4_PRIVATE_DATA
));
159 if (Private
== NULL
) {
160 Status
= EFI_OUT_OF_RESOURCES
;
164 Private
->Signature
= PXE_DHCP4_PRIVATE_DATA_SIGNATURE
;
165 Private
->PxeBc
= PxeBc
;
167 Private
->Handle
= ControllerHandle
;
168 Private
->PxeDhcp4
.Revision
= EFI_PXE_DHCP4_PROTOCOL_REVISION
;
169 Private
->PxeDhcp4
.Run
= PxeDhcp4Run
;
170 Private
->PxeDhcp4
.Setup
= PxeDhcp4Setup
;
171 Private
->PxeDhcp4
.Init
= PxeDhcp4Init
;
172 Private
->PxeDhcp4
.Select
= PxeDhcp4Select
;
173 Private
->PxeDhcp4
.Renew
= PxeDhcp4Renew
;
174 Private
->PxeDhcp4
.Rebind
= PxeDhcp4Rebind
;
175 Private
->PxeDhcp4
.Release
= PxeDhcp4Release
;
176 Private
->PxeDhcp4
.Data
= NULL
;
179 // Install protocol interfaces for the PXE DHCP device.
181 Status
= gBS
->InstallProtocolInterface (
183 &gEfiPxeDhcp4ProtocolGuid
,
184 EFI_NATIVE_INTERFACE
,
188 if (!EFI_ERROR (Status
)) {
195 &gEfiPxeBaseCodeProtocolGuid
,
196 This
->DriverBindingHandle
,
203 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
206 PxeDhcp4DriverBindingStop (
207 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
208 IN EFI_HANDLE ControllerHandle
,
209 IN UINTN NumberOfChildren
,
210 IN EFI_HANDLE
*ChildHandleBuffer
215 Stop this driver on ControllerHandle by removing PXE DHCP
216 protocol and closing the PXE Base Code protocol on
220 This - Protocol instance pointer.
221 ControllerHandle - Handle of device to stop driver on.
222 NumberOfChildren - Not used.
223 ChildHandleBuffer - Not used.
226 EFI_SUCCESS - This driver is removed ControllerHandle.
227 other - This driver was not removed from this
233 EFI_PXE_DHCP4_PROTOCOL
*PxeDhcp4
;
234 PXE_DHCP4_PRIVATE_DATA
*Private
;
237 // Get our context back.
239 Status
= gBS
->OpenProtocol (
241 &gEfiPxeDhcp4ProtocolGuid
,
243 This
->DriverBindingHandle
,
245 EFI_OPEN_PROTOCOL_GET_PROTOCOL
248 if (EFI_ERROR (Status
)) {
249 return EFI_UNSUPPORTED
;
252 Private
= PXE_DHCP4_PRIVATE_DATA_FROM_THIS (PxeDhcp4
);
255 // Release allocated resources
257 if (Private
->PxeDhcp4
.Data
) {
258 FreePool (Private
->PxeDhcp4
.Data
);
259 Private
->PxeDhcp4
.Data
= NULL
;
262 // Uninstall our protocol
264 Status
= gBS
->UninstallProtocolInterface (
266 &gEfiPxeDhcp4ProtocolGuid
,
270 if (EFI_ERROR (Status
)) {
274 // Close any consumed protocols
276 Status
= gBS
->CloseProtocol (
278 &gEfiPxeBaseCodeProtocolGuid
,
279 This
->DriverBindingHandle
,
283 if (EFI_ERROR (Status
)) {
287 // Release our private data
294 /* EOF - PxeDhcp4.c */