]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpBootDxe/HttpBootDxe.h
UefiCpuPkg/Application/Cpuid: Remove unnecessary code check
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootDxe.h
1 /** @file
2 UEFI HTTP boot driver's private data structure and interfaces declaration.
3
4 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __EFI_HTTP_BOOT_DXE_H__
17 #define __EFI_HTTP_BOOT_DXE_H__
18
19 #include <Uefi.h>
20
21 #include <IndustryStandard/Http11.h>
22
23 //
24 // Libraries
25 //
26 #include <Library/UefiBootServicesTableLib.h>
27 #include <Library/UefiHiiServicesLib.h>
28 #include <Library/UefiRuntimeServicesTableLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/BaseLib.h>
31 #include <Library/UefiLib.h>
32 #include <Library/DevicePathLib.h>
33 #include <Library/DebugLib.h>
34 #include <Library/NetLib.h>
35 #include <Library/HttpLib.h>
36 #include <Library/HiiLib.h>
37 #include <Library/PrintLib.h>
38
39 //
40 // UEFI Driver Model Protocols
41 //
42 #include <Protocol/DriverBinding.h>
43 #include <Protocol/ComponentName2.h>
44 #include <Protocol/ComponentName.h>
45
46 //
47 // Consumed Protocols
48 //
49 #include <Protocol/ServiceBinding.h>
50 #include <Protocol/HiiConfigAccess.h>
51 #include <Protocol/NetworkInterfaceIdentifier.h>
52 #include <Protocol/Dhcp4.h>
53 #include <Protocol/Dhcp6.h>
54 #include <Protocol/Dns6.h>
55 #include <Protocol/Http.h>
56 #include <Protocol/Ip4Config2.h>
57 #include <Protocol/Ip6Config.h>
58 //
59 // Produced Protocols
60 //
61 #include <Protocol/LoadFile.h>
62
63 //
64 // Consumed Guids
65 //
66 #include <Guid/HttpBootConfigHii.h>
67
68 //
69 // Driver Version
70 //
71 #define HTTP_BOOT_DXE_VERSION 0xa
72
73 //
74 // Protocol instances
75 //
76 extern EFI_DRIVER_BINDING_PROTOCOL gHttpBootDxeDriverBinding;
77 extern EFI_COMPONENT_NAME2_PROTOCOL gHttpBootDxeComponentName2;
78 extern EFI_COMPONENT_NAME_PROTOCOL gHttpBootDxeComponentName;
79
80 //
81 // Private data structure
82 //
83 typedef struct _HTTP_BOOT_PRIVATE_DATA HTTP_BOOT_PRIVATE_DATA;
84 typedef struct _HTTP_BOOT_VIRTUAL_NIC HTTP_BOOT_VIRTUAL_NIC;
85
86 //
87 // Include files with internal function prototypes
88 //
89 #include "HttpBootComponentName.h"
90 #include "HttpBootDhcp4.h"
91 #include "HttpBootDhcp6.h"
92 #include "HttpBootImpl.h"
93 #include "HttpBootSupport.h"
94 #include "HttpBootClient.h"
95 #include "HttpBootConfig.h"
96
97 typedef union {
98 HTTP_BOOT_DHCP4_PACKET_CACHE Dhcp4;
99 HTTP_BOOT_DHCP6_PACKET_CACHE Dhcp6;
100 } HTTP_BOOT_DHCP_PACKET_CACHE;
101
102 struct _HTTP_BOOT_VIRTUAL_NIC {
103 UINT32 Signature;
104 EFI_HANDLE Controller;
105 EFI_LOAD_FILE_PROTOCOL LoadFile;
106 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
107 HTTP_BOOT_PRIVATE_DATA *Private;
108 };
109
110 #define HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_INFO(Callback) \
111 CR ( \
112 Callback, \
113 HTTP_BOOT_PRIVATE_DATA, \
114 CallbackInfo, \
115 HTTP_BOOT_PRIVATE_DATA_SIGNATURE \
116 )
117
118 struct _HTTP_BOOT_PRIVATE_DATA {
119 UINT32 Signature;
120 EFI_HANDLE Controller;
121 EFI_HANDLE Image;
122
123 HTTP_BOOT_VIRTUAL_NIC *Ip4Nic;
124 HTTP_BOOT_VIRTUAL_NIC *Ip6Nic;
125
126 //
127 // Cousumed children
128 //
129 EFI_HANDLE Ip6Child;
130 EFI_HANDLE Dhcp4Child;
131 EFI_HANDLE Dhcp6Child;
132 HTTP_IO HttpIo;
133 BOOLEAN HttpCreated;
134
135 //
136 // Consumed protocol
137 //
138 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
139 EFI_IP6_PROTOCOL *Ip6;
140 EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
141 EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
142 EFI_DHCP4_PROTOCOL *Dhcp4;
143 EFI_DHCP6_PROTOCOL *Dhcp6;
144 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
145
146
147 //
148 // Produced protocol
149 //
150 EFI_LOAD_FILE_PROTOCOL LoadFile;
151 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
152 UINT32 Id;
153
154 //
155 // HII callback info block
156 //
157 HTTP_BOOT_FORM_CALLBACK_INFO CallbackInfo;
158
159 //
160 // Mode data
161 //
162 BOOLEAN UsingIpv6;
163 BOOLEAN Started;
164 EFI_IP_ADDRESS StationIp;
165 EFI_IP_ADDRESS SubnetMask;
166 EFI_IP_ADDRESS GatewayIp;
167 EFI_IP_ADDRESS ServerIp;
168 UINT16 Port;
169 CHAR8 *BootFileUri;
170 VOID *BootFileUriParser;
171 UINTN BootFileSize;
172 BOOLEAN NoGateway;
173
174 //
175 // URI string extracted from the input FilePath parameter.
176 //
177 CHAR8 *FilePathUri;
178 VOID *FilePathUriParser;
179
180 //
181 // Cached HTTP data
182 //
183 LIST_ENTRY CacheList;
184
185 //
186 // Cached DHCP offer
187 //
188 // OfferIndex records the index of DhcpOffer[] buffer, and OfferCount records the num of each type of offer.
189 //
190 // It supposed that
191 //
192 // OfferNum: 8
193 // OfferBuffer: [ProxyNameUri, DhcpNameUri, DhcpIpUri, ProxyNameUri, ProxyIpUri, DhcpOnly, DhcpIpUri, DhcpNameUriDns]
194 // (OfferBuffer is 0-based.)
195 //
196 // And assume that (DhcpIpUri is the first priority actually.)
197 //
198 // SelectIndex: 5
199 // SelectProxyType: HttpOfferTypeProxyIpUri
200 // (SelectIndex is 1-based, and 0 means no one is selected.)
201 //
202 // So it should be
203 //
204 // DhcpIpUri DhcpNameUriDns DhcpDns DhcpOnly ProxyNameUri ProxyIpUri DhcpNameUri
205 // OfferCount: [ 2, 1, 0, 1, 2, 1, 1]
206 //
207 // OfferIndex: {[ 2, 7, 0, 5, 0, *4, 1]
208 // [ 6, 0, 0, 0, 3, 0, 0]
209 // [ 0, 0, 0, 0, 0, 0, 0]
210 // ... ]}
211 // (OfferIndex is 0-based.)
212 //
213 //
214 UINT32 SelectIndex;
215 UINT32 SelectProxyType;
216 HTTP_BOOT_DHCP_PACKET_CACHE OfferBuffer[HTTP_BOOT_OFFER_MAX_NUM];
217 UINT32 OfferNum;
218 UINT32 OfferCount[HttpOfferTypeMax];
219 UINT32 OfferIndex[HttpOfferTypeMax][HTTP_BOOT_OFFER_MAX_NUM];
220 };
221
222 #define HTTP_BOOT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('H', 'B', 'P', 'D')
223 #define HTTP_BOOT_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('H', 'B', 'V', 'N')
224 #define HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE(a) CR (a, HTTP_BOOT_PRIVATE_DATA, LoadFile, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)
225 #define HTTP_BOOT_PRIVATE_DATA_FROM_ID(a) CR (a, HTTP_BOOT_PRIVATE_DATA, Id, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)
226 #define HTTP_BOOT_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, HTTP_BOOT_VIRTUAL_NIC, LoadFile, HTTP_BOOT_VIRTUAL_NIC_SIGNATURE)
227 extern EFI_LOAD_FILE_PROTOCOL gHttpBootDxeLoadFile;
228
229 /**
230 Tests to see if this driver supports a given controller. If a child device is provided,
231 it further tests to see if this driver supports creating a handle for the specified child device.
232
233 This function checks to see if the driver specified by This supports the device specified by
234 ControllerHandle. Drivers will typically use the device path attached to
235 ControllerHandle and/or the services from the bus I/O abstraction attached to
236 ControllerHandle to determine if the driver supports ControllerHandle. This function
237 may be called many times during platform initialization. In order to reduce boot times, the tests
238 performed by this function must be very small, and take as little time as possible to execute. This
239 function must not change the state of any hardware devices, and this function must be aware that the
240 device specified by ControllerHandle may already be managed by the same driver or a
241 different driver. This function must match its calls to AllocatePages() with FreePages(),
242 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
243 Because ControllerHandle may have been previously started by the same driver, if a protocol is
244 already in the opened state, then it must not be closed with CloseProtocol(). This is required
245 to guarantee the state of ControllerHandle is not modified by this function.
246
247 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
248 @param[in] ControllerHandle The handle of the controller to test. This handle
249 must support a protocol interface that supplies
250 an I/O abstraction to the driver.
251 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
252 parameter is ignored by device drivers, and is optional for bus
253 drivers. For bus drivers, if this parameter is not NULL, then
254 the bus driver must determine if the bus controller specified
255 by ControllerHandle and the child controller specified
256 by RemainingDevicePath are both supported by this
257 bus driver.
258
259 @retval EFI_SUCCESS The device specified by ControllerHandle and
260 RemainingDevicePath is supported by the driver specified by This.
261 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
262 RemainingDevicePath is already being managed by the driver
263 specified by This.
264 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
265 RemainingDevicePath is already being managed by a different
266 driver or an application that requires exclusive access.
267 Currently not implemented.
268 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
269 RemainingDevicePath is not supported by the driver specified by This.
270 **/
271 EFI_STATUS
272 EFIAPI
273 HttpBootIp4DxeDriverBindingSupported (
274 IN EFI_DRIVER_BINDING_PROTOCOL *This,
275 IN EFI_HANDLE ControllerHandle,
276 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
277 );
278
279 /**
280 Starts a device controller or a bus controller.
281
282 The Start() function is designed to be invoked from the EFI boot service ConnectController().
283 As a result, much of the error checking on the parameters to Start() has been moved into this
284 common boot service. It is legal to call Start() from other locations,
285 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
286 1. ControllerHandle must be a valid EFI_HANDLE.
287 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
288 EFI_DEVICE_PATH_PROTOCOL.
289 3. Prior to calling Start(), the Supported() function for the driver specified by This must
290 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
291
292 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
293 @param[in] ControllerHandle The handle of the controller to start. This handle
294 must support a protocol interface that supplies
295 an I/O abstraction to the driver.
296 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
297 parameter is ignored by device drivers, and is optional for bus
298 drivers. For a bus driver, if this parameter is NULL, then handles
299 for all the children of Controller are created by this driver.
300 If this parameter is not NULL and the first Device Path Node is
301 not the End of Device Path Node, then only the handle for the
302 child device specified by the first Device Path Node of
303 RemainingDevicePath is created by this driver.
304 If the first Device Path Node of RemainingDevicePath is
305 the End of Device Path Node, no child handle is created by this
306 driver.
307
308 @retval EFI_SUCCESS The device was started.
309 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
310 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
311 @retval Others The driver failded to start the device.
312
313 **/
314 EFI_STATUS
315 EFIAPI
316 HttpBootIp4DxeDriverBindingStart (
317 IN EFI_DRIVER_BINDING_PROTOCOL *This,
318 IN EFI_HANDLE ControllerHandle,
319 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
320 );
321
322 /**
323 Stops a device controller or a bus controller.
324
325 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
326 As a result, much of the error checking on the parameters to Stop() has been moved
327 into this common boot service. It is legal to call Stop() from other locations,
328 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
329 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
330 same driver's Start() function.
331 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
332 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
333 Start() function, and the Start() function must have called OpenProtocol() on
334 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
335
336 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
337 @param[in] ControllerHandle A handle to the device being stopped. The handle must
338 support a bus specific I/O protocol for the driver
339 to use to stop the device.
340 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
341 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
342 if NumberOfChildren is 0.
343
344 @retval EFI_SUCCESS The device was stopped.
345 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
346
347 **/
348 EFI_STATUS
349 EFIAPI
350 HttpBootIp4DxeDriverBindingStop (
351 IN EFI_DRIVER_BINDING_PROTOCOL *This,
352 IN EFI_HANDLE ControllerHandle,
353 IN UINTN NumberOfChildren,
354 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
355 );
356
357 /**
358 Tests to see if this driver supports a given controller. If a child device is provided,
359 it further tests to see if this driver supports creating a handle for the specified child device.
360
361 This function checks to see if the driver specified by This supports the device specified by
362 ControllerHandle. Drivers will typically use the device path attached to
363 ControllerHandle and/or the services from the bus I/O abstraction attached to
364 ControllerHandle to determine if the driver supports ControllerHandle. This function
365 may be called many times during platform initialization. In order to reduce boot times, the tests
366 performed by this function must be very small, and take as little time as possible to execute. This
367 function must not change the state of any hardware devices, and this function must be aware that the
368 device specified by ControllerHandle may already be managed by the same driver or a
369 different driver. This function must match its calls to AllocatePages() with FreePages(),
370 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
371 Because ControllerHandle may have been previously started by the same driver, if a protocol is
372 already in the opened state, then it must not be closed with CloseProtocol(). This is required
373 to guarantee the state of ControllerHandle is not modified by this function.
374
375 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
376 @param[in] ControllerHandle The handle of the controller to test. This handle
377 must support a protocol interface that supplies
378 an I/O abstraction to the driver.
379 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
380 parameter is ignored by device drivers, and is optional for bus
381 drivers. For bus drivers, if this parameter is not NULL, then
382 the bus driver must determine if the bus controller specified
383 by ControllerHandle and the child controller specified
384 by RemainingDevicePath are both supported by this
385 bus driver.
386
387 @retval EFI_SUCCESS The device specified by ControllerHandle and
388 RemainingDevicePath is supported by the driver specified by This.
389 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
390 RemainingDevicePath is already being managed by the driver
391 specified by This.
392 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
393 RemainingDevicePath is already being managed by a different
394 driver or an application that requires exclusive access.
395 Currently not implemented.
396 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
397 RemainingDevicePath is not supported by the driver specified by This.
398 **/
399 EFI_STATUS
400 EFIAPI
401 HttpBootIp6DxeDriverBindingSupported (
402 IN EFI_DRIVER_BINDING_PROTOCOL *This,
403 IN EFI_HANDLE ControllerHandle,
404 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
405 );
406
407 /**
408 Starts a device controller or a bus controller.
409
410 The Start() function is designed to be invoked from the EFI boot service ConnectController().
411 As a result, much of the error checking on the parameters to Start() has been moved into this
412 common boot service. It is legal to call Start() from other locations,
413 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
414 1. ControllerHandle must be a valid EFI_HANDLE.
415 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
416 EFI_DEVICE_PATH_PROTOCOL.
417 3. Prior to calling Start(), the Supported() function for the driver specified by This must
418 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
419
420 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
421 @param[in] ControllerHandle The handle of the controller to start. This handle
422 must support a protocol interface that supplies
423 an I/O abstraction to the driver.
424 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
425 parameter is ignored by device drivers, and is optional for bus
426 drivers. For a bus driver, if this parameter is NULL, then handles
427 for all the children of Controller are created by this driver.
428 If this parameter is not NULL and the first Device Path Node is
429 not the End of Device Path Node, then only the handle for the
430 child device specified by the first Device Path Node of
431 RemainingDevicePath is created by this driver.
432 If the first Device Path Node of RemainingDevicePath is
433 the End of Device Path Node, no child handle is created by this
434 driver.
435
436 @retval EFI_SUCCESS The device was started.
437 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
438 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
439 @retval Others The driver failded to start the device.
440
441 **/
442 EFI_STATUS
443 EFIAPI
444 HttpBootIp6DxeDriverBindingStart (
445 IN EFI_DRIVER_BINDING_PROTOCOL *This,
446 IN EFI_HANDLE ControllerHandle,
447 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
448 );
449
450 /**
451 Stops a device controller or a bus controller.
452
453 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
454 As a result, much of the error checking on the parameters to Stop() has been moved
455 into this common boot service. It is legal to call Stop() from other locations,
456 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
457 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
458 same driver's Start() function.
459 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
460 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
461 Start() function, and the Start() function must have called OpenProtocol() on
462 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
463
464 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
465 @param[in] ControllerHandle A handle to the device being stopped. The handle must
466 support a bus specific I/O protocol for the driver
467 to use to stop the device.
468 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
469 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
470 if NumberOfChildren is 0.
471
472 @retval EFI_SUCCESS The device was stopped.
473 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
474
475 **/
476 EFI_STATUS
477 EFIAPI
478 HttpBootIp6DxeDriverBindingStop (
479 IN EFI_DRIVER_BINDING_PROTOCOL *This,
480 IN EFI_HANDLE ControllerHandle,
481 IN UINTN NumberOfChildren,
482 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
483 );
484 #endif