]>
Commit | Line | Data |
---|---|---|
d933e70a JW |
1 | /** @file\r |
2 | UEFI HTTP boot driver's private data structure and interfaces declaration.\r | |
3 | \r | |
4 | Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials are licensed and made available under \r | |
6 | the terms and conditions of the BSD License that accompanies this distribution. \r | |
7 | The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php. \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT 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 | |
44 | #include <Protocol/Http.h>\r | |
45 | #include <Protocol/Ip4Config2.h>\r | |
46 | \r | |
47 | //\r | |
48 | // Produced Protocols\r | |
49 | //\r | |
50 | #include <Protocol/LoadFile.h>\r | |
51 | \r | |
52 | //\r | |
53 | // Driver Version\r | |
54 | //\r | |
55 | #define HTTP_BOOT_DXE_VERSION 0xa\r | |
56 | \r | |
57 | //\r | |
58 | // Protocol instances\r | |
59 | //\r | |
60 | extern EFI_DRIVER_BINDING_PROTOCOL gHttpBootDxeDriverBinding;\r | |
61 | extern EFI_COMPONENT_NAME2_PROTOCOL gHttpBootDxeComponentName2;\r | |
62 | extern EFI_COMPONENT_NAME_PROTOCOL gHttpBootDxeComponentName;\r | |
63 | \r | |
64 | //\r | |
65 | // Private data structure\r | |
66 | //\r | |
67 | typedef struct _HTTP_BOOT_PRIVATE_DATA HTTP_BOOT_PRIVATE_DATA;\r | |
68 | \r | |
69 | //\r | |
70 | // Include files with internal function prototypes\r | |
71 | //\r | |
72 | #include "HttpBootComponentName.h"\r | |
73 | #include "HttpBootDhcp4.h"\r | |
74 | #include "HttpBootImpl.h"\r | |
75 | #include "HttpBootSupport.h"\r | |
76 | #include "HttpBootClient.h"\r | |
77 | \r | |
78 | typedef union {\r | |
79 | HTTP_BOOT_DHCP4_PACKET_CACHE Dhcp4;\r | |
80 | } HTTP_BOOT_DHCP_PACKET_CACHE;\r | |
81 | \r | |
82 | struct _HTTP_BOOT_PRIVATE_DATA {\r | |
83 | UINT32 Signature;\r | |
84 | EFI_HANDLE Controller;\r | |
85 | EFI_HANDLE Image;\r | |
86 | \r | |
87 | //\r | |
88 | // Cousumed children\r | |
89 | //\r | |
90 | EFI_HANDLE Dhcp4Child;\r | |
91 | HTTP_IO HttpIo;\r | |
92 | BOOLEAN HttpCreated;\r | |
93 | \r | |
94 | //\r | |
95 | // Consumed protocol\r | |
96 | //\r | |
97 | EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;\r | |
98 | EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;\r | |
99 | EFI_DHCP4_PROTOCOL *Dhcp4;\r | |
100 | EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r | |
101 | \r | |
102 | //\r | |
103 | // Produced children\r | |
104 | //\r | |
105 | EFI_HANDLE ChildHandle;\r | |
106 | \r | |
107 | //\r | |
108 | // Produced protocol\r | |
109 | //\r | |
110 | EFI_LOAD_FILE_PROTOCOL LoadFile;\r | |
111 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
112 | UINT32 Id;\r | |
113 | \r | |
114 | //\r | |
115 | // Mode data\r | |
116 | //\r | |
117 | BOOLEAN UsingIpv6;\r | |
118 | BOOLEAN Started;\r | |
119 | EFI_IP_ADDRESS StationIp;\r | |
120 | EFI_IP_ADDRESS SubnetMask;\r | |
121 | EFI_IP_ADDRESS GatewayIp;\r | |
122 | UINT16 Port;\r | |
123 | CHAR8 *BootFileUri;\r | |
124 | VOID *BootFileUriParser;\r | |
125 | UINTN BootFileSize;\r | |
126 | \r | |
127 | //\r | |
128 | // Cached HTTP data\r | |
129 | //\r | |
130 | LIST_ENTRY CacheList;\r | |
131 | \r | |
132 | //\r | |
133 | // Cached DHCP offer\r | |
134 | //\r | |
135 | // OfferIndex records the index of DhcpOffer[] buffer, and OfferCount records the num of each type of offer.\r | |
136 | //\r | |
137 | // It supposed that\r | |
138 | //\r | |
139 | // OfferNum: 8\r | |
140 | // OfferBuffer: [ProxyNameUri, DhcpNameUri, DhcpIpUri, ProxyNameUri, ProxyIpUri, DhcpOnly, DhcpIpUri, DhcpNameUriDns]\r | |
141 | // (OfferBuffer is 0-based.)\r | |
142 | //\r | |
143 | // And assume that (DhcpIpUri is the first priority actually.)\r | |
144 | //\r | |
145 | // SelectIndex: 5\r | |
146 | // SelectProxyType: HttpOfferTypeProxyIpUri\r | |
147 | // (SelectIndex is 1-based, and 0 means no one is selected.)\r | |
148 | //\r | |
149 | // So it should be\r | |
150 | //\r | |
151 | // DhcpIpUri DhcpNameUriDns DhcpDns DhcpOnly ProxyNameUri ProxyIpUri DhcpNameUri\r | |
152 | // OfferCount: [ 2, 1, 0, 1, 2, 1, 1]\r | |
153 | //\r | |
154 | // OfferIndex: {[ 2, 7, 0, 5, 0, *4, 1]\r | |
155 | // [ 6, 0, 0, 0, 3, 0, 0]\r | |
156 | // [ 0, 0, 0, 0, 0, 0, 0]\r | |
157 | // ... ]}\r | |
158 | // (OfferIndex is 0-based.)\r | |
159 | //\r | |
160 | //\r | |
161 | UINT32 SelectIndex;\r | |
162 | UINT32 SelectProxyType;\r | |
163 | HTTP_BOOT_DHCP_PACKET_CACHE OfferBuffer[HTTP_BOOT_OFFER_MAX_NUM];\r | |
164 | UINT32 OfferNum;\r | |
165 | UINT32 OfferCount[HttpOfferTypeMax];\r | |
166 | UINT32 OfferIndex[HttpOfferTypeMax][HTTP_BOOT_OFFER_MAX_NUM];\r | |
167 | };\r | |
168 | \r | |
169 | #define HTTP_BOOT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('H', 'B', 'P', 'D')\r | |
170 | #define HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE(a) CR (a, HTTP_BOOT_PRIVATE_DATA, LoadFile, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)\r | |
171 | #define HTTP_BOOT_PRIVATE_DATA_FROM_ID(a) CR (a, HTTP_BOOT_PRIVATE_DATA, Id, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)\r | |
172 | \r | |
173 | extern EFI_LOAD_FILE_PROTOCOL gHttpBootDxeLoadFile;\r | |
174 | \r | |
175 | /**\r | |
176 | Tests to see if this driver supports a given controller. If a child device is provided, \r | |
177 | it further tests to see if this driver supports creating a handle for the specified child device.\r | |
178 | \r | |
179 | This function checks to see if the driver specified by This supports the device specified by \r | |
180 | ControllerHandle. Drivers will typically use the device path attached to \r | |
181 | ControllerHandle and/or the services from the bus I/O abstraction attached to \r | |
182 | ControllerHandle to determine if the driver supports ControllerHandle. This function \r | |
183 | may be called many times during platform initialization. In order to reduce boot times, the tests \r | |
184 | performed by this function must be very small, and take as little time as possible to execute. This \r | |
185 | function must not change the state of any hardware devices, and this function must be aware that the \r | |
186 | device specified by ControllerHandle may already be managed by the same driver or a \r | |
187 | different driver. This function must match its calls to AllocatePages() with FreePages(), \r | |
188 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). \r | |
189 | Because ControllerHandle may have been previously started by the same driver, if a protocol is \r | |
190 | already in the opened state, then it must not be closed with CloseProtocol(). This is required \r | |
191 | to guarantee the state of ControllerHandle is not modified by this function.\r | |
192 | \r | |
193 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
194 | @param[in] ControllerHandle The handle of the controller to test. This handle \r | |
195 | must support a protocol interface that supplies \r | |
196 | an I/O abstraction to the driver.\r | |
197 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r | |
198 | parameter is ignored by device drivers, and is optional for bus \r | |
199 | drivers. For bus drivers, if this parameter is not NULL, then \r | |
200 | the bus driver must determine if the bus controller specified \r | |
201 | by ControllerHandle and the child controller specified \r | |
202 | by RemainingDevicePath are both supported by this \r | |
203 | bus driver.\r | |
204 | \r | |
205 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r | |
206 | RemainingDevicePath is supported by the driver specified by This.\r | |
207 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
208 | RemainingDevicePath is already being managed by the driver\r | |
209 | specified by This.\r | |
210 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
211 | RemainingDevicePath is already being managed by a different\r | |
212 | driver or an application that requires exclusive access.\r | |
213 | Currently not implemented.\r | |
214 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
215 | RemainingDevicePath is not supported by the driver specified by This.\r | |
216 | **/\r | |
217 | EFI_STATUS\r | |
218 | EFIAPI\r | |
219 | HttpBootIp4DxeDriverBindingSupported (\r | |
220 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
221 | IN EFI_HANDLE ControllerHandle,\r | |
222 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
223 | );\r | |
224 | \r | |
225 | /**\r | |
226 | Starts a device controller or a bus controller.\r | |
227 | \r | |
228 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
229 | As a result, much of the error checking on the parameters to Start() has been moved into this \r | |
230 | common boot service. It is legal to call Start() from other locations, \r | |
231 | but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r | |
232 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
233 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
234 | EFI_DEVICE_PATH_PROTOCOL.\r | |
235 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
236 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r | |
237 | \r | |
238 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
239 | @param[in] ControllerHandle The handle of the controller to start. This handle \r | |
240 | must support a protocol interface that supplies \r | |
241 | an I/O abstraction to the driver.\r | |
242 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r | |
243 | parameter is ignored by device drivers, and is optional for bus \r | |
244 | drivers. For a bus driver, if this parameter is NULL, then handles \r | |
245 | for all the children of Controller are created by this driver. \r | |
246 | If this parameter is not NULL and the first Device Path Node is \r | |
247 | not the End of Device Path Node, then only the handle for the \r | |
248 | child device specified by the first Device Path Node of \r | |
249 | RemainingDevicePath is created by this driver.\r | |
250 | If the first Device Path Node of RemainingDevicePath is \r | |
251 | the End of Device Path Node, no child handle is created by this\r | |
252 | driver.\r | |
253 | \r | |
254 | @retval EFI_SUCCESS The device was started.\r | |
255 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r | |
256 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
257 | @retval Others The driver failded to start the device.\r | |
258 | \r | |
259 | **/\r | |
260 | EFI_STATUS\r | |
261 | EFIAPI\r | |
262 | HttpBootIp4DxeDriverBindingStart (\r | |
263 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
264 | IN EFI_HANDLE ControllerHandle,\r | |
265 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
266 | );\r | |
267 | \r | |
268 | /**\r | |
269 | Stops a device controller or a bus controller.\r | |
270 | \r | |
271 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r | |
272 | As a result, much of the error checking on the parameters to Stop() has been moved \r | |
273 | into this common boot service. It is legal to call Stop() from other locations, \r | |
274 | but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r | |
275 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
276 | same driver's Start() function.\r | |
277 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
278 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
279 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
280 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
281 | \r | |
282 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
283 | @param[in] ControllerHandle A handle to the device being stopped. The handle must \r | |
284 | support a bus specific I/O protocol for the driver \r | |
285 | to use to stop the device.\r | |
286 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
287 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r | |
288 | if NumberOfChildren is 0.\r | |
289 | \r | |
290 | @retval EFI_SUCCESS The device was stopped.\r | |
291 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
292 | \r | |
293 | **/\r | |
294 | EFI_STATUS\r | |
295 | EFIAPI\r | |
296 | HttpBootIp4DxeDriverBindingStop (\r | |
297 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
298 | IN EFI_HANDLE ControllerHandle,\r | |
299 | IN UINTN NumberOfChildren,\r | |
300 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r | |
301 | );\r | |
302 | \r | |
303 | #endif\r |