3 Copyright (c) 2004 - 2005, 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 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
27 // Driver model protocol interface
31 PxeDhcp4DriverEntryPoint (
32 IN EFI_HANDLE ImageHandle
,
33 IN EFI_SYSTEM_TABLE
*SystemTable
38 PxeDhcp4DriverBindingSupported (
39 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
40 IN EFI_HANDLE ControllerHandle
,
41 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
46 PxeDhcp4DriverBindingStart (
47 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
48 IN EFI_HANDLE ControllerHandle
,
49 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
54 PxeDhcp4DriverBindingStop (
55 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
56 IN EFI_HANDLE ControllerHandle
,
57 IN UINTN NumberOfChildren
,
58 IN EFI_HANDLE
*ChildHandleBuffer
61 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
64 // PXE DHCP Protocol Interface
66 EFI_DRIVER_BINDING_PROTOCOL gPxeDhcp4DriverBinding
= {
67 PxeDhcp4DriverBindingSupported
,
68 PxeDhcp4DriverBindingStart
,
69 PxeDhcp4DriverBindingStop
,
75 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
78 // PxeDhcp4 Driver Entry point funtion
82 Register Driver Binding protocol for this driver.
84 @param entry EFI_IMAGE_ENTRY_POINT)
86 @retval EFI_SUCCESS Driver loaded.
87 @retval other Driver not loaded.
92 PxeDhcp4DriverEntryPoint (
93 IN EFI_HANDLE ImageHandle
,
94 IN EFI_SYSTEM_TABLE
*SystemTable
97 return EfiLibInstallAllDriverProtocols (
100 &gPxeDhcp4DriverBinding
,
108 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
111 Test to see if this driver supports ControllerHandle. Any
112 ControllerHandle that contains a PxeBaseCode protocol can be
115 @param This Protocol instance pointer.
116 @param ControllerHandle Handle of device to test.
117 @param RemainingDevicePath Not used.
119 @retval EFI_SUCCESS This driver supports this device.
120 @retval EFI_ALREADY_STARTED This driver is already running on this device.
121 @retval other This driver does not support this device.
126 PxeDhcp4DriverBindingSupported (
127 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
128 IN EFI_HANDLE ControllerHandle
,
129 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
133 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
136 // Open the IO Abstraction(s) needed to perform the supported test.
138 Status
= gBS
->OpenProtocol (
140 &gEfiPxeBaseCodeProtocolGuid
,
142 This
->DriverBindingHandle
,
144 EFI_OPEN_PROTOCOL_BY_DRIVER
147 if (EFI_ERROR (Status
)) {
151 // Close the I/O Abstraction(s) used to perform the supported test.
153 return gBS
->CloseProtocol (
155 &gEfiPxeBaseCodeProtocolGuid
,
156 This
->DriverBindingHandle
,
161 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
164 Start this driver on ControllerHandle by opening a PxeBaseCode
165 protocol and installing a PxeDhcp4 protocol on ControllerHandle.
167 @param This Protocol instance pointer.
168 @param ControllerHandle Handle of device to bind driver to.
169 @param RemainingDevicePath Not used, always produce all possible children.
171 @retval EFI_SUCCESS This driver is added to ControllerHandle.
172 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
173 @retval other This driver does not support this device.
178 PxeDhcp4DriverBindingStart (
179 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
180 IN EFI_HANDLE ControllerHandle
,
181 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
185 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
186 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
187 PXE_DHCP4_PRIVATE_DATA
*Private
;
190 // Connect to the PxeBaseCode interface on ControllerHandle.
192 Status
= gBS
->OpenProtocol (
194 &gEfiPxeBaseCodeProtocolGuid
,
196 This
->DriverBindingHandle
,
198 EFI_OPEN_PROTOCOL_BY_DRIVER
201 if (EFI_ERROR (Status
)) {
205 // BaseCode has already grabbed the SimpleNetwork interface
206 // so just do a HandleProtocol() to get it.
208 Status
= gBS
->HandleProtocol (
210 &gEfiSimpleNetworkProtocolGuid
,
214 if (EFI_ERROR (Status
)) {
221 // Initialize the PXE DHCP device instance.
223 Private
= AllocateZeroPool (sizeof (PXE_DHCP4_PRIVATE_DATA
));
224 if (Private
== NULL
) {
225 Status
= EFI_OUT_OF_RESOURCES
;
229 Private
->Signature
= PXE_DHCP4_PRIVATE_DATA_SIGNATURE
;
230 Private
->PxeBc
= PxeBc
;
232 Private
->Handle
= ControllerHandle
;
233 Private
->PxeDhcp4
.Revision
= EFI_PXE_DHCP4_PROTOCOL_REVISION
;
234 Private
->PxeDhcp4
.Run
= PxeDhcp4Run
;
235 Private
->PxeDhcp4
.Setup
= PxeDhcp4Setup
;
236 Private
->PxeDhcp4
.Init
= PxeDhcp4Init
;
237 Private
->PxeDhcp4
.Select
= PxeDhcp4Select
;
238 Private
->PxeDhcp4
.Renew
= PxeDhcp4Renew
;
239 Private
->PxeDhcp4
.Rebind
= PxeDhcp4Rebind
;
240 Private
->PxeDhcp4
.Release
= PxeDhcp4Release
;
241 Private
->PxeDhcp4
.Data
= NULL
;
244 // Install protocol interfaces for the PXE DHCP device.
246 Status
= gBS
->InstallProtocolInterface (
248 &gEfiPxeDhcp4ProtocolGuid
,
249 EFI_NATIVE_INTERFACE
,
253 if (!EFI_ERROR (Status
)) {
260 &gEfiPxeBaseCodeProtocolGuid
,
261 This
->DriverBindingHandle
,
268 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
271 Stop this driver on ControllerHandle by removing PXE DHCP
272 protocol and closing the PXE Base Code protocol on
275 @param This Protocol instance pointer.
276 @param ControllerHandle Handle of device to stop driver on.
277 @param NumberOfChildren Not used.
278 @param ChildHandleBuffer Not used.
280 @retval EFI_SUCCESS This driver is removed ControllerHandle.
281 @retval other This driver was not removed from this device.
286 PxeDhcp4DriverBindingStop (
287 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
288 IN EFI_HANDLE ControllerHandle
,
289 IN UINTN NumberOfChildren
,
290 IN EFI_HANDLE
*ChildHandleBuffer
294 EFI_PXE_DHCP4_PROTOCOL
*PxeDhcp4
;
295 PXE_DHCP4_PRIVATE_DATA
*Private
;
298 // Get our context back.
300 Status
= gBS
->OpenProtocol (
302 &gEfiPxeDhcp4ProtocolGuid
,
304 This
->DriverBindingHandle
,
306 EFI_OPEN_PROTOCOL_GET_PROTOCOL
309 if (EFI_ERROR (Status
)) {
310 return EFI_UNSUPPORTED
;
313 Private
= PXE_DHCP4_PRIVATE_DATA_FROM_THIS (PxeDhcp4
);
316 // Release allocated resources
318 if (Private
->PxeDhcp4
.Data
) {
319 FreePool (Private
->PxeDhcp4
.Data
);
320 Private
->PxeDhcp4
.Data
= NULL
;
323 // Uninstall our protocol
325 Status
= gBS
->UninstallProtocolInterface (
327 &gEfiPxeDhcp4ProtocolGuid
,
331 if (EFI_ERROR (Status
)) {
335 // Close any consumed protocols
337 Status
= gBS
->CloseProtocol (
339 &gEfiPxeBaseCodeProtocolGuid
,
340 This
->DriverBindingHandle
,
344 if (EFI_ERROR (Status
)) {
348 // Release our private data
355 /* EOF - PxeDhcp4.c */