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