3 Copyright (c) 2006, 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 Status
= gBS
->AllocatePool (
160 sizeof (PXE_DHCP4_PRIVATE_DATA
),
164 if (EFI_ERROR (Status
)) {
170 ZeroMem (Private
, sizeof (PXE_DHCP4_PRIVATE_DATA
));
172 Private
->Signature
= PXE_DHCP4_PRIVATE_DATA_SIGNATURE
;
173 Private
->PxeBc
= PxeBc
;
175 Private
->Handle
= ControllerHandle
;
176 Private
->PxeDhcp4
.Revision
= EFI_PXE_DHCP4_PROTOCOL_REVISION
;
177 Private
->PxeDhcp4
.Run
= PxeDhcp4Run
;
178 Private
->PxeDhcp4
.Setup
= PxeDhcp4Setup
;
179 Private
->PxeDhcp4
.Init
= PxeDhcp4Init
;
180 Private
->PxeDhcp4
.Select
= PxeDhcp4Select
;
181 Private
->PxeDhcp4
.Renew
= PxeDhcp4Renew
;
182 Private
->PxeDhcp4
.Rebind
= PxeDhcp4Rebind
;
183 Private
->PxeDhcp4
.Release
= PxeDhcp4Release
;
184 Private
->PxeDhcp4
.Data
= NULL
;
187 // Install protocol interfaces for the PXE DHCP device.
189 Status
= gBS
->InstallProtocolInterface (
191 &gEfiPxeDhcp4ProtocolGuid
,
192 EFI_NATIVE_INTERFACE
,
196 if (!EFI_ERROR (Status
)) {
203 &gEfiPxeBaseCodeProtocolGuid
,
204 This
->DriverBindingHandle
,
211 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
214 PxeDhcp4DriverBindingStop (
215 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
216 IN EFI_HANDLE ControllerHandle
,
217 IN UINTN NumberOfChildren
,
218 IN EFI_HANDLE
*ChildHandleBuffer
223 Stop this driver on ControllerHandle by removing PXE DHCP
224 protocol and closing the PXE Base Code protocol on
228 This - Protocol instance pointer.
229 ControllerHandle - Handle of device to stop driver on.
230 NumberOfChildren - Not used.
231 ChildHandleBuffer - Not used.
234 EFI_SUCCESS - This driver is removed ControllerHandle.
235 other - This driver was not removed from this
241 EFI_PXE_DHCP4_PROTOCOL
*PxeDhcp4
;
242 PXE_DHCP4_PRIVATE_DATA
*Private
;
245 // Get our context back.
247 Status
= gBS
->OpenProtocol (
249 &gEfiPxeDhcp4ProtocolGuid
,
251 This
->DriverBindingHandle
,
253 EFI_OPEN_PROTOCOL_GET_PROTOCOL
256 if (EFI_ERROR (Status
)) {
257 return EFI_UNSUPPORTED
;
260 Private
= PXE_DHCP4_PRIVATE_DATA_FROM_THIS (PxeDhcp4
);
263 // Release allocated resources
265 if (Private
->PxeDhcp4
.Data
) {
266 gBS
->FreePool (Private
->PxeDhcp4
.Data
);
267 Private
->PxeDhcp4
.Data
= NULL
;
270 // Uninstall our protocol
272 Status
= gBS
->UninstallProtocolInterface (
274 &gEfiPxeDhcp4ProtocolGuid
,
278 if (EFI_ERROR (Status
)) {
282 // Close any consumed protocols
284 Status
= gBS
->CloseProtocol (
286 &gEfiPxeBaseCodeProtocolGuid
,
287 This
->DriverBindingHandle
,
291 if (EFI_ERROR (Status
)) {
295 // Release our private data
297 gBS
->FreePool (Private
);
302 /* EOF - PxeDhcp4.c */