]>
Commit | Line | Data |
---|---|---|
83cbd279 | 1 | /** @file\r |
2 | \r | |
dfc1f033 | 3 | Copyright (c) 2005 - 2006, Intel Corporation<BR>\r |
83cbd279 | 4 | All rights reserved. This program and the accompanying materials\r |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
dfc1f033 | 7 | http://opensource.org/licenses/bsd-license.php<BR>\r |
83cbd279 | 8 | \r |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
83cbd279 | 12 | **/\r |
13 | \r | |
14 | #ifndef _TCP4_DRIVER_H_\r | |
15 | #define _TCP4_DRIVER_H_\r | |
16 | \r | |
17 | #include <Protocol/ServiceBinding.h>\r | |
18 | #include <Library/IpIoLib.h>\r | |
19 | \r | |
f3f2e05d | 20 | #define TCP4_DRIVER_SIGNATURE SIGNATURE_32 ('T', 'C', 'P', '4')\r |
83cbd279 | 21 | \r |
22 | #define TCP4_PORT_KNOWN 1024\r | |
23 | #define TCP4_PORT_USER_RESERVED 65535\r | |
24 | \r | |
dfc1f033 | 25 | #define TCP4_FROM_THIS(a) \\r |
26 | CR ( \\r | |
27 | (a), \\r | |
28 | TCP4_SERVICE_DATA, \\r | |
29 | Tcp4ServiceBinding, \\r | |
30 | TCP4_DRIVER_SIGNATURE \\r | |
31 | )\r | |
32 | \r | |
83cbd279 | 33 | typedef struct _TCP4_HEARTBEAT_TIMER {\r |
34 | EFI_EVENT TimerEvent;\r | |
35 | INTN RefCnt;\r | |
36 | } TCP4_HEARTBEAT_TIMER;\r | |
37 | \r | |
38 | typedef struct _TCP4_SERVICE_DATA {\r | |
39 | UINT32 Signature;\r | |
40 | EFI_HANDLE ControllerHandle;\r | |
41 | IP_IO *IpIo; // IP Io consumed by TCP4\r | |
42 | EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding;\r | |
43 | EFI_HANDLE DriverBindingHandle;\r | |
44 | CHAR16 *MacString;\r | |
e48e37fc | 45 | LIST_ENTRY SocketList;\r |
83cbd279 | 46 | } TCP4_SERVICE_DATA;\r |
47 | \r | |
dfc1f033 | 48 | \r |
49 | \r | |
50 | /**\r | |
51 | Packet receive callback function provided to IP_IO, used to call\r | |
52 | the proper function to handle the packet received by IP.\r | |
53 | \r | |
54 | @param Status Status of the received packet.\r | |
55 | @param IcmpErr ICMP error number.\r | |
56 | @param NetSession Pointer to the net session of this packet.\r | |
57 | @param Pkt Pointer to the recieved packet.\r | |
58 | @param Context Pointer to the context configured in IpIoOpen(), not used\r | |
59 | now.\r | |
60 | \r | |
61 | @return None\r | |
62 | \r | |
63 | **/\r | |
83cbd279 | 64 | VOID\r |
65 | Tcp4RxCallback (\r | |
66 | IN EFI_STATUS Status,\r | |
67 | IN ICMP_ERROR IcmpErr,\r | |
68 | IN EFI_NET_SESSION_DATA *NetSession,\r | |
69 | IN NET_BUF *Pkt,\r | |
70 | IN VOID *Context OPTIONAL\r | |
71 | );\r | |
72 | \r | |
dfc1f033 | 73 | /**\r |
74 | Send the segment to IP via IpIo function.\r | |
75 | \r | |
76 | @param Tcb Pointer to the TCP_CB of this TCP instance.\r | |
77 | @param Nbuf Pointer to the TCP segment to be sent.\r | |
78 | @param Src Source address of the TCP segment.\r | |
79 | @param Dest Destination address of the TCP segment.\r | |
80 | \r | |
81 | @retval 0 The segment was sent out successfully.\r | |
82 | @retval -1 The segment was failed to send.\r | |
83 | \r | |
84 | **/\r | |
83cbd279 | 85 | INTN\r |
86 | TcpSendIpPacket (\r | |
87 | IN TCP_CB *Tcb,\r | |
88 | IN NET_BUF *Nbuf,\r | |
89 | IN UINT32 Src,\r | |
90 | IN UINT32 Dest\r | |
91 | );\r | |
92 | \r | |
dfc1f033 | 93 | /**\r |
94 | The procotol handler provided to the socket layer, used to\r | |
95 | dispatch the socket level requests by calling the corresponding\r | |
96 | TCP layer functions.\r | |
97 | \r | |
98 | @param Sock Pointer to the socket of this TCP instance.\r | |
99 | @param Request The code of this operation request.\r | |
100 | @param Data Pointer to the operation specific data passed in\r | |
101 | together with the operation request.\r | |
102 | \r | |
103 | @retval EFI_SUCCESS The socket request is completed successfully.\r | |
104 | @retval other The error status returned by the corresponding TCP\r | |
105 | layer function.\r | |
106 | \r | |
107 | **/\r | |
83cbd279 | 108 | EFI_STATUS\r |
109 | Tcp4Dispatcher (\r | |
110 | IN SOCKET *Sock,\r | |
111 | IN SOCK_REQUEST Request,\r | |
dfc1f033 | 112 | IN VOID *Data OPTIONAL\r |
83cbd279 | 113 | );\r |
114 | \r | |
115 | typedef struct _TCP4_PROTO_DATA {\r | |
116 | TCP4_SERVICE_DATA *TcpService;\r | |
117 | TCP_CB *TcpPcb;\r | |
118 | } TCP4_PROTO_DATA;\r | |
119 | \r | |
dfc1f033 | 120 | /**\r |
121 | The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.\r | |
83cbd279 | 122 | \r |
dfc1f033 | 123 | @param ImageHandle The firmware allocated handle for this\r |
124 | driver image.\r | |
125 | @param SystemTable Pointer to the EFI system table.\r | |
126 | \r | |
127 | @retval EFI_SUCCESS Driver loaded.\r | |
128 | @retval other Driver not loaded.\r | |
129 | \r | |
130 | **/\r | |
83cbd279 | 131 | EFI_STATUS\r |
132 | EFIAPI\r | |
133 | Tcp4DriverEntryPoint (\r | |
134 | IN EFI_HANDLE ImageHandle,\r | |
135 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
136 | );\r | |
137 | \r | |
dfc1f033 | 138 | \r |
139 | /**\r | |
140 | Tests to see if this driver supports a given controller.\r | |
141 | \r | |
142 | If a child device is provided, it further tests to see if this driver supports \r | |
143 | creating a handle for the specified child device.\r | |
144 | \r | |
145 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
146 | @param ControllerHandle The handle of the controller to test. This handle \r | |
147 | must support a protocol interface that supplies \r | |
148 | an I/O abstraction to the driver.\r | |
149 | @param RemainingDevicePath A pointer to the remaining portion of a device path. \r | |
150 | This parameter is ignored by device drivers, and is optional for bus drivers.\r | |
151 | \r | |
152 | \r | |
153 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r | |
154 | RemainingDevicePath is supported by the driver \r | |
155 | specified by This.\r | |
156 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
157 | RemainingDevicePath is already being managed by \r | |
158 | the driver specified by This.\r | |
159 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
160 | RemainingDevicePath is already being managed by a \r | |
161 | different driver or an application that requires \r | |
162 | exclusive access.\r | |
163 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
164 | RemainingDevicePath is not supported by the driver \r | |
165 | specified by This.\r | |
166 | \r | |
167 | **/\r | |
83cbd279 | 168 | EFI_STATUS\r |
169 | EFIAPI\r | |
170 | Tcp4DriverBindingSupported (\r | |
120db52c | 171 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
83cbd279 | 172 | IN EFI_HANDLE ControllerHandle,\r |
120db52c | 173 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r |
83cbd279 | 174 | );\r |
175 | \r | |
dfc1f033 | 176 | /**\r |
177 | Start this driver on ControllerHandle. \r | |
178 | \r | |
179 | The Start() function is designed to be invoked from the EFI boot service \r | |
180 | ConnectController(). As a result, much of the error checking on the parameters \r | |
181 | to Start() has been moved into this common boot service. It is legal to call \r | |
182 | Start() from other locations, but the following calling restrictions must be \r | |
183 | followed or the system behavior will not be deterministic.\r | |
184 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
185 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally \r | |
186 | aligned EFI_DEVICE_PATH_PROTOCOL.\r | |
187 | 3. Prior to calling Start(), the Supported() function for the driver specified \r | |
188 | by This must have been called with the same calling parameters, and Supported() \r | |
189 | must have returned EFI_SUCCESS.\r | |
190 | \r | |
191 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
192 | @param ControllerHandle The handle of the controller to start. This handle \r | |
193 | must support a protocol interface that supplies \r | |
194 | an I/O abstraction to the driver.\r | |
195 | @param RemainingDevicePath A pointer to the remaining portion of a device path. \r | |
196 | This parameter is ignored by device drivers, and is \r | |
197 | optional for bus drivers.\r | |
198 | \r | |
199 | @retval EFI_SUCCESS The device was started.\r | |
200 | @retval EFI_ALREADY_STARTED The device could not be started due to a device error.\r | |
201 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack \r | |
202 | of resources.\r | |
203 | \r | |
204 | **/\r | |
83cbd279 | 205 | EFI_STATUS\r |
206 | EFIAPI\r | |
207 | Tcp4DriverBindingStart (\r | |
120db52c | 208 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
83cbd279 | 209 | IN EFI_HANDLE ControllerHandle,\r |
120db52c | 210 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r |
83cbd279 | 211 | );\r |
212 | \r | |
dfc1f033 | 213 | /**\r |
214 | Stop this driver on ControllerHandle.\r | |
215 | \r | |
216 | The Stop() function is designed to be invoked from the EFI boot service \r | |
217 | DisconnectController(). As a result, much of the error checking on the parameters \r | |
218 | to Stop() has been moved into this common boot service. It is legal to call Stop() \r | |
219 | from other locations, but the following calling restrictions must be followed \r | |
220 | or the system behavior will not be deterministic.\r | |
221 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call \r | |
222 | to this same driver's Start() function.\r | |
223 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
224 | EFI_HANDLE. In addition, all of these handles must have been created in this \r | |
225 | driver's Start() function, and the Start() function must have called OpenProtocol() \r | |
226 | on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
227 | \r | |
228 | @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
229 | @param ControllerHandle A handle to the device being stopped. The handle must \r | |
230 | support a bus specific I/O protocol for the driver \r | |
231 | to use to stop the device.\r | |
232 | @param NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
233 | @param ChildHandleBuffer An array of child handles to be freed. May be NULL if \r | |
234 | NumberOfChildren is 0.\r | |
235 | \r | |
236 | @retval EFI_SUCCESS The device was stopped.\r | |
237 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
238 | \r | |
239 | **/\r | |
83cbd279 | 240 | EFI_STATUS\r |
241 | EFIAPI\r | |
242 | Tcp4DriverBindingStop (\r | |
243 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
244 | IN EFI_HANDLE ControllerHandle,\r | |
245 | IN UINTN NumberOfChildren,\r | |
246 | IN EFI_HANDLE *ChildHandleBuffer\r | |
247 | );\r | |
248 | \r | |
dfc1f033 | 249 | /**\r |
250 | Open Ip4 and device path protocols for a created socket, and insert it in \r | |
251 | socket list.\r | |
252 | \r | |
253 | @param This Pointer to the socket just created\r | |
254 | @param Context Context of the socket\r | |
255 | \r | |
256 | @retval EFI_SUCCESS This protocol is installed successfully.\r | |
257 | @retval other Some error occured.\r | |
258 | \r | |
259 | **/\r | |
4f6e31e4 | 260 | EFI_STATUS\r |
261 | Tcp4CreateSocketCallback (\r | |
262 | IN SOCKET *This,\r | |
263 | IN VOID *Context\r | |
264 | );\r | |
265 | \r | |
dfc1f033 | 266 | /**\r |
267 | Close Ip4 and device path protocols for a socket, and remove it from socket list. \r | |
268 | \r | |
269 | @param This Pointer to the socket to be removed\r | |
270 | @param Context Context of the socket\r | |
271 | \r | |
272 | **/\r | |
4f6e31e4 | 273 | VOID\r |
274 | Tcp4DestroySocketCallback (\r | |
275 | IN SOCKET *This,\r | |
276 | IN VOID *Context\r | |
277 | );\r | |
278 | \r | |
dfc1f033 | 279 | /**\r |
280 | Creates a child handle and installs a protocol.\r | |
281 | \r | |
282 | The CreateChild() function installs a protocol on ChildHandle. If ChildHandle \r | |
283 | is a pointer to NULL, then a new handle is created and returned in ChildHandle. \r | |
284 | If ChildHandle is not a pointer to NULL, then the protocol installs on the existing \r | |
285 | ChildHandle.\r | |
286 | \r | |
287 | @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r | |
288 | @param ChildHandle Pointer to the handle of the child to create. If it is NULL, then \r | |
289 | a new handle is created. If it is a pointer to an existing UEFI \r | |
290 | handle, then the protocol is added to the existing UEFI handle.\r | |
291 | \r | |
292 | @retval EFI_SUCCES The protocol was added to ChildHandle.\r | |
293 | @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r | |
294 | @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r | |
295 | the child.\r | |
296 | @retval other The child handle was not created.\r | |
297 | \r | |
298 | **/\r | |
83cbd279 | 299 | EFI_STATUS\r |
300 | EFIAPI\r | |
301 | Tcp4ServiceBindingCreateChild (\r | |
302 | IN EFI_SERVICE_BINDING_PROTOCOL *This,\r | |
303 | IN EFI_HANDLE *ChildHandle\r | |
304 | );\r | |
305 | \r | |
dfc1f033 | 306 | /**\r |
307 | Destroys a child handle with a protocol installed on it.\r | |
308 | \r | |
309 | The DestroyChild() function does the opposite of CreateChild(). It removes a protocol \r | |
310 | that was installed by CreateChild() from ChildHandle. If the removed protocol is the \r | |
311 | last protocol on ChildHandle, then ChildHandle is destroyed.\r | |
312 | \r | |
313 | @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r | |
314 | @param ChildHandle Handle of the child to destroy\r | |
315 | \r | |
316 | @retval EFI_SUCCES The protocol was removed from ChildHandle.\r | |
317 | @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is \r | |
318 | being removed.\r | |
319 | @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.\r | |
320 | @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle\r | |
321 | because its services are being used.\r | |
322 | @retval other The child handle was not destroyed.\r | |
323 | \r | |
324 | **/\r | |
83cbd279 | 325 | EFI_STATUS\r |
326 | EFIAPI\r | |
327 | Tcp4ServiceBindingDestroyChild (\r | |
328 | IN EFI_SERVICE_BINDING_PROTOCOL *This,\r | |
329 | IN EFI_HANDLE ChildHandle\r | |
330 | );\r | |
331 | \r | |
332 | #endif\r |