]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
Fix the comments to follow UEFI Spec regarding how to check an EFI_HANDLE is valid...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Driver.h
index 82fd57c34da1453e487f6ce48b9a1e2759d5b14f..0a106a46fb9f355526781bcc6b63841635e657d4 100644 (file)
@@ -1,21 +1,15 @@
 /** @file\r
+  Tcp driver function header.\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
+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\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
-Module Name:\r
-\r
-  Tcp4Driver.h\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #ifndef _TCP4_DRIVER_H_\r
@@ -24,16 +18,30 @@ Abstract:
 #include <Protocol/ServiceBinding.h>\r
 #include <Library/IpIoLib.h>\r
 \r
-#define TCP4_DRIVER_SIGNATURE   EFI_SIGNATURE_32 ('T', 'C', 'P', '4')\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
+///\r
+/// TCP heartbeat tick timer.\r
+///\r
 typedef struct _TCP4_HEARTBEAT_TIMER {\r
-  EFI_EVENT  TimerEvent;\r
-  INTN       RefCnt;\r
+  EFI_EVENT  TimerEvent;         ///< The event assoiated with the timer\r
+  INTN       RefCnt;             ///< Number of reference\r
 } TCP4_HEARTBEAT_TIMER;\r
 \r
+///\r
+/// TCP service data\r
+///\r
 typedef struct _TCP4_SERVICE_DATA {\r
   UINT32                        Signature;\r
   EFI_HANDLE                    ControllerHandle;\r
@@ -44,18 +52,51 @@ typedef struct _TCP4_SERVICE_DATA {
   LIST_ENTRY                    SocketList;\r
 } TCP4_SERVICE_DATA;\r
 \r
-//\r
-// Prototype for TCP4 driver Rcv callback function registered to IP_IO\r
-//\r
+///\r
+/// TCP protocol data\r
+///\r
+typedef struct _TCP4_PROTO_DATA {\r
+  TCP4_SERVICE_DATA *TcpService;\r
+  TCP_CB            *TcpPcb;\r
+} TCP4_PROTO_DATA;\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
+EFIAPI\r
 Tcp4RxCallback (\r
   IN EFI_STATUS                       Status,\r
-  IN ICMP_ERROR                       IcmpErr,\r
+  IN UINT8                            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
@@ -64,29 +105,40 @@ TcpSendIpPacket (
   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
+  IN UINT8                   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
-#define TCP4_FROM_THIS(a) \\r
-  CR ( \\r
-  (a), \\r
-  TCP4_SERVICE_DATA, \\r
-  Tcp4ServiceBinding, \\r
-  TCP4_DRIVER_SIGNATURE \\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
-//\r
-// Function prototype for the driver's entry point\r
-//\r
+  @retval EFI_SUCCESS   Driver loaded.\r
+  @retval other         Driver not loaded.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Tcp4DriverEntryPoint (\r
@@ -94,9 +146,36 @@ Tcp4DriverEntryPoint (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   );\r
 \r
-//\r
-// Function prototypes for the Drivr Binding Protocol\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
@@ -105,6 +184,35 @@ Tcp4DriverBindingSupported (
   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
@@ -113,6 +221,33 @@ Tcp4DriverBindingStart (
   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
@@ -122,28 +257,82 @@ Tcp4DriverBindingStop (
   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
-// Function ptototypes for the ServiceBinding Prococol\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
+  IN     EFI_SERVICE_BINDING_PROTOCOL  *This,\r
+  IN OUT 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 NULL.\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