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 EfiLibInstallDriverBindingComponentName2 (
100 &gPxeDhcp4DriverBinding
,
102 &gPxeDhcp4ComponentName
,
103 &gPxeDhcp4ComponentName2
107 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
110 Test to see if this driver supports ControllerHandle. Any
111 ControllerHandle that contains a PxeBaseCode protocol can be
114 @param This Protocol instance pointer.
115 @param ControllerHandle Handle of device to test.
116 @param RemainingDevicePath Not used.
118 @retval EFI_SUCCESS This driver supports this device.
119 @retval EFI_ALREADY_STARTED This driver is already running on this device.
120 @retval other This driver does not support this device.
125 PxeDhcp4DriverBindingSupported (
126 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
127 IN EFI_HANDLE ControllerHandle
,
128 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
132 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
135 // Open the IO Abstraction(s) needed to perform the supported test.
137 Status
= gBS
->OpenProtocol (
139 &gEfiPxeBaseCodeProtocolGuid
,
141 This
->DriverBindingHandle
,
143 EFI_OPEN_PROTOCOL_BY_DRIVER
146 if (EFI_ERROR (Status
)) {
150 // Close the I/O Abstraction(s) used to perform the supported test.
152 return gBS
->CloseProtocol (
154 &gEfiPxeBaseCodeProtocolGuid
,
155 This
->DriverBindingHandle
,
160 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
163 Start this driver on ControllerHandle by opening a PxeBaseCode
164 protocol and installing a PxeDhcp4 protocol on ControllerHandle.
166 @param This Protocol instance pointer.
167 @param ControllerHandle Handle of device to bind driver to.
168 @param RemainingDevicePath Not used, always produce all possible children.
170 @retval EFI_SUCCESS This driver is added to ControllerHandle.
171 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
172 @retval other This driver does not support this device.
177 PxeDhcp4DriverBindingStart (
178 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
179 IN EFI_HANDLE ControllerHandle
,
180 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
184 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
185 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
186 PXE_DHCP4_PRIVATE_DATA
*Private
;
189 // Connect to the PxeBaseCode interface on ControllerHandle.
191 Status
= gBS
->OpenProtocol (
193 &gEfiPxeBaseCodeProtocolGuid
,
195 This
->DriverBindingHandle
,
197 EFI_OPEN_PROTOCOL_BY_DRIVER
200 if (EFI_ERROR (Status
)) {
204 // BaseCode has already grabbed the SimpleNetwork interface
205 // so just do a HandleProtocol() to get it.
207 Status
= gBS
->HandleProtocol (
209 &gEfiSimpleNetworkProtocolGuid
,
213 if (EFI_ERROR (Status
)) {
220 // Initialize the PXE DHCP device instance.
222 Private
= AllocateZeroPool (sizeof (PXE_DHCP4_PRIVATE_DATA
));
223 if (Private
== NULL
) {
224 Status
= EFI_OUT_OF_RESOURCES
;
228 Private
->Signature
= PXE_DHCP4_PRIVATE_DATA_SIGNATURE
;
229 Private
->PxeBc
= PxeBc
;
231 Private
->Handle
= ControllerHandle
;
232 Private
->PxeDhcp4
.Revision
= EFI_PXE_DHCP4_PROTOCOL_REVISION
;
233 Private
->PxeDhcp4
.Run
= PxeDhcp4Run
;
234 Private
->PxeDhcp4
.Setup
= PxeDhcp4Setup
;
235 Private
->PxeDhcp4
.Init
= PxeDhcp4Init
;
236 Private
->PxeDhcp4
.Select
= PxeDhcp4Select
;
237 Private
->PxeDhcp4
.Renew
= PxeDhcp4Renew
;
238 Private
->PxeDhcp4
.Rebind
= PxeDhcp4Rebind
;
239 Private
->PxeDhcp4
.Release
= PxeDhcp4Release
;
240 Private
->PxeDhcp4
.Data
= NULL
;
243 // Install protocol interfaces for the PXE DHCP device.
245 Status
= gBS
->InstallProtocolInterface (
247 &gEfiPxeDhcp4ProtocolGuid
,
248 EFI_NATIVE_INTERFACE
,
252 if (!EFI_ERROR (Status
)) {
259 &gEfiPxeBaseCodeProtocolGuid
,
260 This
->DriverBindingHandle
,
267 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
270 Stop this driver on ControllerHandle by removing PXE DHCP
271 protocol and closing the PXE Base Code protocol on
274 @param This Protocol instance pointer.
275 @param ControllerHandle Handle of device to stop driver on.
276 @param NumberOfChildren Not used.
277 @param ChildHandleBuffer Not used.
279 @retval EFI_SUCCESS This driver is removed ControllerHandle.
280 @retval other This driver was not removed from this device.
285 PxeDhcp4DriverBindingStop (
286 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
287 IN EFI_HANDLE ControllerHandle
,
288 IN UINTN NumberOfChildren
,
289 IN EFI_HANDLE
*ChildHandleBuffer
293 EFI_PXE_DHCP4_PROTOCOL
*PxeDhcp4
;
294 PXE_DHCP4_PRIVATE_DATA
*Private
;
297 // Get our context back.
299 Status
= gBS
->OpenProtocol (
301 &gEfiPxeDhcp4ProtocolGuid
,
303 This
->DriverBindingHandle
,
305 EFI_OPEN_PROTOCOL_GET_PROTOCOL
308 if (EFI_ERROR (Status
)) {
309 return EFI_UNSUPPORTED
;
312 Private
= PXE_DHCP4_PRIVATE_DATA_FROM_THIS (PxeDhcp4
);
315 // Release allocated resources
317 if (Private
->PxeDhcp4
.Data
) {
318 FreePool (Private
->PxeDhcp4
.Data
);
319 Private
->PxeDhcp4
.Data
= NULL
;
322 // Uninstall our protocol
324 Status
= gBS
->UninstallProtocolInterface (
326 &gEfiPxeDhcp4ProtocolGuid
,
330 if (EFI_ERROR (Status
)) {
334 // Close any consumed protocols
336 Status
= gBS
->CloseProtocol (
338 &gEfiPxeBaseCodeProtocolGuid
,
339 This
->DriverBindingHandle
,
343 if (EFI_ERROR (Status
)) {
347 // Release our private data
354 /* EOF - PxeDhcp4.c */