VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/HttpBootDxe/HttpBootDxe.h@ 80721

Last change on this file since 80721 was 80721, checked in by vboxsync, 5 years ago

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette