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.
22 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
26 // Driver model protocol interface
30 PxeDhcp4DriverEntryPoint (
31 IN EFI_HANDLE ImageHandle
,
32 IN EFI_SYSTEM_TABLE
*SystemTable
37 PxeDhcp4DriverBindingSupported (
38 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
39 IN EFI_HANDLE ControllerHandle
,
40 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
45 PxeDhcp4DriverBindingStart (
46 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
47 IN EFI_HANDLE ControllerHandle
,
48 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
53 PxeDhcp4DriverBindingStop (
54 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
55 IN EFI_HANDLE ControllerHandle
,
56 IN UINTN NumberOfChildren
,
57 IN EFI_HANDLE
*ChildHandleBuffer
60 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
63 // PXE DHCP Protocol Interface
65 EFI_DRIVER_BINDING_PROTOCOL gPxeDhcp4DriverBinding
= {
66 PxeDhcp4DriverBindingSupported
,
67 PxeDhcp4DriverBindingStart
,
68 PxeDhcp4DriverBindingStop
,
74 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
77 PxeDhcp4DriverBindingSupported (
78 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
79 IN EFI_HANDLE ControllerHandle
,
80 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
85 Test to see if this driver supports ControllerHandle. Any
86 ControllerHandle that contains a PxeBaseCode protocol can be
90 This - Protocol instance pointer.
91 ControllerHandle - Handle of device to test.
92 RemainingDevicePath - Not used.
95 EFI_SUCCESS - This driver supports this device.
96 EFI_ALREADY_STARTED - This driver is already running on this
98 other - This driver does not support this device.
103 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
106 // Open the IO Abstraction(s) needed to perform the supported test.
108 Status
= gBS
->OpenProtocol (
110 &gEfiPxeBaseCodeProtocolGuid
,
112 This
->DriverBindingHandle
,
114 EFI_OPEN_PROTOCOL_BY_DRIVER
117 if (EFI_ERROR (Status
)) {
121 // Close the I/O Abstraction(s) used to perform the supported test.
123 return gBS
->CloseProtocol (
125 &gEfiPxeBaseCodeProtocolGuid
,
126 This
->DriverBindingHandle
,
131 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
134 PxeDhcp4DriverBindingStart (
135 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
136 IN EFI_HANDLE ControllerHandle
,
137 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
142 Start this driver on ControllerHandle by opening a PxeBaseCode
143 protocol and installing a PxeDhcp4 protocol on ControllerHandle.
146 This - Protocol instance pointer.
147 ControllerHandle - Handle of device to bind driver to.
148 RemainingDevicePath - Not used, always produce all possible
152 EFI_SUCCESS - This driver is added to ControllerHandle.
153 EFI_ALREADY_STARTED - This driver is already running on
155 other - This driver does not support this device.
160 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
161 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
162 PXE_DHCP4_PRIVATE_DATA
*Private
;
165 // Connect to the PxeBaseCode interface on ControllerHandle.
167 Status
= gBS
->OpenProtocol (
169 &gEfiPxeBaseCodeProtocolGuid
,
171 This
->DriverBindingHandle
,
173 EFI_OPEN_PROTOCOL_BY_DRIVER
176 if (EFI_ERROR (Status
)) {
180 // BaseCode has already grabbed the SimpleNetwork interface
181 // so just do a HandleProtocol() to get it.
183 Status
= gBS
->HandleProtocol (
185 &gEfiSimpleNetworkProtocolGuid
,
189 if (EFI_ERROR (Status
)) {
196 // Initialize the PXE DHCP device instance.
198 Status
= gBS
->AllocatePool (
200 sizeof (PXE_DHCP4_PRIVATE_DATA
),
204 if (EFI_ERROR (Status
)) {
210 ZeroMem (Private
, sizeof (PXE_DHCP4_PRIVATE_DATA
));
212 Private
->Signature
= PXE_DHCP4_PRIVATE_DATA_SIGNATURE
;
213 Private
->PxeBc
= PxeBc
;
215 Private
->Handle
= ControllerHandle
;
216 Private
->PxeDhcp4
.Revision
= EFI_PXE_DHCP4_PROTOCOL_REVISION
;
217 Private
->PxeDhcp4
.Run
= PxeDhcp4Run
;
218 Private
->PxeDhcp4
.Setup
= PxeDhcp4Setup
;
219 Private
->PxeDhcp4
.Init
= PxeDhcp4Init
;
220 Private
->PxeDhcp4
.Select
= PxeDhcp4Select
;
221 Private
->PxeDhcp4
.Renew
= PxeDhcp4Renew
;
222 Private
->PxeDhcp4
.Rebind
= PxeDhcp4Rebind
;
223 Private
->PxeDhcp4
.Release
= PxeDhcp4Release
;
224 Private
->PxeDhcp4
.Data
= NULL
;
227 // Install protocol interfaces for the PXE DHCP device.
229 Status
= gBS
->InstallProtocolInterface (
231 &gEfiPxeDhcp4ProtocolGuid
,
232 EFI_NATIVE_INTERFACE
,
236 if (!EFI_ERROR (Status
)) {
243 &gEfiPxeBaseCodeProtocolGuid
,
244 This
->DriverBindingHandle
,
251 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
254 PxeDhcp4DriverBindingStop (
255 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
256 IN EFI_HANDLE ControllerHandle
,
257 IN UINTN NumberOfChildren
,
258 IN EFI_HANDLE
*ChildHandleBuffer
263 Stop this driver on ControllerHandle by removing PXE DHCP
264 protocol and closing the PXE Base Code protocol on
268 This - Protocol instance pointer.
269 ControllerHandle - Handle of device to stop driver on.
270 NumberOfChildren - Not used.
271 ChildHandleBuffer - Not used.
274 EFI_SUCCESS - This driver is removed ControllerHandle.
275 other - This driver was not removed from this
281 EFI_PXE_DHCP4_PROTOCOL
*PxeDhcp4
;
282 PXE_DHCP4_PRIVATE_DATA
*Private
;
285 // Get our context back.
287 Status
= gBS
->OpenProtocol (
289 &gEfiPxeDhcp4ProtocolGuid
,
291 This
->DriverBindingHandle
,
293 EFI_OPEN_PROTOCOL_GET_PROTOCOL
296 if (EFI_ERROR (Status
)) {
297 return EFI_UNSUPPORTED
;
300 Private
= PXE_DHCP4_PRIVATE_DATA_FROM_THIS (PxeDhcp4
);
303 // Release allocated resources
305 if (Private
->PxeDhcp4
.Data
) {
306 gBS
->FreePool (Private
->PxeDhcp4
.Data
);
307 Private
->PxeDhcp4
.Data
= NULL
;
310 // Uninstall our protocol
312 Status
= gBS
->UninstallProtocolInterface (
314 &gEfiPxeDhcp4ProtocolGuid
,
318 if (EFI_ERROR (Status
)) {
322 // Close any consumed protocols
324 Status
= gBS
->CloseProtocol (
326 &gEfiPxeBaseCodeProtocolGuid
,
327 This
->DriverBindingHandle
,
331 if (EFI_ERROR (Status
)) {
335 // Release our private data
337 gBS
->FreePool (Private
);
342 /* EOF - PxeDhcp4.c */