-/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-Module Name:
-
- Tcp4Driver.h
-
-Abstract:
-
-
-**/
-
-#ifndef _TCP4_DRIVER_H_
-#define _TCP4_DRIVER_H_
-
-#include <Protocol/ServiceBinding.h>
-#include <Library/IpIoLib.h>
-
-#define TCP4_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('T', 'C', 'P', '4')
-
-#define TCP4_PORT_KNOWN 1024
-#define TCP4_PORT_USER_RESERVED 65535
-
-typedef struct _TCP4_HEARTBEAT_TIMER {
- EFI_EVENT TimerEvent;
- INTN RefCnt;
-} TCP4_HEARTBEAT_TIMER;
-
-typedef struct _TCP4_SERVICE_DATA {
- UINT32 Signature;
- EFI_HANDLE ControllerHandle;
- IP_IO *IpIo; // IP Io consumed by TCP4
- EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding;
- EFI_HANDLE DriverBindingHandle;
- CHAR16 *MacString;
-} TCP4_SERVICE_DATA;
-
-//
-// Prototype for TCP4 driver Rcv callback function registered to IP_IO
-//
-VOID
-Tcp4RxCallback (
- IN EFI_STATUS Status,
- IN ICMP_ERROR IcmpErr,
- IN EFI_NET_SESSION_DATA *NetSession,
- IN NET_BUF *Pkt,
- IN VOID *Context OPTIONAL
- );
-
-INTN
-TcpSendIpPacket (
- IN TCP_CB *Tcb,
- IN NET_BUF *Nbuf,
- IN UINT32 Src,
- IN UINT32 Dest
- );
-
-EFI_STATUS
-Tcp4Dispatcher (
- IN SOCKET *Sock,
- IN SOCK_REQUEST Request,
- IN VOID *Data OPTIONAL
- );
-
-typedef struct _TCP4_PROTO_DATA {
- TCP4_SERVICE_DATA *TcpService;
- TCP_CB *TcpPcb;
-} TCP4_PROTO_DATA;
-
-#define TCP4_FROM_THIS(a) \
- CR ( \
- (a), \
- TCP4_SERVICE_DATA, \
- Tcp4ServiceBinding, \
- TCP4_DRIVER_SIGNATURE \
- )
-
-//
-// Function prototype for the driver's entry point
-//
-EFI_STATUS
-EFIAPI
-Tcp4DriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-//
-// Function prototypes for the Drivr Binding Protocol
-//
-EFI_STATUS
-EFIAPI
-Tcp4DriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
- );
-
-EFI_STATUS
-EFIAPI
-Tcp4DriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
- );
-
-EFI_STATUS
-EFIAPI
-Tcp4DriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// Function ptototypes for the ServiceBinding Prococol
-//
-EFI_STATUS
-EFIAPI
-Tcp4ServiceBindingCreateChild (
- IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE *ChildHandle
- );
-
-EFI_STATUS
-EFIAPI
-Tcp4ServiceBindingDestroyChild (
- IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ChildHandle
- );
-
-#endif
+/** @file\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php<BR>\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _TCP4_DRIVER_H_\r
+#define _TCP4_DRIVER_H_\r
+\r
+#include <Protocol/ServiceBinding.h>\r
+#include <Library/IpIoLib.h>\r
+\r
+#define TCP4_DRIVER_SIGNATURE SIGNATURE_32 ('T', 'C', 'P', '4')\r
+\r
+#define TCP4_PORT_KNOWN 1024\r
+#define TCP4_PORT_USER_RESERVED 65535\r
+\r
+#define TCP4_FROM_THIS(a) \\r
+ CR ( \\r
+ (a), \\r
+ TCP4_SERVICE_DATA, \\r
+ Tcp4ServiceBinding, \\r
+ TCP4_DRIVER_SIGNATURE \\r
+ )\r
+\r
+typedef struct _TCP4_HEARTBEAT_TIMER {\r
+ EFI_EVENT TimerEvent;\r
+ INTN RefCnt;\r
+} TCP4_HEARTBEAT_TIMER;\r
+\r
+typedef struct _TCP4_SERVICE_DATA {\r
+ UINT32 Signature;\r
+ EFI_HANDLE ControllerHandle;\r
+ IP_IO *IpIo; // IP Io consumed by TCP4\r
+ EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding;\r
+ EFI_HANDLE DriverBindingHandle;\r
+ CHAR16 *MacString;\r
+ LIST_ENTRY SocketList;\r
+} TCP4_SERVICE_DATA;\r
+\r
+\r
+\r
+/**\r
+ Packet receive callback function provided to IP_IO, used to call\r
+ the proper function to handle the packet received by IP.\r
+\r
+ @param Status Status of the received packet.\r
+ @param IcmpErr ICMP error number.\r
+ @param NetSession Pointer to the net session of this packet.\r
+ @param Pkt Pointer to the recieved packet.\r
+ @param Context Pointer to the context configured in IpIoOpen(), not used\r
+ now.\r
+\r
+ @return None\r
+\r
+**/\r
+VOID\r
+Tcp4RxCallback (\r
+ IN EFI_STATUS Status,\r
+ IN ICMP_ERROR IcmpErr,\r
+ IN EFI_NET_SESSION_DATA *NetSession,\r
+ IN NET_BUF *Pkt,\r
+ IN VOID *Context OPTIONAL\r
+ );\r
+\r
+/**\r
+ Send the segment to IP via IpIo function.\r
+\r
+ @param Tcb Pointer to the TCP_CB of this TCP instance.\r
+ @param Nbuf Pointer to the TCP segment to be sent.\r
+ @param Src Source address of the TCP segment.\r
+ @param Dest Destination address of the TCP segment.\r
+\r
+ @retval 0 The segment was sent out successfully.\r
+ @retval -1 The segment was failed to send.\r
+\r
+**/\r
+INTN\r
+TcpSendIpPacket (\r
+ IN TCP_CB *Tcb,\r
+ IN NET_BUF *Nbuf,\r
+ IN UINT32 Src,\r
+ IN UINT32 Dest\r
+ );\r
+\r
+/**\r
+ The procotol handler provided to the socket layer, used to\r
+ dispatch the socket level requests by calling the corresponding\r
+ TCP layer functions.\r
+\r
+ @param Sock Pointer to the socket of this TCP instance.\r
+ @param Request The code of this operation request.\r
+ @param Data Pointer to the operation specific data passed in\r
+ together with the operation request.\r
+\r
+ @retval EFI_SUCCESS The socket request is completed successfully.\r
+ @retval other The error status returned by the corresponding TCP\r
+ layer function.\r
+\r
+**/\r
+EFI_STATUS\r
+Tcp4Dispatcher (\r
+ IN SOCKET *Sock,\r
+ IN SOCK_REQUEST Request,\r
+ IN VOID *Data OPTIONAL\r
+ );\r
+\r
+typedef struct _TCP4_PROTO_DATA {\r
+ TCP4_SERVICE_DATA *TcpService;\r
+ TCP_CB *TcpPcb;\r
+} TCP4_PROTO_DATA;\r
+\r
+/**\r
+ The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.\r
+\r
+ @param ImageHandle The firmware allocated handle for this\r
+ driver image.\r
+ @param SystemTable Pointer to the EFI system table.\r
+\r
+ @retval EFI_SUCCESS Driver loaded.\r
+ @retval other Driver not loaded.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Tcp4DriverEntryPoint (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ );\r
+\r
+\r
+/**\r
+ Tests to see if this driver supports a given controller.\r
+ \r
+ If a child device is provided, it further tests to see if this driver supports \r
+ creating a handle for the specified child device.\r
+\r
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param ControllerHandle The handle of the controller to test. This handle \r
+ must support a protocol interface that supplies \r
+ an I/O abstraction to the driver.\r
+ @param RemainingDevicePath A pointer to the remaining portion of a device path. \r
+ This parameter is ignored by device drivers, and is optional for bus drivers.\r
+\r
+\r
+ @retval EFI_SUCCESS The device specified by ControllerHandle and\r
+ RemainingDevicePath is supported by the driver \r
+ specified by This.\r
+ @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
+ RemainingDevicePath is already being managed by \r
+ the driver specified by This.\r
+ @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
+ RemainingDevicePath is already being managed by a \r
+ different driver or an application that requires \r
+ exclusive access.\r
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
+ RemainingDevicePath is not supported by the driver \r
+ specified by This.\r
+ \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Tcp4DriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ );\r
+\r
+/**\r
+ Start this driver on ControllerHandle. \r
+ \r
+ The Start() function is designed to be invoked from the EFI boot service \r
+ ConnectController(). As a result, much of the error checking on the parameters \r
+ to Start() has been moved into this common boot service. It is legal to call \r
+ Start() from other locations, but the following calling restrictions must be \r
+ followed or the system behavior will not be deterministic.\r
+ 1. ControllerHandle must be a valid EFI_HANDLE.\r
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally \r
+ aligned EFI_DEVICE_PATH_PROTOCOL.\r
+ 3. Prior to calling Start(), the Supported() function for the driver specified \r
+ by This must have been called with the same calling parameters, and Supported() \r
+ must have returned EFI_SUCCESS.\r
+\r
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param ControllerHandle The handle of the controller to start. This handle \r
+ must support a protocol interface that supplies \r
+ an I/O abstraction to the driver.\r
+ @param RemainingDevicePath A pointer to the remaining portion of a device path. \r
+ This parameter is ignored by device drivers, and is \r
+ optional for bus drivers.\r
+\r
+ @retval EFI_SUCCESS The device was started.\r
+ @retval EFI_ALREADY_STARTED The device could not be started due to a device error.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack \r
+ of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Tcp4DriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ );\r
+\r
+/**\r
+ Stop this driver on ControllerHandle.\r
+ \r
+ The Stop() function is designed to be invoked from the EFI boot service \r
+ DisconnectController(). As a result, much of the error checking on the parameters \r
+ to Stop() has been moved into this common boot service. It is legal to call Stop() \r
+ from other locations, but the following calling restrictions must be followed \r
+ or the system behavior will not be deterministic.\r
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call \r
+ to this same driver's Start() function.\r
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+ EFI_HANDLE. In addition, all of these handles must have been created in this \r
+ driver's Start() function, and the Start() function must have called OpenProtocol() \r
+ on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+ \r
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param ControllerHandle A handle to the device being stopped. The handle must \r
+ support a bus specific I/O protocol for the driver \r
+ to use to stop the device.\r
+ @param NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
+ @param ChildHandleBuffer An array of child handles to be freed. May be NULL if \r
+ NumberOfChildren is 0.\r
+\r
+ @retval EFI_SUCCESS The device was stopped.\r
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Tcp4DriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ );\r
+\r
+/**\r
+ Open Ip4 and device path protocols for a created socket, and insert it in \r
+ socket list.\r
+ \r
+ @param This Pointer to the socket just created\r
+ @param Context Context of the socket\r
+ \r
+ @retval EFI_SUCCESS This protocol is installed successfully.\r
+ @retval other Some error occured.\r
+ \r
+**/\r
+EFI_STATUS\r
+Tcp4CreateSocketCallback (\r
+ IN SOCKET *This,\r
+ IN VOID *Context\r
+ );\r
+\r
+/**\r
+ Close Ip4 and device path protocols for a socket, and remove it from socket list. \r
+ \r
+ @param This Pointer to the socket to be removed\r
+ @param Context Context of the socket\r
+ \r
+**/\r
+VOID\r
+Tcp4DestroySocketCallback (\r
+ IN SOCKET *This,\r
+ IN VOID *Context\r
+ );\r
+\r
+/**\r
+ Creates a child handle and installs a protocol.\r
+ \r
+ The CreateChild() function installs a protocol on ChildHandle. If ChildHandle \r
+ is a pointer to NULL, then a new handle is created and returned in ChildHandle. \r
+ If ChildHandle is not a pointer to NULL, then the protocol installs on the existing \r
+ ChildHandle.\r
+\r
+ @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
+ @param ChildHandle Pointer to the handle of the child to create. If it is NULL, then \r
+ a new handle is created. If it is a pointer to an existing UEFI \r
+ handle, then the protocol is added to the existing UEFI handle.\r
+\r
+ @retval EFI_SUCCES The protocol was added to ChildHandle.\r
+ @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r
+ the child.\r
+ @retval other The child handle was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Tcp4ServiceBindingCreateChild (\r
+ IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE *ChildHandle\r
+ );\r
+\r
+/**\r
+ Destroys a child handle with a protocol installed on it.\r
+ \r
+ The DestroyChild() function does the opposite of CreateChild(). It removes a protocol \r
+ that was installed by CreateChild() from ChildHandle. If the removed protocol is the \r
+ last protocol on ChildHandle, then ChildHandle is destroyed.\r
+\r
+ @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
+ @param ChildHandle Handle of the child to destroy\r
+\r
+ @retval EFI_SUCCES The protocol was removed from ChildHandle.\r
+ @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is \r
+ being removed.\r
+ @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.\r
+ @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle\r
+ because its services are being used.\r
+ @retval other The child handle was not destroyed.\r
+ \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Tcp4ServiceBindingDestroyChild (\r
+ IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ChildHandle\r
+ );\r
+\r
+#endif\r