NetworkPkg: Add HTTP Driver
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpDriver.h
CommitLineData
47f51a06
YT
1/** @file\r
2 The header files of the driver binding and service binding protocol for HttpDxe driver.\r
3\r
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __EFI_HTTP_DRIVER_H__\r
17#define __EFI_HTTP_DRIVER_H__\r
18\r
19#include <Uefi.h>\r
20\r
21//\r
22// Libraries\r
23//\r
24#include <Library/UefiBootServicesTableLib.h>\r
25#include <Library/MemoryAllocationLib.h>\r
26#include <Library/BaseLib.h>\r
27#include <Library/UefiLib.h>\r
28#include <Library/DebugLib.h>\r
29#include <Library/NetLib.h>\r
30#include <Library/HttpLib.h>\r
31#include <Library/TcpIoLib.h>\r
32\r
33//\r
34// UEFI Driver Model Protocols\r
35//\r
36#include <Protocol/DriverBinding.h>\r
37#include <Protocol/ServiceBinding.h>\r
38#include <Protocol/ComponentName2.h>\r
39#include <Protocol/ComponentName.h>\r
40\r
41//\r
42// Consumed Protocols\r
43//\r
44#include <Protocol/Tcp4.h>\r
45#include <Protocol/Dns4.h>\r
46#include <Protocol/Ip4Config2.h>\r
47\r
48//\r
49// Produced Protocols\r
50//\r
51#include <Protocol/Http.h>\r
52\r
53//\r
54// Driver Version\r
55//\r
56#define HTTP_DRIVER_VERSION 0xa\r
57\r
58//\r
59// Protocol instances\r
60//\r
61extern EFI_DRIVER_BINDING_PROTOCOL gHttpDxeDriverBinding;\r
62extern EFI_COMPONENT_NAME2_PROTOCOL gHttpDxeComponentName2;\r
63extern EFI_COMPONENT_NAME_PROTOCOL gHttpDxeComponentName;\r
64\r
65//\r
66// Include files with function prototypes\r
67//\r
68#include "ComponentName.h"\r
69#include "HttpImpl.h"\r
70#include "HttpProto.h"\r
71#include "HttpDns.h"\r
72#include "HttpUtilities.h"\r
73\r
74typedef struct {\r
75 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
76 UINTN NumberOfChildren;\r
77 EFI_HANDLE *ChildHandleBuffer;\r
78} HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;\r
79\r
80/**\r
81 Tests to see if this driver supports a given controller. If a child device is provided, \r
82 it further tests to see if this driver supports creating a handle for the specified child device.\r
83\r
84 This function checks to see if the driver specified by This supports the device specified by \r
85 ControllerHandle. Drivers will typically use the device path attached to \r
86 ControllerHandle and/or the services from the bus I/O abstraction attached to \r
87 ControllerHandle to determine if the driver supports ControllerHandle. This function \r
88 may be called many times during platform initialization. In order to reduce boot times, the tests \r
89 performed by this function must be very small, and take as little time as possible to execute. This \r
90 function must not change the state of any hardware devices, and this function must be aware that the \r
91 device specified by ControllerHandle may already be managed by the same driver or a \r
92 different driver. This function must match its calls to AllocatePages() with FreePages(), \r
93 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). \r
94 Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
95 already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
96 to guarantee the state of ControllerHandle is not modified by this function.\r
97\r
98 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
99 @param[in] ControllerHandle The handle of the controller to test. This handle \r
100 must support a protocol interface that supplies \r
101 an I/O abstraction to the driver.\r
102 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r
103 parameter is ignored by device drivers, and is optional for bus \r
104 drivers. For bus drivers, if this parameter is not NULL, then \r
105 the bus driver must determine if the bus controller specified \r
106 by ControllerHandle and the child controller specified \r
107 by RemainingDevicePath are both supported by this \r
108 bus driver.\r
109\r
110 @retval EFI_SUCCESS The device specified by ControllerHandle and\r
111 RemainingDevicePath is supported by the driver specified by This.\r
112 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
113 RemainingDevicePath is already being managed by the driver\r
114 specified by This.\r
115 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
116 RemainingDevicePath is already being managed by a different\r
117 driver or an application that requires exclusive access.\r
118 Currently not implemented.\r
119 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
120 RemainingDevicePath is not supported by the driver specified by This.\r
121**/\r
122EFI_STATUS\r
123EFIAPI\r
124HttpDxeDriverBindingSupported (\r
125 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
126 IN EFI_HANDLE ControllerHandle,\r
127 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
128 );\r
129\r
130/**\r
131 Starts a device controller or a bus controller.\r
132\r
133 The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
134 As a result, much of the error checking on the parameters to Start() has been moved into this \r
135 common boot service. It is legal to call Start() from other locations, \r
136 but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
137 1. ControllerHandle must be a valid EFI_HANDLE.\r
138 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
139 EFI_DEVICE_PATH_PROTOCOL.\r
140 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
141 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r
142\r
143 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
144 @param[in] ControllerHandle The handle of the controller to start. This handle \r
145 must support a protocol interface that supplies \r
146 an I/O abstraction to the driver.\r
147 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This \r
148 parameter is ignored by device drivers, and is optional for bus \r
149 drivers. For a bus driver, if this parameter is NULL, then handles \r
150 for all the children of Controller are created by this driver. \r
151 If this parameter is not NULL and the first Device Path Node is \r
152 not the End of Device Path Node, then only the handle for the \r
153 child device specified by the first Device Path Node of \r
154 RemainingDevicePath is created by this driver.\r
155 If the first Device Path Node of RemainingDevicePath is \r
156 the End of Device Path Node, no child handle is created by this\r
157 driver.\r
158\r
159 @retval EFI_SUCCESS The device was started.\r
160 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r
161 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
162 @retval Others The driver failded to start the device.\r
163\r
164**/\r
165EFI_STATUS\r
166EFIAPI\r
167HttpDxeDriverBindingStart (\r
168 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
169 IN EFI_HANDLE ControllerHandle,\r
170 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
171 );\r
172\r
173/**\r
174 Stops a device controller or a bus controller.\r
175 \r
176 The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
177 As a result, much of the error checking on the parameters to Stop() has been moved \r
178 into this common boot service. It is legal to call Stop() from other locations, \r
179 but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
180 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
181 same driver's Start() function.\r
182 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
183 EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
184 Start() function, and the Start() function must have called OpenProtocol() on\r
185 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
186 \r
187 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
188 @param[in] ControllerHandle A handle to the device being stopped. The handle must \r
189 support a bus specific I/O protocol for the driver \r
190 to use to stop the device.\r
191 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
192 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r
193 if NumberOfChildren is 0.\r
194\r
195 @retval EFI_SUCCESS The device was stopped.\r
196 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
197\r
198**/\r
199EFI_STATUS\r
200EFIAPI\r
201HttpDxeDriverBindingStop (\r
202 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
203 IN EFI_HANDLE ControllerHandle,\r
204 IN UINTN NumberOfChildren,\r
205 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
206 );\r
207\r
208/**\r
209 Creates a child handle and installs a protocol.\r
210\r
211 The CreateChild() function installs a protocol on ChildHandle.\r
212 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.\r
213 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.\r
214\r
215 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
216 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,\r
217 then a new handle is created. If it is a pointer to an existing UEFI handle,\r
218 then the protocol is added to the existing UEFI handle.\r
219\r
220 @retval EFI_SUCCES The protocol was added to ChildHandle.\r
221 @retval EFI_INVALID_PARAMETER This is NULL, or ChildHandle is NULL.\r
222 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r
223 the child.\r
224 @retval other The child handle was not created.\r
225\r
226**/\r
227EFI_STATUS\r
228EFIAPI\r
229HttpServiceBindingCreateChild (\r
230 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
231 IN OUT EFI_HANDLE *ChildHandle\r
232 );\r
233\r
234/**\r
235 Destroys a child handle with a protocol installed on it.\r
236\r
237 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol\r
238 that was installed by CreateChild() from ChildHandle. If the removed protocol is the\r
239 last protocol on ChildHandle, then ChildHandle is destroyed.\r
240\r
241 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
242 @param ChildHandle Handle of the child to destroy\r
243\r
244 @retval EFI_SUCCES The protocol was removed from ChildHandle.\r
245 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.\r
246 @retval EFI_INVALID_PARAMETER Child handle is NULL.\r
247 @retval other The child handle was not destroyed\r
248\r
249**/\r
250EFI_STATUS\r
251EFIAPI\r
252HttpServiceBindingDestroyChild (\r
253 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
254 IN EFI_HANDLE ChildHandle\r
255 );\r
256\r
257\r
258extern EFI_HTTP_PROTOCOL mEfiHttpProtocolTemplete;\r
259\r
260#endif\r