]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Network/PxeDhcp4/Dxe/PxeDhcp4.c
remove unused PCD
[mirror_edk2.git] / EdkModulePkg / Universal / Network / PxeDhcp4 / Dxe / PxeDhcp4.c
1 /*++
2
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
8
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.
11
12 Module Name:
13 PxeDhcp4.c
14
15 Abstract:
16
17 --*/
18
19
20 #include "PxeDhcp4.h"
21
22 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
23
24 //
25 // Prototypes
26 // Driver model protocol interface
27 //
28 EFI_STATUS
29 EFIAPI
30 PxeDhcp4DriverEntryPoint (
31 IN EFI_HANDLE ImageHandle,
32 IN EFI_SYSTEM_TABLE *SystemTable
33 );
34
35 EFI_STATUS
36 EFIAPI
37 PxeDhcp4DriverBindingSupported (
38 IN EFI_DRIVER_BINDING_PROTOCOL *This,
39 IN EFI_HANDLE ControllerHandle,
40 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
41 );
42
43 EFI_STATUS
44 EFIAPI
45 PxeDhcp4DriverBindingStart (
46 IN EFI_DRIVER_BINDING_PROTOCOL *This,
47 IN EFI_HANDLE ControllerHandle,
48 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
49 );
50
51 EFI_STATUS
52 EFIAPI
53 PxeDhcp4DriverBindingStop (
54 IN EFI_DRIVER_BINDING_PROTOCOL *This,
55 IN EFI_HANDLE ControllerHandle,
56 IN UINTN NumberOfChildren,
57 IN EFI_HANDLE *ChildHandleBuffer
58 );
59
60 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
61
62 //
63 // PXE DHCP Protocol Interface
64 //
65 EFI_DRIVER_BINDING_PROTOCOL gPxeDhcp4DriverBinding = {
66 PxeDhcp4DriverBindingSupported,
67 PxeDhcp4DriverBindingStart,
68 PxeDhcp4DriverBindingStop,
69 0xa,
70 NULL,
71 NULL
72 };
73
74 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
75 EFI_STATUS
76 EFIAPI
77 PxeDhcp4DriverBindingSupported (
78 IN EFI_DRIVER_BINDING_PROTOCOL * This,
79 IN EFI_HANDLE ControllerHandle,
80 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
81 )
82 /*++
83
84 Routine Description:
85 Test to see if this driver supports ControllerHandle. Any
86 ControllerHandle that contains a PxeBaseCode protocol can be
87 supported.
88
89 Arguments:
90 This - Protocol instance pointer.
91 ControllerHandle - Handle of device to test.
92 RemainingDevicePath - Not used.
93
94 Returns:
95 EFI_SUCCESS - This driver supports this device.
96 EFI_ALREADY_STARTED - This driver is already running on this
97 device.
98 other - This driver does not support this device.
99
100 --*/
101 {
102 EFI_STATUS Status;
103 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
104
105 //
106 // Open the IO Abstraction(s) needed to perform the supported test.
107 //
108 Status = gBS->OpenProtocol (
109 ControllerHandle,
110 &gEfiPxeBaseCodeProtocolGuid,
111 (VOID **) &PxeBc,
112 This->DriverBindingHandle,
113 ControllerHandle,
114 EFI_OPEN_PROTOCOL_BY_DRIVER
115 );
116
117 if (EFI_ERROR (Status)) {
118 return Status;
119 }
120 //
121 // Close the I/O Abstraction(s) used to perform the supported test.
122 //
123 return gBS->CloseProtocol (
124 ControllerHandle,
125 &gEfiPxeBaseCodeProtocolGuid,
126 This->DriverBindingHandle,
127 ControllerHandle
128 );
129 }
130
131 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
132 EFI_STATUS
133 EFIAPI
134 PxeDhcp4DriverBindingStart (
135 IN EFI_DRIVER_BINDING_PROTOCOL * This,
136 IN EFI_HANDLE ControllerHandle,
137 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
138 )
139 /*++
140
141 Routine Description:
142 Start this driver on ControllerHandle by opening a PxeBaseCode
143 protocol and installing a PxeDhcp4 protocol on ControllerHandle.
144
145 Arguments:
146 This - Protocol instance pointer.
147 ControllerHandle - Handle of device to bind driver to.
148 RemainingDevicePath - Not used, always produce all possible
149 children.
150
151 Returns:
152 EFI_SUCCESS - This driver is added to ControllerHandle.
153 EFI_ALREADY_STARTED - This driver is already running on
154 ControllerHandle.
155 other - This driver does not support this device.
156
157 --*/
158 {
159 EFI_STATUS Status;
160 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
161 EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
162 PXE_DHCP4_PRIVATE_DATA *Private;
163
164 //
165 // Connect to the PxeBaseCode interface on ControllerHandle.
166 //
167 Status = gBS->OpenProtocol (
168 ControllerHandle,
169 &gEfiPxeBaseCodeProtocolGuid,
170 (VOID **) &PxeBc,
171 This->DriverBindingHandle,
172 ControllerHandle,
173 EFI_OPEN_PROTOCOL_BY_DRIVER
174 );
175
176 if (EFI_ERROR (Status)) {
177 return Status;
178 }
179 //
180 // BaseCode has already grabbed the SimpleNetwork interface
181 // so just do a HandleProtocol() to get it.
182 //
183 Status = gBS->HandleProtocol (
184 ControllerHandle,
185 &gEfiSimpleNetworkProtocolGuid,
186 (VOID **) &Snp
187 );
188
189 if (EFI_ERROR (Status)) {
190 goto error_exit;
191 }
192
193 ASSERT (Snp);
194
195 //
196 // Initialize the PXE DHCP device instance.
197 //
198 Status = gBS->AllocatePool (
199 EfiBootServicesData,
200 sizeof (PXE_DHCP4_PRIVATE_DATA),
201 (VOID **) &Private
202 );
203
204 if (EFI_ERROR (Status)) {
205 goto error_exit;
206 }
207 //
208 //
209 //
210 ZeroMem (Private, sizeof (PXE_DHCP4_PRIVATE_DATA));
211
212 Private->Signature = PXE_DHCP4_PRIVATE_DATA_SIGNATURE;
213 Private->PxeBc = PxeBc;
214 Private->Snp = Snp;
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;
225
226 //
227 // Install protocol interfaces for the PXE DHCP device.
228 //
229 Status = gBS->InstallProtocolInterface (
230 &ControllerHandle,
231 &gEfiPxeDhcp4ProtocolGuid,
232 EFI_NATIVE_INTERFACE,
233 &Private->PxeDhcp4
234 );
235
236 if (!EFI_ERROR (Status)) {
237 return Status;
238 }
239
240 error_exit: ;
241 gBS->CloseProtocol (
242 ControllerHandle,
243 &gEfiPxeBaseCodeProtocolGuid,
244 This->DriverBindingHandle,
245 ControllerHandle
246 );
247
248 return Status;
249 }
250
251 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
252 EFI_STATUS
253 EFIAPI
254 PxeDhcp4DriverBindingStop (
255 IN EFI_DRIVER_BINDING_PROTOCOL *This,
256 IN EFI_HANDLE ControllerHandle,
257 IN UINTN NumberOfChildren,
258 IN EFI_HANDLE *ChildHandleBuffer
259 )
260 /*++
261
262 Routine Description:
263 Stop this driver on ControllerHandle by removing PXE DHCP
264 protocol and closing the PXE Base Code protocol on
265 ControllerHandle.
266
267 Arguments:
268 This - Protocol instance pointer.
269 ControllerHandle - Handle of device to stop driver on.
270 NumberOfChildren - Not used.
271 ChildHandleBuffer - Not used.
272
273 Returns:
274 EFI_SUCCESS - This driver is removed ControllerHandle.
275 other - This driver was not removed from this
276 device.
277
278 --*/
279 {
280 EFI_STATUS Status;
281 EFI_PXE_DHCP4_PROTOCOL *PxeDhcp4;
282 PXE_DHCP4_PRIVATE_DATA *Private;
283
284 //
285 // Get our context back.
286 //
287 Status = gBS->OpenProtocol (
288 ControllerHandle,
289 &gEfiPxeDhcp4ProtocolGuid,
290 (VOID **) &PxeDhcp4,
291 This->DriverBindingHandle,
292 ControllerHandle,
293 EFI_OPEN_PROTOCOL_GET_PROTOCOL
294 );
295
296 if (EFI_ERROR (Status)) {
297 return EFI_UNSUPPORTED;
298 }
299
300 Private = PXE_DHCP4_PRIVATE_DATA_FROM_THIS (PxeDhcp4);
301
302 //
303 // Release allocated resources
304 //
305 if (Private->PxeDhcp4.Data) {
306 gBS->FreePool (Private->PxeDhcp4.Data);
307 Private->PxeDhcp4.Data = NULL;
308 }
309 //
310 // Uninstall our protocol
311 //
312 Status = gBS->UninstallProtocolInterface (
313 ControllerHandle,
314 &gEfiPxeDhcp4ProtocolGuid,
315 &Private->PxeDhcp4
316 );
317
318 if (EFI_ERROR (Status)) {
319 return Status;
320 }
321 //
322 // Close any consumed protocols
323 //
324 Status = gBS->CloseProtocol (
325 ControllerHandle,
326 &gEfiPxeBaseCodeProtocolGuid,
327 This->DriverBindingHandle,
328 ControllerHandle
329 );
330
331 if (EFI_ERROR (Status)) {
332 return Status;
333 }
334 //
335 // Release our private data
336 //
337 gBS->FreePool (Private);
338
339 return Status;
340 }
341
342 /* EOF - PxeDhcp4.c */