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