]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Insert comments for functions/macros and add the file headers.
authorniry <niry@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 16 Jan 2009 06:56:18 +0000 (06:56 +0000)
committerniry <niry@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 16 Jan 2009 06:56:18 +0000 (06:56 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7293 6f19259b-4bc3-4df7-8a09-765794883524

23 files changed:
MdeModulePkg/Universal/Network/Mtftp4Dxe/ComponentName.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.h
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.h
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h
MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h

index 256d86aaa2b04a003fbd3ee0fb531450fcffa6f3..36a1c19d26b2e49df096da4eeed553aa352ff9a5 100644 (file)
@@ -1,21 +1,15 @@
 /** @file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+  UEFI Component Name(2) protocol implementation for Mtftp4Dxe driver.\r
+  \r
+Copyright (c) 2006 - 2007, 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\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
-  ComponentName.c\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #include "Mtftp4Driver.h"\r
@@ -33,10 +27,10 @@ Abstract:
   by This does not support the language specified by Language,\r
   then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language. This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
@@ -45,7 +39,7 @@ Abstract:
                                 to the driver writer. Language is specified\r
                                 in RFC 3066 or ISO 639-2 language code format.\r
 \r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+  @param[out]  DriverName       A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 driver specified by This in the language\r
                                 specified by Language.\r
@@ -65,9 +59,9 @@ Abstract:
 EFI_STATUS\r
 EFIAPI\r
 Mtftp4ComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
+  IN     EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN     CHAR8                        *Language,\r
+     OUT CHAR16                       **DriverName\r
   );\r
 \r
 \r
@@ -84,15 +78,15 @@ Mtftp4ComponentNameGetDriverName (
   then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
   support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+  @param[in]  ControllerHandle  The handle of a controller that the driver\r
                                 specified by This is managing.  This handle\r
                                 specifies the controller whose name is to be\r
                                 returned.\r
 \r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+  @param[in]  ChildHandle       The handle of the child controller to retrieve\r
                                 the name of.  This is an optional parameter that\r
                                 may be NULL.  It will be NULL for device\r
                                 drivers.  It will also be NULL for a bus drivers\r
@@ -101,7 +95,7 @@ Mtftp4ComponentNameGetDriverName (
                                 driver that wishes to retrieve the name of a\r
                                 child controller.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language.  This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
@@ -110,7 +104,7 @@ Mtftp4ComponentNameGetDriverName (
                                 to the driver writer. Language is specified in\r
                                 RFC 3066 or ISO 639-2 language code format.\r
 \r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+  @param[out]  ControllerName   A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 controller specified by ControllerHandle and\r
                                 ChildHandle in the language specified by\r
@@ -142,26 +136,26 @@ Mtftp4ComponentNameGetDriverName (
 EFI_STATUS\r
 EFIAPI\r
 Mtftp4ComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
+  IN     EFI_COMPONENT_NAME_PROTOCOL               *This,\r
+  IN     EFI_HANDLE                                ControllerHandle,\r
+  IN     EFI_HANDLE                                ChildHandle        OPTIONAL,\r
+  IN     CHAR8                                     *Language,\r
+     OUT CHAR16                                    **ControllerName\r
   );\r
 \r
 \r
-//\r
-// EFI Component Name Protocol\r
-//\r
+///\r
+/// EFI Component Name Protocol\r
+///\r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gMtftp4ComponentName = {\r
   Mtftp4ComponentNameGetDriverName,\r
   Mtftp4ComponentNameGetControllerName,\r
   "eng"\r
 };\r
 \r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
+///\r
+/// EFI Component Name 2 Protocol\r
+///\r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2 = {\r
   (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Mtftp4ComponentNameGetDriverName,\r
   (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Mtftp4ComponentNameGetControllerName,\r
@@ -190,10 +184,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable[]
   by This does not support the language specified by Language,\r
   then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language. This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
@@ -202,7 +196,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable[]
                                 to the driver writer. Language is specified\r
                                 in RFC 3066 or ISO 639-2 language code format.\r
 \r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+  @param[out]  DriverName       A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 driver specified by This in the language\r
                                 specified by Language.\r
@@ -222,9 +216,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMtftp4DriverNameTable[]
 EFI_STATUS\r
 EFIAPI\r
 Mtftp4ComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
+  IN     EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN     CHAR8                        *Language,\r
+     OUT CHAR16                       **DriverName\r
   )\r
 {\r
   return LookupUnicodeString2 (\r
@@ -249,15 +243,15 @@ Mtftp4ComponentNameGetDriverName (
   then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
   support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param[in]  This              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+  @param[in]  ControllerHandle  The handle of a controller that the driver\r
                                 specified by This is managing.  This handle\r
                                 specifies the controller whose name is to be\r
                                 returned.\r
 \r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+  @param[in]  ChildHandle       The handle of the child controller to retrieve\r
                                 the name of.  This is an optional parameter that\r
                                 may be NULL.  It will be NULL for device\r
                                 drivers.  It will also be NULL for a bus drivers\r
@@ -266,7 +260,7 @@ Mtftp4ComponentNameGetDriverName (
                                 driver that wishes to retrieve the name of a\r
                                 child controller.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param[in]  Language          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language.  This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
@@ -275,7 +269,7 @@ Mtftp4ComponentNameGetDriverName (
                                 to the driver writer. Language is specified in\r
                                 RFC 3066 or ISO 639-2 language code format.\r
 \r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+  @param[out]  ControllerName   A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 controller specified by ControllerHandle and\r
                                 ChildHandle in the language specified by\r
@@ -307,11 +301,11 @@ Mtftp4ComponentNameGetDriverName (
 EFI_STATUS\r
 EFIAPI\r
 Mtftp4ComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
+  IN     EFI_COMPONENT_NAME_PROTOCOL               *This,\r
+  IN     EFI_HANDLE                                ControllerHandle,\r
+  IN     EFI_HANDLE                                ChildHandle        OPTIONAL,\r
+  IN     CHAR8                                     *Language,\r
+     OUT CHAR16                                    **ControllerName\r
   )\r
 {\r
   return EFI_UNSUPPORTED;\r
index 5886b94351a9d55bfddb3c614be38cb2d6cb61d3..ceeee0545e6876fe0c2e0f33d4c08fe0de0286be 100644 (file)
@@ -1,21 +1,15 @@
 /** @file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+  Implementation of Mtftp drivers.\r
+  \r
+Copyright (c) 2006 - 2007, 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\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
-  Mtftp4Driver.c\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #include "Mtftp4Impl.h"\r
@@ -34,29 +28,23 @@ EFI_SERVICE_BINDING_PROTOCOL  gMtftp4ServiceBindingTemplete = {
   Mtftp4ServiceBindingDestroyChild\r
 };\r
 \r
+\r
+/**\r
+  The driver entry point which installs multiple protocols to the ImageHandle.\r
+\r
+  @param ImageHandle    The MTFTP's image handle.\r
+  @param SystemTable    The system table.\r
+\r
+  @retval EFI_SUCCESS  The handles are successfully installed on the image. \r
+  @retval others       some EFI_ERROR occured.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 Mtftp4DriverEntryPoint (\r
   IN EFI_HANDLE             ImageHandle,\r
   IN EFI_SYSTEM_TABLE       *SystemTable\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The driver entry point which installs multiple protocols to the ImageHandle.\r
-\r
-Arguments:\r
-\r
-  ImageHandle - The MTFTP's image handle\r
-  SystemTable - The system table\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - The handles are successfully installed on the image. Otherwise\r
-  some EFI_ERROR.\r
-\r
---*/\r
 {\r
   return EfiLibInstallDriverBindingComponentName2 (\r
            ImageHandle,\r
@@ -82,6 +70,7 @@ Returns:
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4DriverBindingSupported (\r
   IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
   IN EFI_HANDLE                     Controller,\r
@@ -104,9 +93,10 @@ Mtftp4DriverBindingSupported (
 \r
 \r
 /**\r
-  Config a NULL UDP that is used to keep the connection between UDP\r
-  and MTFTP. Just leave the Udp child unconfigured. When UDP is\r
-  unloaded, MTFTP will be informed with DriverBinding Stop.\r
+  Config a NULL UDP that is used to keep the connection between UDP and MTFTP. \r
+  \r
+  Just leave the Udp child unconfigured. When UDP is unloaded, \r
+    MTFTP will be informed with DriverBinding Stop.\r
 \r
   @param  UdpIo                  The UDP port to configure\r
   @param  Context                The opaque parameter to the callback\r
@@ -142,9 +132,9 @@ Mtftp4ConfigNullUdp (
 **/\r
 EFI_STATUS\r
 Mtftp4CreateService (\r
-  IN  EFI_HANDLE            Controller,\r
-  IN  EFI_HANDLE            Image,\r
-  OUT MTFTP4_SERVICE        **Service\r
+  IN     EFI_HANDLE            Controller,\r
+  IN     EFI_HANDLE            Image,\r
+     OUT MTFTP4_SERVICE        **Service\r
   )\r
 {\r
   MTFTP4_SERVICE            *MtftpSb;\r
@@ -221,8 +211,6 @@ Mtftp4CreateService (
 \r
   @param  MtftpSb                The MTFTP service binding instance.\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 Mtftp4CleanService (\r
@@ -236,8 +224,9 @@ Mtftp4CleanService (
 \r
 \r
 /**\r
-  Start the MTFTP driver on this controller. MTFTP driver will\r
-  install a MTFTP SERVICE BINDING protocol on the supported\r
+  Start the MTFTP driver on this controller. \r
+  \r
+  MTFTP driver will install a MTFTP SERVICE BINDING protocol on the supported\r
   controller, which can be used to create/destroy MTFTP children.\r
 \r
   @param  This                   The MTFTP driver binding protocol.\r
@@ -251,6 +240,7 @@ Mtftp4CleanService (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4DriverBindingStart (\r
   IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN EFI_HANDLE                   Controller,\r
@@ -326,11 +316,12 @@ ON_ERROR:
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4DriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL *This,\r
-  IN  EFI_HANDLE                  Controller,\r
-  IN  UINTN                       NumberOfChildren,\r
-  IN  EFI_HANDLE                  *ChildHandleBuffer\r
+  IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+  IN EFI_HANDLE                  Controller,\r
+  IN UINTN                       NumberOfChildren,\r
+  IN EFI_HANDLE                  *ChildHandleBuffer\r
   )\r
 {\r
   EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;\r
@@ -408,13 +399,11 @@ Mtftp4DriverBindingStop (
   @param  MtftpSb                The MTFTP service binding protocol.\r
   @param  Instance               The MTFTP instance to initialize.\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 Mtftp4InitProtocol (\r
-  IN MTFTP4_SERVICE         *MtftpSb,\r
-  IN MTFTP4_PROTOCOL        *Instance\r
+  IN     MTFTP4_SERVICE         *MtftpSb,\r
+     OUT MTFTP4_PROTOCOL        *Instance\r
   )\r
 {\r
   ZeroMem (Instance, sizeof (MTFTP4_PROTOCOL));\r
@@ -423,7 +412,7 @@ Mtftp4InitProtocol (
   InitializeListHead (&Instance->Link);\r
   CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (Instance->Mtftp4));\r
   Instance->State     = MTFTP4_STATE_UNCONFIGED;\r
-  Instance->Indestory = FALSE;\r
+  Instance->InDestory = FALSE;\r
   Instance->Service   = MtftpSb;\r
 \r
   InitializeListHead (&Instance->Blocks);\r
@@ -443,9 +432,10 @@ Mtftp4InitProtocol (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4ServiceBindingCreateChild (\r
   IN EFI_SERVICE_BINDING_PROTOCOL  *This,\r
-  IN OUT EFI_HANDLE                *ChildHandle\r
+  IN EFI_HANDLE                *ChildHandle\r
   )\r
 {\r
   MTFTP4_SERVICE            *MtftpSb;\r
@@ -552,6 +542,7 @@ ON_ERROR:
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4ServiceBindingDestroyChild (\r
   IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
   IN EFI_HANDLE                   ChildHandle\r
@@ -590,11 +581,11 @@ Mtftp4ServiceBindingDestroyChild (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (Instance->Indestory) {\r
+  if (Instance->InDestory) {\r
     return EFI_SUCCESS;\r
   }\r
 \r
-  Instance->Indestory = TRUE;\r
+  Instance->InDestory = TRUE;\r
 \r
   //\r
   // Close the Udp4 protocol.\r
@@ -616,7 +607,7 @@ Mtftp4ServiceBindingDestroyChild (
                   );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    Instance->Indestory = FALSE;\r
+    Instance->InDestory = FALSE;\r
     return Status;\r
   }\r
 \r
index b6eba0cea6ed784b0dcd89950d68d3b581a8969b..d5e760b0a1fda5f66258699a3e258145d1282287 100644 (file)
 /** @file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+  Mtftp drivers function header.\r
+  \r
+Copyright (c) 2006 - 2007, 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\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
-  Mtftp4Driver.h\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #ifndef __EFI_MTFTP4_DRIVER_H__\r
 #define __EFI_MTFTP4_DRIVER_H__\r
 \r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
 \r
 #include <Protocol/ServiceBinding.h>\r
 \r
 #include <Library/NetLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+\r
+extern EFI_COMPONENT_NAME_PROTOCOL   gMtftp4ComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL  gMtftp4ComponentName2;\r
+extern EFI_DRIVER_BINDING_PROTOCOL   gMtftp4DriverBinding;\r
 \r
+/**\r
+  Test whether MTFTP driver support this controller.\r
 \r
+  @param  This                   The MTFTP driver binding instance\r
+  @param  Controller             The controller to test\r
+  @param  RemainingDevicePath    The remaining device path\r
+\r
+  @retval EFI_SUCCESS            The controller has UDP service binding protocol\r
+                                 installed, MTFTP can support it.\r
+  @retval Others                 MTFTP can't support the controller.\r
+\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4DriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   );\r
 \r
+/**\r
+  Start the MTFTP driver on this controller. \r
+  \r
+  MTFTP driver will install a MTFTP SERVICE BINDING protocol on the supported\r
+  controller, which can be used to create/destroy MTFTP children.\r
+\r
+  @param  This                   The MTFTP driver binding protocol.\r
+  @param  Controller             The controller to manage.\r
+  @param  RemainingDevicePath    Remaining device path.\r
+\r
+  @retval EFI_ALREADY_STARTED    The MTFTP service binding protocol has been\r
+                                 started  on the controller.\r
+  @retval EFI_SUCCESS            The MTFTP service binding is installed on the\r
+                                 controller.\r
+\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4DriverBindingStart (\r
   IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN EFI_HANDLE                   Controller,\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   );\r
 \r
+/**\r
+  Stop the MTFTP driver on controller. The controller is a UDP\r
+  child handle.\r
+\r
+  @param  This                   The MTFTP driver binding protocol\r
+  @param  Controller             The controller to stop\r
+  @param  NumberOfChildren       The number of children\r
+  @param  ChildHandleBuffer      The array of the child handle.\r
+\r
+  @retval EFI_SUCCESS            The driver is stopped on the controller.\r
+  @retval EFI_DEVICE_ERROR       Failed to stop the driver on the controller.\r
+\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4DriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL *This,\r
-  IN  EFI_HANDLE                  Controller,\r
-  IN  UINTN                       NumberOfChildren,\r
-  IN  EFI_HANDLE                  *ChildHandleBuffer\r
+  IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+  IN EFI_HANDLE                  Controller,\r
+  IN UINTN                       NumberOfChildren,\r
+  IN EFI_HANDLE                  *ChildHandleBuffer\r
   );\r
 \r
+/**\r
+  Create a MTFTP child for the service binding instance, then\r
+  install the MTFTP protocol to the ChildHandle.\r
+\r
+  @param  This                   The MTFTP service binding instance.\r
+  @param  ChildHandle            The Child handle to install the MTFTP protocol.\r
+\r
+  @retval EFI_INVALID_PARAMETER  The parameter is invalid.\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resource for the new child.\r
+  @retval EFI_SUCCESS            The child is successfully create.\r
+\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4ServiceBindingCreateChild (\r
-  IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
-  IN OUT EFI_HANDLE               *ChildHandle\r
+  IN EFI_SERVICE_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                *ChildHandle\r
   );\r
 \r
+/**\r
+  Destory one of the service binding's child.\r
+\r
+  @param  This                   The service binding instance\r
+  @param  ChildHandle            The child handle to destory\r
+\r
+  @retval EFI_INVALID_PARAMETER  The parameter is invaid.\r
+  @retval EFI_UNSUPPORTED        The child may have already been destoried.\r
+  @retval EFI_SUCCESS            The child is destoried and removed from the\r
+                                 parent's child list.\r
+\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 Mtftp4ServiceBindingDestroyChild (\r
   IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
   IN EFI_HANDLE                   ChildHandle\r
   );\r
 \r
-extern EFI_COMPONENT_NAME_PROTOCOL   gMtftp4ComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gMtftp4ComponentName2;\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gMtftp4DriverBinding;\r
+\r
 \r
 #endif\r
index b31a50209aecfad18e782f7dafc45062b822449f..34c5aeaa7ffac94b0633dd4f5482070e74d825ab 100644 (file)
@@ -1,50 +1,41 @@
 /** @file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+  Interface routine for Mtftp4.\r
+  \r
+Copyright (c) 2006 - 2007, 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\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
-  Mtftp4Impl.c\r
-\r
-Abstract:\r
-\r
-  Interface routine for Mtftp4\r
-\r
-\r
 **/\r
 \r
-#include "Mtftp4Impl.h"\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-EfiMtftp4ReadFile (\r
-  IN EFI_MTFTP4_PROTOCOL    *This,\r
-  IN EFI_MTFTP4_TOKEN       *Token\r
-  );\r
+#include "Mtftp4Impl.h"\r
 \r
 \r
 /**\r
-  Get the current operation parameter for the MTFTP session\r
+  Reads the current operational settings.\r
 \r
-  @param  This                   The MTFTP protocol instance\r
-  @param  ModeData               The MTFTP mode data\r
+  The GetModeData()function reads the current operational settings of this \r
+  EFI MTFTPv4 Protocol driver instance.\r
 \r
-  @retval EFI_INVALID_PARAMETER  This or ModeData is NULL\r
-  @retval EFI_SUCCESS            The operation parameter is saved in ModeData\r
+  @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance.\r
+  @param  ModeData               Pointer to storage for the EFI MTFTPv4 Protocol\r
+                                 driver mode data. \r
 \r
+  @retval EFI_SUCCESS            The configuration data was successfully returned.\r
+  @retval EFI_OUT_OF_RESOURCES   The required mode data could not be allocated.\r
+  @retval EFI_INVALID_PARAMETER  This is NULL or ModeData is NULL.\r
+  \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 EfiMtftp4GetModeData (\r
-  IN EFI_MTFTP4_PROTOCOL    *This,\r
-  OUT EFI_MTFTP4_MODE_DATA  *ModeData\r
+  IN     EFI_MTFTP4_PROTOCOL    *This,\r
+     OUT EFI_MTFTP4_MODE_DATA  *ModeData\r
   )\r
 {\r
   MTFTP4_PROTOCOL  *Instance;\r
@@ -75,14 +66,11 @@ EfiMtftp4GetModeData (
   @param  Instance               The MTFTP session to clean up\r
   @param  Result                 The result to return to the caller who initiated\r
                                  the operation.\r
-\r
-  @return None\r
-\r
 **/\r
 VOID\r
 Mtftp4CleanOperation (\r
-  IN MTFTP4_PROTOCOL        *Instance,\r
-  IN EFI_STATUS             Result\r
+  IN OUT MTFTP4_PROTOCOL        *Instance,\r
+  IN     EFI_STATUS             Result\r
   )\r
 {\r
   LIST_ENTRY                *Entry;\r
@@ -145,15 +133,50 @@ Mtftp4CleanOperation (
 \r
 \r
 /**\r
-  Configure the MTFTP session for new operation or reset the current\r
-  operation if ConfigData is NULL.\r
-\r
-  @param  This                   The MTFTP session to configure\r
-  @param  ConfigData             The configure parameters\r
-\r
-  @retval EFI_INVALID_PARAMETER  Some of the parameter is invalid.\r
-  @retval EFI_ACCESS_DENIED      There is pending operation\r
-  @retval EFI_SUCCESS            The instance is configured for operation.\r
+  Initializes, changes, or resets the default operational setting for this \r
+  EFI MTFTPv4 Protocol driver instance.\r
+  \r
+  The Configure() function is used to set and change the configuration data for \r
+  this EFI MTFTPv4 Protocol driver instance. The configuration data can be reset \r
+  to startup defaults by calling Configure() with MtftpConfigData set to NULL. \r
+  Whenever the instance is reset, any pending operation is aborted. By changing \r
+  the EFI MTFTPv4 Protocol driver instance configuration data, the client can \r
+  connect to different MTFTPv4 servers. The configuration parameters in \r
+  MtftpConfigData are used as the default parameters in later MTFTPv4 operations \r
+  and can be overridden in later operations.\r
+  \r
+  @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance\r
+  @param  ConfigData             MtftpConfigDataPointer to the configuration data \r
+                                 structure\r
+\r
+  @retval EFI_SUCCESS            The EFI MTFTPv4 Protocol driver was configured \r
+                                 successfully.\r
+  @retval EFI_INVALID_PARAMETER  One or more following conditions are TRUE:\r
+                                 1.This is NULL.\r
+                                 2.MtftpConfigData.UseDefaultSetting is FALSE and \r
+                                   MtftpConfigData.StationIp is not a valid IPv4 \r
+                                   unicast address.\r
+                                 3.MtftpCofigData.UseDefaultSetting is FALSE and \r
+                                   MtftpConfigData.SubnetMask is invalid.\r
+                                 4.MtftpCofigData.ServerIp is not a valid IPv4 \r
+                                   unicast address.\r
+                                 5.MtftpConfigData.UseDefaultSetting is FALSE and \r
+                                   MtftpConfigData.GatewayIp is not a valid IPv4 \r
+                                   unicast address or is not in the same subnet \r
+                                   with station address.\r
+  @retval EFI_ACCESS_DENIED      The EFI configuration could not be changed at this \r
+                                 time because there is one MTFTP background operation \r
+                                 in progress.\r
+  @retval EFI_NO_MAPPING         When using a default address, configuration \r
+                                 (DHCP, BOOTP, RARP, etc.) has not finished yet.\r
+  @retval EFI_UNSUPPORTED        A configuration protocol (DHCP, BOOTP, RARP, etc.) \r
+                                 could not be located when clients choose to use \r
+                                 the default address settings.\r
+  @retval EFI_OUT_OF_RESOURCES   The EFI MTFTPv4 Protocol driver instance data could \r
+                                 not be allocated.\r
+  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred. \r
+                                 The EFI MTFTPv4 Protocol driver instance is not \r
+                                 configured.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -213,7 +236,7 @@ EfiMtftp4Configure (
     }\r
 \r
     if ((Gateway != 0) &&\r
-       (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !Ip4IsUnicast (Gateway, Netmask))) {\r
+        (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !Ip4IsUnicast (Gateway, Netmask))) {\r
 \r
       return EFI_INVALID_PARAMETER;\r
     }\r
@@ -236,9 +259,10 @@ EfiMtftp4Configure (
 \r
 \r
 /**\r
-  Check packet for GetInfo. GetInfo is implemented with EfiMtftp4ReadFile.\r
-  It use Mtftp4GetInfoCheckPacket to inspect the first packet from server,\r
-  then abort the session.\r
+  Check packet for GetInfo. \r
+  \r
+  GetInfo is implemented with EfiMtftp4ReadFile. It use Mtftp4GetInfoCheckPacket \r
+  to inspect the first packet from server, then abort the session.\r
 \r
   @param  This                   The MTFTP4 protocol instance\r
   @param  Token                  The user's token\r
@@ -300,108 +324,43 @@ Mtftp4GetInfoCheckPacket (
 \r
 \r
 /**\r
-  Get the information of the download from the server. It is implemented\r
-  with EfiMtftp4ReadFile: build a token, then pass it to EfiMtftp4ReadFile.\r
-  In its check packet callback abort the opertions.\r
-\r
-  @param  This                   The MTFTP protocol instance\r
-  @param  OverrideData           The MTFTP override data\r
-  @param  Filename               The file to get information\r
-  @param  ModeStr                The mode to use\r
-  @param  OptionCount            The number of options to append\r
-  @param  OptionList             The options to append\r
-  @param  PacketLength           The variable to receive the packet length\r
-  @param  Packet                 The variable to receive the packet.\r
-\r
-  @retval EFI_INVALID_PARAMETER  The parameter is invaid\r
-  @retval EFI_SUCCESS            The information is got\r
-  @retval Others                 Failed to get the information.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EfiMtftp4GetInfo (\r
-  IN EFI_MTFTP4_PROTOCOL      *This,\r
-  IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData,        OPTIONAL\r
-  IN UINT8                    *Filename,\r
-  IN UINT8                    *ModeStr,             OPTIONAL\r
-  IN UINT8                    OptionCount,\r
-  IN EFI_MTFTP4_OPTION        *OptionList,\r
-  OUT UINT32                  *PacketLength,\r
-  OUT EFI_MTFTP4_PACKET       **Packet OPTIONAL\r
-  )\r
-{\r
-  EFI_MTFTP4_TOKEN          Token;\r
-  MTFTP4_PROTOCOL           *Instance;\r
-  MTFTP4_GETINFO_STATE      *State;\r
-  EFI_STATUS                Status;\r
-\r
-  if ((This == NULL) || (Filename == NULL) || (PacketLength == NULL) ||\r
-      (OptionCount && (OptionList == NULL))) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Packet != NULL) {\r
-    *Packet = NULL;\r
-  }\r
-\r
-  *PacketLength         = 0;\r
-  Instance              = MTFTP4_PROTOCOL_FROM_THIS (This);\r
-  State                 = &Instance->GetInfoState;\r
-  State->Packet          = Packet;\r
-  State->PacketLen       = PacketLength;\r
-  State->Status          = EFI_SUCCESS;\r
-\r
-  //\r
-  // Fill in the Token to issue an synchronous ReadFile operation\r
-  //\r
-  Token.Status          = EFI_SUCCESS;\r
-  Token.Event           = NULL;\r
-  Token.OverrideData    = OverrideData;\r
-  Token.Filename        = Filename;\r
-  Token.ModeStr         = ModeStr;\r
-  Token.OptionCount     = OptionCount;\r
-  Token.OptionList      = OptionList;\r
-  Token.BufferSize      = 0;\r
-  Token.Buffer          = NULL;\r
-  Token.CheckPacket     = Mtftp4GetInfoCheckPacket;\r
-  Token.TimeoutCallback = NULL;\r
-  Token.PacketNeeded    = NULL;\r
-\r
-  Status                = EfiMtftp4ReadFile (This, &Token);\r
-\r
-  if (EFI_ABORTED == Status) {\r
-    return State->Status;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Parse the packet into an array of options. The OptionList is allocated\r
-  by this function, and caller should free it when used.\r
-\r
-  @param  This                   The MTFTP protocol instance\r
-  @param  PacketLen              The length of the packet\r
-  @param  Packet                 The packet to parse\r
-  @param  OptionCount            The size of the OptionList array allocated.\r
-  @param  OptionList             The allocated option array to save the option\r
-                                 addresses.\r
-\r
-  @retval EFI_INVALID_PARAMETER  The parameters are invalid.\r
-  @retval EFI_NOT_FOUND          There is no valid option in the packet\r
-  @retval EFI_SUCCESS            The packet is parsed.\r
+  Parses the options in an MTFTPv4 OACK packet.\r
+  \r
+  The ParseOptions() function parses the option fields in an MTFTPv4 OACK packet \r
+  and returns the number of options that were found and optionally a list of \r
+  pointers to the options in the packet.\r
+  If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is \r
+  returned and *OptionCount and *OptionList stop at the last valid option.\r
+  The OptionList is allocated by this function, and caller should free it when used.\r
+\r
+  @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance.\r
+  @param  PacketLen              Length of the OACK packet to be parsed.\r
+  @param  Packet                 Pointer to the OACK packet to be parsed. \r
+  @param  OptionCount            Pointer to the number of options in following OptionList.\r
+  @param  OptionList             Pointer to EFI_MTFTP4_OPTION storage. Call the \r
+                                 EFI Boot Service FreePool() to release theOptionList\r
+                                 if the options in this OptionList are not needed \r
+                                 any more\r
+\r
+  @retval EFI_SUCCESS            The OACK packet was valid and the OptionCount and\r
+                                 OptionList parameters have been updated.\r
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:\r
+                                 1.PacketLen is 0.\r
+                                 2.Packet is NULL or Packet is not a valid MTFTPv4 packet.\r
+                                 3.OptionCount is NULL.\r
+  @retval EFI_NOT_FOUND          No options were found in the OACK packet.\r
+  @retval EFI_OUT_OF_RESOURCES   Storage for the OptionList array cannot be allocated.\r
+  @retval EFI_PROTOCOL_ERROR     One or more of the option fields is invalid.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 EfiMtftp4ParseOptions (\r
-  IN EFI_MTFTP4_PROTOCOL    *This,\r
-  IN UINT32                 PacketLen,\r
-  IN EFI_MTFTP4_PACKET      *Packet,\r
-  IN OUT UINT32             *OptionCount,\r
-  OUT EFI_MTFTP4_OPTION     **OptionList          OPTIONAL\r
+  IN     EFI_MTFTP4_PROTOCOL    *This,\r
+  IN     UINT32                 PacketLen,\r
+  IN     EFI_MTFTP4_PACKET      *Packet,\r
+     OUT UINT32                 *OptionCount,\r
+     OUT EFI_MTFTP4_OPTION      **OptionList          OPTIONAL\r
   )\r
 {\r
   EFI_STATUS                Status;\r
@@ -427,16 +386,18 @@ EfiMtftp4ParseOptions (
 \r
 \r
 /**\r
-  Check whether the override data is valid. It will first\r
-  validate whether the server is a valid unicast. If a gateway\r
-  is provided in the Override, it also check that it is a\r
-  unicast on the connected network.\r
+  Check whether the override data is valid. \r
+  \r
+  It will first validate whether the server is a valid unicast. If a gateway\r
+  is provided in the Override, it also check that it is a unicast on the \r
+  connected network.\r
 \r
   @param  Instance               The MTFTP instance\r
   @param  Override               The override data to validate.\r
 \r
-  @return TRUE if the override data is valid, otherwise FALSE.\r
-\r
+  @retval TRUE                   The override data is valid\r
+  @retval FALSE                  The override data is invalid\r
+  \r
 **/\r
 BOOLEAN\r
 Mtftp4OverrideValid (\r
@@ -477,16 +438,18 @@ Mtftp4OverrideValid (
 \r
 /**\r
   Poll the UDP to get the IP4 default address, which may be retrieved\r
-  by DHCP. The default time out value is 5 seconds. If IP has retrieved\r
-  the default address, the UDP is reconfigured.\r
+  by DHCP. \r
+  \r
+  The default time out value is 5 seconds. If IP has retrieved the default address, \r
+  the UDP is reconfigured.\r
 \r
   @param  Instance               The Mtftp instance\r
   @param  UdpPort                The UDP port to poll\r
   @param  UdpCfgData             The UDP configure data to reconfigure the UDP\r
                                  port.\r
 \r
-  @return TRUE if the default address is retrieved and UDP is reconfigured.\r
-  @return Otherwise FALSE.\r
+  @retval TRUE                   The default address is retrieved and UDP is reconfigured.\r
+  @retval FALSE                  Some error occured.\r
 \r
 **/\r
 BOOLEAN\r
@@ -781,15 +744,32 @@ ON_ERROR:
 \r
 \r
 /**\r
-  Read a file from the server.\r
-\r
-  @param  This                   The Mtftp protocol instance.\r
-  @param  Token                  The user's request wrap token.\r
-\r
-  @retval EFI_SUCCESS            The ReadFile has finished, the file has been\r
-                                 downloaded if it is synchronous operation,\r
-                                 otherwise it has been  initated.\r
-  @retval Others                 Some error happened.\r
+  Downloads a file from an MTFTPv4 server.\r
+  \r
+  The ReadFile() function is used to initialize and start an MTFTPv4 download \r
+  process and optionally wait for completion. When the download operation completes, \r
+  whether successfully or not, the Token.Status field is updated by the EFI MTFTPv4 \r
+  Protocol driver and then Token.Event is signaled (if it is not NULL).\r
+  Data can be downloaded from the MTFTPv4 server into either of the following locations:\r
+  1.A fixed buffer that is pointed to by Token.Buffer\r
+  2.A download service function that is pointed to by Token.CheckPacket\r
+  If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket \r
+  will be called first. If the call is successful, the packet will be stored in \r
+  Token.Buffer.\r
+\r
+  @param  This                  Pointer to the EFI_MTFTP4_PROTOCOL instance\r
+  @param  Token                 Pointer to the token structure to provide the \r
+                                parameters that are used in this operation.\r
+\r
+  @retval EFI_SUCCESS           The data file has been transferred successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.\r
+  @retval EFI_BUFFER_TOO_SMALL  BufferSize is not large enough to hold the downloaded \r
+                                data in downloading process.\r
+  @retval EFI_ABORTED           Current operation is aborted by user.\r
+  @retval EFI_ICMP_ERROR        An ICMP ERROR packet was received.\r
+  @retval EFI_TIMEOUT           No responses were received from the MTFTPv4 server.\r
+  @retval EFI_TFTP_ERROR        An MTFTPv4 ERROR packet was received.\r
+  @retval EFI_DEVICE_ERROR      An unexpected network error or system error occurred.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -804,15 +784,53 @@ EfiMtftp4ReadFile (
 \r
 \r
 /**\r
-  Upload a file to the server.\r
-\r
-  @param  This                   The MTFTP protocol session\r
-  @param  Token                  The user's request wrap token.\r
-\r
-  @retval EFI_SUCCESS            The WriteFile has finished, the file has been\r
-                                 uploaded if it is synchronous operation, otherwise\r
-                                 it has been  initated.\r
-  @retval Others                 Some error happened.\r
+  Sends a data file to an MTFTPv4 server. May be unsupported in some EFI implementations\r
+\r
+  The WriteFile() function is used to initialize an uploading operation with the \r
+  given option list and optionally wait for completion. If one or more of the \r
+  options is not supported by the server, the unsupported options are ignored and \r
+  a standard TFTP process starts instead. When the upload process completes, \r
+  whether successfully or not, Token.Event is signaled, and the EFI MTFTPv4 Protocol \r
+  driver updates Token.Status.\r
+  The caller can supply the data to be uploaded in the following two modes:\r
+  1.Through the user-provided buffer\r
+  2.Through a callback function\r
+  With the user-provided buffer, the Token.BufferSize field indicates the length\r
+  of the buffer, and the driver will upload the data in the buffer. With an \r
+  EFI_MTFTP4_PACKET_NEEDED callback function, the driver will call this callback \r
+  function to get more data from the user to upload. See the definition of \r
+  EFI_MTFTP4_PACKET_NEEDED for more information. These two modes cannot be used at \r
+  the same time. The callback function will be ignored if the user provides the buffer.\r
+\r
+  @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance.\r
+  @param  Token                  Pointer to the token structure to provide the \r
+                                 parameters that are used in this function\r
+\r
+  @retval EFI_SUCCESS            The upload session has started.\r
+  @retval EFI_UNSUPPORTED        The operation is not supported by this implementation.\r
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:\r
+                                 1. This is NULL.\r
+                                 2. Token is NULL.\r
+                                 3. Token.Filename is NULL.\r
+                                 4. Token.OptionCount is not zero and\r
+                                    Token.OptionList is NULL.\r
+                                 5. One or more options in Token.OptionList have wrong\r
+                                    format.\r
+                                 6. Token.Buffer and Token.PacketNeeded are both\r
+                                    NULL.\r
+                                 7. One or more IPv4 addresses in Token.OverrideData \r
+                                    are not valid unicast IPv4 addresses if \r
+                                    Token.OverrideData is not NULL.\r
+  @retval EFI_UNSUPPORTED        One or more options in the Token.OptionList are in the\r
+                                 unsupported list of structure EFI_MTFTP4_MODE_DATA.\r
+  @retval EFI_NOT_STARTED        The EFI MTFTPv4 Protocol driver has not been started.\r
+  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP, \r
+                                 BOOTP, RARP, etc.) is not finished yet.\r
+  @retval EFI_ALREADY_STARTED    This Token is already being used in another MTFTPv4 \r
+                                 session.\r
+  @retval EFI_OUT_OF_RESOURCES   Required system resources could not be allocated.\r
+  @retval EFI_ACCESS_DENIED      The previous operation has not completed yet.\r
+  @retval EFI_DEVICE_ERROR       An unexpected network error or system error occurred.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -827,16 +845,62 @@ EfiMtftp4WriteFile (
 \r
 \r
 /**\r
-  Read a directory from the server. The only difference\r
-  between ReadFile and ReadDirectory is the opcode used.\r
-\r
-  @param  This                   The MTFTP protocol session\r
-  @param  Token                  The user's request wrap token.\r
-\r
-  @retval EFI_SUCCESS            The ReadDirectory has finished, the directory has\r
-                                 been  downloaded as a file if it is synchronous\r
-                                 operation,  otherwise it has been initated.\r
-  @retval Others                 Some error happened.\r
+  Downloads a data file "directory" from an MTFTPv4 server. \r
+  May be unsupported in some EFI implementations\r
+  \r
+  The ReadDirectory() function is used to return a list of files on the MTFTPv4 \r
+  server that are logically (or operationally) related to Token.Filename. The \r
+  directory request packet that is sent to the server is built with the option \r
+  list that was provided by caller, if present.\r
+  The file information that the server returns is put into either of the following \r
+  locations:\r
+  1.A fixed buffer that is pointed to by Token.Buffer\r
+  2.A download service function that is pointed to by Token.CheckPacket\r
+  If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket will \r
+  be called first. If the call is successful, the packet will be stored in Token.Buffer.\r
+  The returned directory listing in the Token.Buffer or EFI_MTFTP4_PACKET consists \r
+  of a list of two or three variable-length ASCII strings, each terminated by a \r
+  null character, for each file in the directory. If the multicast option is involved, \r
+  the first field of each directory entry is the static multicast IP address and \r
+  UDP port number that is associated with the file name. The format of the field \r
+  is ip:ip:ip:ip:port. If the multicast option is not involved, this field and its \r
+  terminating null character are not present.\r
+  The next field of each directory entry is the file name and the last field is \r
+  the file information string. The information string contains the file size and \r
+  the create/modify timestamp. The format of the information string is filesize \r
+  yyyy-mm-dd hh:mm:ss:ffff. The timestamp is Coordinated Universal Time \r
+  (UTC; also known as Greenwich Mean Time [GMT]).\r
+  The only difference between ReadFile and ReadDirectory is the opcode used.\r
+\r
+  @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance\r
+  @param  Token                  Pointer to the token structure to provide the \r
+                                 parameters that are used in this function\r
+\r
+  @retval EFI_SUCCESS            The MTFTPv4 related file "directory" has been downloaded.\r
+  @retval EFI_UNSUPPORTED        The operation is not supported by this implementation.\r
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:\r
+                                 1. This is NULL.\r
+                                 2. Token is NULL.\r
+                                 3. Token.Filename is NULL.\r
+                                 4. Token.OptionCount is not zero and\r
+                                    Token.OptionList is NULL.\r
+                                 5. One or more options in Token.OptionList have wrong\r
+                                    format.\r
+                                 6. Token.Buffer and Token.PacketNeeded are both\r
+                                    NULL.\r
+                                 7. One or more IPv4 addresses in Token.OverrideData \r
+                                    are not valid unicast IPv4 addresses if \r
+                                    Token.OverrideData is not NULL.\r
+  @retval EFI_UNSUPPORTED        One or more options in the Token.OptionList are in the\r
+                                 unsupported list of structure EFI_MTFTP4_MODE_DATA.\r
+  @retval EFI_NOT_STARTED        The EFI MTFTPv4 Protocol driver has not been started.\r
+  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP, \r
+                                 BOOTP, RARP, etc.) is not finished yet.\r
+  @retval EFI_ALREADY_STARTED    This Token is already being used in another MTFTPv4 \r
+                                 session.\r
+  @retval EFI_OUT_OF_RESOURCES   Required system resources could not be allocated.\r
+  @retval EFI_ACCESS_DENIED      The previous operation has not completed yet.\r
+  @retval EFI_DEVICE_ERROR       An unexpected network error or system error occurred.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -851,13 +915,139 @@ EfiMtftp4ReadDirectory (
 \r
 \r
 /**\r
-  Poll the network stack to accelerate the packet process.\r
+  Gets information about a file from an MTFTPv4 server. \r
+  \r
+  The GetInfo() function assembles an MTFTPv4 request packet with options; \r
+  sends it to the MTFTPv4 server; and may return an MTFTPv4 OACK, MTFTPv4 ERROR, \r
+  or ICMP ERROR packet. Retries occur only if no response packets are received \r
+  from the MTFTPv4 server before the timeout expires.\r
+  It is implemented with EfiMtftp4ReadFile: build a token, then pass it to \r
+  EfiMtftp4ReadFile. In its check packet callback abort the opertions.\r
+\r
+  @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance\r
+  @param  OverrideData           Data that is used to override the existing \r
+                                 parameters. If NULL, the default parameters that \r
+                                 were set in the EFI_MTFTP4_PROTOCOL.Configure() \r
+                                 function are used\r
+  @param  Filename               Pointer to ASCIIZ file name string\r
+  @param  ModeStr                Pointer to ASCIIZ mode string. If NULL, "octet" \r
+                                 will be used\r
+  @param  OptionCount            Number of option/value string pairs in OptionList\r
+  @param  OptionList             Pointer to array of option/value string pairs. \r
+                                 Ignored if OptionCount is zero\r
+  @param  PacketLength           The number of bytes in the returned packet\r
+  @param  Packet                 PacketThe pointer to the received packet. This \r
+                                 buffer must be freed by the caller.\r
+\r
+  @retval EFI_SUCCESS            An MTFTPv4 OACK packet was received and is in \r
+                                 the Buffer.\r
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:\r
+                                 1.This is NULL.\r
+                                 2.Filename is NULL.\r
+                                 3.OptionCount is not zero and OptionList is NULL.\r
+                                 4.One or more options in OptionList have wrong format.\r
+                                 5.PacketLength is NULL.\r
+                                 6.One or more IPv4 addresses in OverrideData are \r
+                                   not valid unicast IPv4 addresses if OverrideData \r
+                                   is not NULL.\r
+  @retval EFI_UNSUPPORTED        One or more options in the OptionList are in the\r
+                                 unsupported list of structure EFI_MTFTP4_MODE_DATA\r
+  @retval EFI_NOT_STARTED        The EFI MTFTPv4 Protocol driver has not been started.\r
+  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP, \r
+                                 BOOTP, RARP, etc.) has not finished yet.\r
+  @retval EFI_ACCESS_DENIED      The previous operation has not completed yet.\r
+  @retval EFI_OUT_OF_RESOURCES   Required system resources could not be allocated.\r
+  @retval EFI_TFTP_ERROR         An MTFTPv4 ERROR packet was received and is in \r
+                                 the Buffer.\r
+  @retval EFI_ICMP_ERROR         An ICMP ERROR packet was received and the Packet \r
+                                 is set to NULL.\r
+  @retval EFI_PROTOCOL_ERROR     An unexpected MTFTPv4 packet was received and is \r
+                                 in the Buffer.\r
+  @retval EFI_TIMEOUT            No responses were received from the MTFTPv4 server.\r
+  @retval EFI_DEVICE_ERROR       An unexpected network error or system error occurred.\r
+  \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMtftp4GetInfo (\r
+  IN     EFI_MTFTP4_PROTOCOL      *This,\r
+  IN     EFI_MTFTP4_OVERRIDE_DATA *OverrideData        OPTIONAL,\r
+  IN     UINT8                    *Filename,\r
+  IN     UINT8                    *ModeStr             OPTIONAL,\r
+  IN     UINT8                    OptionCount,\r
+  IN     EFI_MTFTP4_OPTION        *OptionList          OPTIONAL,\r
+     OUT UINT32                   *PacketLength,\r
+     OUT EFI_MTFTP4_PACKET        **Packet             OPTIONAL\r
+  )\r
+{\r
+  EFI_MTFTP4_TOKEN          Token;\r
+  MTFTP4_PROTOCOL           *Instance;\r
+  MTFTP4_GETINFO_STATE      *State;\r
+  EFI_STATUS                Status;\r
+\r
+  if ((This == NULL) || (Filename == NULL) || (PacketLength == NULL) ||\r
+      ((OptionCount != 0) && (OptionList == NULL))) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (Packet != NULL) {\r
+    *Packet = NULL;\r
+  }\r
+\r
+  *PacketLength         = 0;\r
+  Instance              = MTFTP4_PROTOCOL_FROM_THIS (This);\r
+  State                 = &Instance->GetInfoState;\r
+  State->Packet         = Packet;\r
+  State->PacketLen      = PacketLength;\r
+  State->Status         = EFI_SUCCESS;\r
+\r
+  //\r
+  // Fill in the Token to issue an synchronous ReadFile operation\r
+  //\r
+  Token.Status          = EFI_SUCCESS;\r
+  Token.Event           = NULL;\r
+  Token.OverrideData    = OverrideData;\r
+  Token.Filename        = Filename;\r
+  Token.ModeStr         = ModeStr;\r
+  Token.OptionCount     = OptionCount;\r
+  Token.OptionList      = OptionList;\r
+  Token.BufferSize      = 0;\r
+  Token.Buffer          = NULL;\r
+  Token.CheckPacket     = Mtftp4GetInfoCheckPacket;\r
+  Token.TimeoutCallback = NULL;\r
+  Token.PacketNeeded    = NULL;\r
+\r
+  Status                = EfiMtftp4ReadFile (This, &Token);\r
 \r
-  @param  This                   The MTFTP protocol instance.\r
+  if (EFI_ABORTED == Status) {\r
+    return State->Status;\r
+  }\r
+\r
+  return Status;\r
+}\r
 \r
+/**\r
+  Polls for incoming data packets and processes outgoing data packets.\r
+\r
+  The Poll() function can be used by network drivers and applications to increase \r
+  the rate that data packets are moved between the communications device and the \r
+  transmit and receive queues.\r
+  In some systems, the periodic timer event in the managed network driver may not \r
+  poll the underlying communications device fast enough to transmit and/or receive \r
+  all data packets without missing incoming packets or dropping outgoing packets. \r
+  Drivers and applications that are experiencing packet loss should try calling \r
+  the Poll() function more often.\r
+  \r
+  @param  This                   Pointer to the EFI_MTFTP4_PROTOCOL instance\r
+\r
+  @retval EFI_SUCCESS            Incoming or outgoing data was processed.\r
+  @retval EFI_NOT_STARTED        This EFI MTFTPv4 Protocol instance has not been started.\r
+  @retval EFI_NO_MAPPING         When using a default address, configuration (DHCP,\r
+                                 BOOTP, RARP, etc.) is not finished yet.\r
   @retval EFI_INVALID_PARAMETER  This is NULL.\r
-  @retval EFI_NOT_STARTED        The MTFTP session hasn't been configured.\r
-  @retval EFI_DEVICE_ERROR       The MTFTP session has been destoried.\r
+  @retval EFI_DEVICE_ERROR       An unexpected system or network error occurred.\r
+  @retval EFI_TIMEOUT            Data was dropped out of the transmit and/or receive \r
+                                 queue. Consider increasing the polling rate.\r
 \r
 **/\r
 EFI_STATUS\r
index 780a86a0014b51e3f593baef4898121cc9d96a4a..efc0e4a8fe4a448ea27188535a099c958a16d911 100644 (file)
@@ -1,46 +1,39 @@
 /** @file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+  \r
+  Mtftp4 Implementation.\r
+  \r
+  Mtftp4 Implementation, it supports the following RFCs:\r
+  RFC1350 - THE TFTP PROTOCOL (REVISION 2)\r
+  RFC2090 - TFTP Multicast Option\r
+  RFC2347 - TFTP Option Extension\r
+  RFC2348 - TFTP Blocksize Option\r
+  RFC2349 - TFTP Timeout Interval and Transfer Size Options\r
+  \r
+Copyright (c) 2006 - 2007, 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\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
-  Mtftp4Impl.h\r
-\r
-Abstract:\r
-\r
- Mtftp4 Implementation, it supports the following RFCs:\r
-   RFC1350 - THE TFTP PROTOCOL (REVISION 2)\r
-   RFC2090 - TFTP Multicast Option\r
-   RFC2347 - TFTP Option Extension\r
-   RFC2348 - TFTP Blocksize Option\r
-   RFC2349 - TFTP Timeout Interval and Transfer Size Options\r
-\r
-\r
 **/\r
 \r
+\r
 #ifndef __EFI_MTFTP4_IMPL_H__\r
 #define __EFI_MTFTP4_IMPL_H__\r
 \r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
 \r
 #include <Protocol/Udp4.h>\r
 #include <Protocol/Mtftp4.h>\r
 \r
 #include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
 #include <Library/UdpIoLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
+\r
+extern EFI_MTFTP4_PROTOCOL  gMtftp4ProtocolTemplate;\r
 \r
 typedef struct _MTFTP4_SERVICE  MTFTP4_SERVICE;\r
 typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;\r
@@ -49,7 +42,11 @@ typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;
 #include "Mtftp4Option.h"\r
 #include "Mtftp4Support.h"\r
 \r
-enum {\r
+\r
+///\r
+/// Some constant value of Mtftp service.\r
+///\r
+typedef enum {\r
   MTFTP4_SERVICE_SIGNATURE   = SIGNATURE_32 ('T', 'F', 'T', 'P'),\r
   MTFTP4_PROTOCOL_SIGNATURE  = SIGNATURE_32 ('t', 'f', 't', 'p'),\r
 \r
@@ -62,8 +59,11 @@ enum {
   MTFTP4_STATE_UNCONFIGED    = 0,\r
   MTFTP4_STATE_CONFIGED,\r
   MTFTP4_STATE_DESTORY\r
-};\r
+} MTFTP4_SERVICE_CONST_VALUE;\r
 \r
+///\r
+/// Mtftp service block\r
+///\r
 struct _MTFTP4_SERVICE {\r
   UINT32                        Signature;\r
   EFI_SERVICE_BINDING_PROTOCOL  ServiceBinding;\r
@@ -86,6 +86,7 @@ struct _MTFTP4_SERVICE {
   UDP_IO_PORT                   *ConnectUdp;\r
 };\r
 \r
+\r
 typedef struct {\r
   EFI_MTFTP4_PACKET             **Packet;\r
   UINT32                        *PacketLen;\r
@@ -98,7 +99,7 @@ struct _MTFTP4_PROTOCOL {
   EFI_MTFTP4_PROTOCOL           Mtftp4;\r
 \r
   INTN                          State;\r
-  BOOLEAN                       Indestory;\r
+  BOOLEAN                       InDestory;\r
 \r
   MTFTP4_SERVICE                *Service;\r
   EFI_HANDLE                    Handle;\r
@@ -150,22 +151,57 @@ struct _MTFTP4_PROTOCOL {
   MTFTP4_GETINFO_STATE          GetInfoState;\r
 };\r
 \r
+/**\r
+  Clean up the MTFTP session to get ready for new operation.\r
+\r
+  @param  Instance               The MTFTP session to clean up\r
+  @param  Result                 The result to return to the caller who initiated\r
+                                 the operation.\r
+**/\r
 VOID\r
 Mtftp4CleanOperation (\r
-  IN MTFTP4_PROTOCOL            *Instance,\r
-  IN EFI_STATUS                 Result\r
+  IN OUT MTFTP4_PROTOCOL        *Instance,\r
+  IN     EFI_STATUS             Result\r
   );\r
 \r
+/**\r
+  Start the MTFTP session for upload.\r
+  \r
+  It will first init some states, then send the WRQ request packet, \r
+  and start receiving the packet.\r
+\r
+  @param  Instance              The MTFTP session\r
+  @param  Operation             Redundant parameter, which is always\r
+                                EFI_MTFTP4_OPCODE_WRQ here.\r
+\r
+  @retval EFI_SUCCESS           The upload process has been started.\r
+  @retval Others                Failed to start the upload.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4WrqStart (\r
-  IN MTFTP4_PROTOCOL            *Instance,\r
-  IN UINT16                     Operation\r
+  IN MTFTP4_PROTOCOL        *Instance,\r
+  IN UINT16                 Operation\r
   );\r
 \r
+/**\r
+  Start the MTFTP session to download. \r
+  \r
+  It will first initialize some of the internal states then build and send a RRQ \r
+  reqeuest packet, at last, it will start receive for the downloading.\r
+\r
+  @param  Instance              The Mtftp session\r
+  @param  Operation             The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ\r
+                                or EFI_MTFTP4_OPCODE_DIR.\r
+\r
+  @retval EFI_SUCCESS           The mtftp download session is started.\r
+  @retval Others                Failed to start downloading.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4RrqStart (\r
-  IN MTFTP4_PROTOCOL            *Instance,\r
-  IN UINT16                     Operation\r
+  IN MTFTP4_PROTOCOL        *Instance,\r
+  IN UINT16                 Operation\r
   );\r
 \r
 #define MTFTP4_SERVICE_FROM_THIS(a)   \\r
@@ -174,5 +210,4 @@ Mtftp4RrqStart (
 #define MTFTP4_PROTOCOL_FROM_THIS(a)  \\r
   CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)\r
 \r
-extern EFI_MTFTP4_PROTOCOL  gMtftp4ProtocolTemplate;\r
 #endif\r
index 6ae404b22a849b2cc4631395e6151538077e90b2..0f66fe5433676df8ff7d13da0bbfe01cf985bcd0 100644 (file)
@@ -1,22 +1,15 @@
 /** @file\r
-\r
-Copyright (c) 2006, Intel Corporation\r
+  Routines to process MTFTP4 options.\r
+  \r
+Copyright (c) 2006 - 2007, 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\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
-  Mtftp4Option.c\r
-\r
-Abstract:\r
-  routines to process MTFTP4 options\r
-\r
-\r
 **/\r
 \r
 #include "Mtftp4Impl.h"\r
@@ -46,10 +39,10 @@ CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] = {
 **/\r
 EFI_STATUS\r
 Mtftp4FillOptions (\r
-  IN  EFI_MTFTP4_PACKET     *Packet,\r
-  IN  UINT32                PacketLen,\r
-  IN  OUT UINT32            *Count,\r
-  OUT EFI_MTFTP4_OPTION     *Options          OPTIONAL\r
+  IN     EFI_MTFTP4_PACKET     *Packet,\r
+  IN     UINT32                PacketLen,\r
+  IN OUT UINT32                *Count,\r
+     OUT EFI_MTFTP4_OPTION     *Options          OPTIONAL\r
   )\r
 {\r
   UINT8                     *Cur;\r
@@ -103,8 +96,9 @@ Mtftp4FillOptions (
 \r
 \r
 /**\r
-  Allocate and fill in a array of Mtftp options from the Packet. It\r
-  first calls Mtftp4FillOption to get the option number, then allocate\r
+  Allocate and fill in a array of Mtftp options from the Packet. \r
+  \r
+  It first calls Mtftp4FillOption to get the option number, then allocate\r
   the array, at last, call Mtftp4FillOption again to save the options.\r
 \r
   @param  Packet                 The packet to parse\r
@@ -120,10 +114,10 @@ Mtftp4FillOptions (
 **/\r
 EFI_STATUS\r
 Mtftp4ExtractOptions (\r
-  IN  EFI_MTFTP4_PACKET     *Packet,\r
-  IN  UINT32                PacketLen,\r
-  IN  OUT UINT32            *OptionCount,\r
-  OUT EFI_MTFTP4_OPTION     **OptionList        OPTIONAL\r
+  IN     EFI_MTFTP4_PACKET     *Packet,\r
+  IN     UINT32                PacketLen,\r
+     OUT UINT32                *OptionCount,\r
+     OUT EFI_MTFTP4_OPTION     **OptionList        OPTIONAL\r
   )\r
 {\r
   EFI_STATUS                Status;\r
@@ -189,8 +183,8 @@ Mtftp4ExtractOptions (
 **/\r
 BOOLEAN\r
 NetStringEqualNoCase (\r
-  IN  UINT8                 *Str1,\r
-  IN  UINT8                 *Str2\r
+  IN UINT8                 *Str1,\r
+  IN UINT8                 *Str2\r
   )\r
 {\r
   UINT8                     Ch1;\r
@@ -232,7 +226,7 @@ NetStringEqualNoCase (
 **/\r
 UINT32\r
 NetStringToU32 (\r
-  IN  UINT8                 *Str\r
+  IN UINT8                 *Str\r
   )\r
 {\r
   UINT32                    Num;\r
@@ -261,8 +255,8 @@ NetStringToU32 (
 **/\r
 EFI_STATUS\r
 NetStringToIp (\r
-  IN  UINT8                 *Str,\r
-  OUT IP4_ADDR              *Ip\r
+  IN     UINT8                 *Str,\r
+     OUT IP4_ADDR              *Ip\r
   )\r
 {\r
   UINT32                    Byte;\r
@@ -317,8 +311,8 @@ NetStringToIp (
 **/\r
 EFI_STATUS\r
 Mtftp4ExtractMcast (\r
-  IN UINT8                  *Value,\r
-  IN MTFTP4_OPTION          *Option\r
+  IN     UINT8                  *Value,\r
+  IN OUT MTFTP4_OPTION          *Option\r
   )\r
 {\r
   EFI_STATUS                Status;\r
@@ -337,7 +331,7 @@ Mtftp4ExtractMcast (
       return Status;\r
     }\r
 \r
-    while (*Value && (*Value != ',')) {\r
+    while ((*Value != 0) && (*Value != ',')) {\r
       Value++;\r
     }\r
   }\r
@@ -361,7 +355,7 @@ Mtftp4ExtractMcast (
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    Option->McastPort = (UINT16)Num;\r
+    Option->McastPort = (UINT16) Num;\r
 \r
     while (NET_IS_DIGIT (*Value)) {\r
       Value++;\r
@@ -383,7 +377,7 @@ Mtftp4ExtractMcast (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  Option->Master = (BOOLEAN)(Num == 1);\r
+  Option->Master = (BOOLEAN) (Num == 1);\r
 \r
   while (NET_IS_DIGIT (*Value)) {\r
     Value++;\r
@@ -402,7 +396,7 @@ Mtftp4ExtractMcast (
   can access directly.\r
 \r
   @param  Options                The option array, which contains addresses of each\r
-                                  option's name/value string.\r
+                                 option's name/value string.\r
   @param  Count                  The number of options in the Options\r
   @param  Request                Whether this is a request or OACK. The format of\r
                                  multicast is different according to this setting.\r
@@ -415,10 +409,10 @@ Mtftp4ExtractMcast (
 **/\r
 EFI_STATUS\r
 Mtftp4ParseOption (\r
-  IN  EFI_MTFTP4_OPTION     *Options,\r
-  IN  UINT32                Count,\r
-  IN  BOOLEAN               Request,\r
-  OUT MTFTP4_OPTION         *MtftpOption\r
+  IN     EFI_MTFTP4_OPTION     *Options,\r
+  IN     UINT32                Count,\r
+  IN     BOOLEAN               Request,\r
+     OUT MTFTP4_OPTION         *MtftpOption\r
   )\r
 {\r
   EFI_STATUS                Status;\r
@@ -515,9 +509,9 @@ Mtftp4ParseOption (
 **/\r
 EFI_STATUS\r
 Mtftp4ParseOptionOack (\r
-  IN  EFI_MTFTP4_PACKET     *Packet,\r
-  IN  UINT32                PacketLen,\r
-  OUT MTFTP4_OPTION         *MtftpOption\r
+  IN     EFI_MTFTP4_PACKET     *Packet,\r
+  IN     UINT32                PacketLen,\r
+     OUT MTFTP4_OPTION         *MtftpOption\r
   )\r
 {\r
   EFI_MTFTP4_OPTION *OptionList;\r
index 22b7c7d92382fe6e3e177d230eb2a31fa25a15b1..3e450101cd1b042d445e0877a9506898b63deada 100644 (file)
@@ -1,29 +1,24 @@
 /** @file\r
-\r
-Copyright (c) 2006, Intel Corporation\r
+  Routines to process MTFTP4 options.\r
+  \r
+Copyright (c) 2006 - 2007, 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\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
-  Mtftp4Option.h\r
-\r
-Abstract:\r
-\r
-  Mtftp4 option process routines.\r
-\r
-\r
 **/\r
 \r
+\r
 #ifndef __EFI_MTFTP4_OPTION_H__\r
 #define __EFI_MTFTP4_OPTION_H__\r
 \r
-enum {\r
+\r
+\r
+typedef enum {\r
   MTFTP4_SUPPORTED_OPTIONS = 4,\r
   MTFTP4_OPCODE_LEN        = 2,\r
   MTFTP4_ERRCODE_LEN       = 2,\r
@@ -34,7 +29,7 @@ enum {
   MTFTP4_TIMEOUT_EXIST     = 0x02,\r
   MTFTP4_TSIZE_EXIST       = 0x04,\r
   MTFTP4_MCAST_EXIST       = 0x08\r
-};\r
+} MTFTP4_OPTION_CONST_VALUE;\r
 \r
 typedef struct {\r
   UINT16                    BlkSize;\r
@@ -46,28 +41,75 @@ typedef struct {
   UINT32                    Exist;\r
 } MTFTP4_OPTION;\r
 \r
+/**\r
+  Allocate and fill in a array of Mtftp options from the Packet. \r
+  \r
+  It first calls Mtftp4FillOption to get the option number, then allocate\r
+  the array, at last, call Mtftp4FillOption again to save the options.\r
+\r
+  @param  Packet                 The packet to parse\r
+  @param  PacketLen              The length of the packet\r
+  @param  OptionCount            The number of options in the packet\r
+  @param  OptionList             The point to get the option array.\r
+\r
+  @retval EFI_INVALID_PARAMETER  The parametera are invalid or packet isn't a\r
+                                 well-formated OACK packet.\r
+  @retval EFI_SUCCESS            The option array is build\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory for the array\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4ExtractOptions (\r
-  IN  EFI_MTFTP4_PACKET     *Packet,\r
-  IN  UINT32                PacketLen,\r
-  IN  OUT UINT32            *OptionCount,\r
-  OUT EFI_MTFTP4_OPTION     **OptionList OPTIONAL\r
+  IN     EFI_MTFTP4_PACKET     *Packet,\r
+  IN     UINT32                PacketLen,\r
+     OUT UINT32                *OptionCount,\r
+     OUT EFI_MTFTP4_OPTION     **OptionList        OPTIONAL\r
   );\r
 \r
+/**\r
+  Parse the option in Options array to MTFTP4_OPTION which program\r
+  can access directly.\r
+\r
+  @param  Options                The option array, which contains addresses of each\r
+                                 option's name/value string.\r
+  @param  Count                  The number of options in the Options\r
+  @param  Request                Whether this is a request or OACK. The format of\r
+                                 multicast is different according to this setting.\r
+  @param  MtftpOption            The MTFTP4_OPTION for easy access.\r
+\r
+  @retval EFI_INVALID_PARAMETER  The option is mal-formated\r
+  @retval EFI_UNSUPPORTED        Some option isn't supported\r
+  @retval EFI_SUCCESS            The option are OK and has been parsed.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4ParseOption (\r
-  IN  EFI_MTFTP4_OPTION     *OptionList,\r
-  IN  UINT32                Count,\r
-  IN  BOOLEAN               Request,\r
-  OUT MTFTP4_OPTION         *Option\r
+  IN     EFI_MTFTP4_OPTION     *Options,\r
+  IN     UINT32                Count,\r
+  IN     BOOLEAN               Request,\r
+     OUT MTFTP4_OPTION         *MtftpOption\r
   );\r
 \r
+/**\r
+  Parse the options in the OACK packet to MTFTP4_OPTION which program\r
+  can access directly.\r
+\r
+  @param  Packet                 The OACK packet to parse\r
+  @param  PacketLen              The length of the packet\r
+  @param  MtftpOption            The MTFTP_OPTION for easy access.\r
+\r
+  @retval EFI_INVALID_PARAMETER  The packet option is mal-formated\r
+  @retval EFI_UNSUPPORTED        Some option isn't supported\r
+  @retval EFI_SUCCESS            The option are OK and has been parsed.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4ParseOptionOack (\r
-  IN  EFI_MTFTP4_PACKET     *Packet,\r
-  IN  UINT32                PacketLen,\r
-  OUT MTFTP4_OPTION         *Option\r
+  IN     EFI_MTFTP4_PACKET     *Packet,\r
+  IN     UINT32                PacketLen,\r
+     OUT MTFTP4_OPTION         *MtftpOption\r
   );\r
 \r
 extern CHAR8  *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS];\r
+\r
 #endif\r
index 93780fb87f7aff7b31f5708880bc0b54135903db..3f64bf05d916ea533b0ddee704d647113e8c02c6 100644 (file)
@@ -1,27 +1,30 @@
 /** @file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+  Routines to process Rrq (download).\r
+  \r
+Copyright (c) 2006 - 2007, 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\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
-  Mtftp4Rrq.c\r
+**/\r
 \r
-Abstract:\r
 \r
-  Routines to process Rrq (download)\r
+#include "Mtftp4Impl.h"\r
 \r
 \r
-**/\r
+/**\r
+  The packet process callback for MTFTP download.\r
 \r
-#include "Mtftp4Impl.h"\r
+  @param  UdpPacket             The packet received\r
+  @param  Points                The local/remote access point of the packet\r
+  @param  IoStatus              The status of the receiving\r
+  @param  Context               Opaque parameter, which is the MTFTP session\r
 \r
+**/\r
 VOID\r
 Mtftp4RrqInput (\r
   IN NET_BUF                *UdpPacket,\r
@@ -32,9 +35,10 @@ Mtftp4RrqInput (
 \r
 \r
 /**\r
-  Start the MTFTP session to download. It will first initialize some\r
-  of the internal states then build and send a RRQ reqeuest packet, at\r
-  last, it will start receive for the downloading.\r
+  Start the MTFTP session to download. \r
+  \r
+  It will first initialize some of the internal states then build and send a RRQ \r
+  reqeuest packet, at last, it will start receive for the downloading.\r
 \r
   @param  Instance              The Mtftp session\r
   @param  Operation             The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ\r
@@ -130,9 +134,9 @@ Mtftp4RrqSendAck (
 **/\r
 EFI_STATUS\r
 Mtftp4RrqSaveBlock (\r
-  IN MTFTP4_PROTOCOL        *Instance,\r
-  IN EFI_MTFTP4_PACKET      *Packet,\r
-  IN UINT32                 Len\r
+  IN OUT MTFTP4_PROTOCOL        *Instance,\r
+  IN     EFI_MTFTP4_PACKET      *Packet,\r
+  IN     UINT32                 Len\r
   )\r
 {\r
   EFI_MTFTP4_TOKEN          *Token;\r
@@ -215,8 +219,9 @@ Mtftp4RrqSaveBlock (
 \r
 \r
 /**\r
-  Function to process the received data packets. It will save the block\r
-  then send back an ACK if it is active.\r
+  Function to process the received data packets. \r
+  \r
+  It will save the block then send back an ACK if it is active.\r
 \r
   @param  Instance              The downloading MTFTP session\r
   @param  Packet                The packet received\r
@@ -231,11 +236,11 @@ Mtftp4RrqSaveBlock (
 **/\r
 EFI_STATUS\r
 Mtftp4RrqHandleData (\r
-  IN  MTFTP4_PROTOCOL       *Instance,\r
-  IN  EFI_MTFTP4_PACKET     *Packet,\r
-  IN  UINT32                Len,\r
-  IN  BOOLEAN               Multicast,\r
-  OUT BOOLEAN               *Completed\r
+  IN     MTFTP4_PROTOCOL       *Instance,\r
+  IN     EFI_MTFTP4_PACKET     *Packet,\r
+  IN     UINT32                Len,\r
+  IN     BOOLEAN               Multicast,\r
+     OUT BOOLEAN               *Completed\r
   )\r
 {\r
   EFI_STATUS                Status;\r
@@ -304,6 +309,7 @@ Mtftp4RrqHandleData (
 \r
 /**\r
   Validate whether the options received in the server's OACK packet is valid.\r
+  \r
   The options are valid only if:\r
   1. The server doesn't include options not requested by us\r
   2. The server can only use smaller blksize than that is requested\r
@@ -314,7 +320,8 @@ Mtftp4RrqHandleData (
   @param  Reply                 The options in the OACK packet\r
   @param  Request               The requested options\r
 \r
-  @return TRUE if the options in the OACK is OK, otherwise FALSE.\r
+  @retval TRUE                  The options in the OACK is OK.\r
+  @retval FALSE                 The options in the OACK is invalid.\r
 \r
 **/\r
 BOOLEAN\r
@@ -336,8 +343,8 @@ Mtftp4RrqOackValid (
   // Server can only specify a smaller block size to be used and\r
   // return the timeout matches that requested.\r
   //\r
-  if (((Reply->Exist & MTFTP4_BLKSIZE_EXIST) && (Reply->BlkSize > Request->BlkSize)) ||\r
-      ((Reply->Exist & MTFTP4_TIMEOUT_EXIST) && (Reply->Timeout != Request->Timeout))) {\r
+  if ((((Reply->Exist & MTFTP4_BLKSIZE_EXIST) != 0)&& (Reply->BlkSize > Request->BlkSize)) ||\r
+      (((Reply->Exist & MTFTP4_TIMEOUT_EXIST) != 0) && (Reply->Timeout != Request->Timeout))) {\r
     return FALSE;\r
   }\r
 \r
@@ -346,7 +353,7 @@ Mtftp4RrqOackValid (
   // setting. But if it use the specific multicast channel, it can't\r
   // change the setting.\r
   //\r
-  if ((Reply->Exist & MTFTP4_MCAST_EXIST) && (This->McastIp != 0)) {\r
+  if (((Reply->Exist & MTFTP4_MCAST_EXIST) != 0) && (This->McastIp != 0)) {\r
     if ((Reply->McastIp != 0) && (Reply->McastIp != This->McastIp)) {\r
       return FALSE;\r
     }\r
@@ -367,7 +374,7 @@ Mtftp4RrqOackValid (
   @param  Context               The opaque parameter to the function which is the\r
                                 MTFTP session.\r
 \r
-  @retval EFI_SUCCESS           The udp child is successfully configured.\r
+  @retval EFI_SUCCESS           The UDP child is successfully configured.\r
   @retval Others                Failed to configure the UDP child.\r
 \r
 **/\r
@@ -411,12 +418,20 @@ Mtftp4RrqConfigMcastPort (
     return Status;\r
   }\r
 \r
-  if (!Config->UseDefaultSetting && !EFI_IP4_EQUAL (&mZeroIp4Addr, &Config->GatewayIp)) {\r
+  if (!Config->UseDefaultSetting && \r
+      !EFI_IP4_EQUAL (&mZeroIp4Addr, &Config->GatewayIp)) {\r
     //\r
     // The station IP address is manually configured and the Gateway IP is not 0.\r
     // Add the default route for this UDP instance.\r
     //\r
-    Status = McastIo->Udp->Routes (McastIo->Udp, FALSE, &mZeroIp4Addr, &mZeroIp4Addr, &Config->GatewayIp);\r
+    Status = McastIo->Udp->Routes (\r
+                             McastIo->Udp, \r
+                             FALSE,\r
+                             &mZeroIp4Addr,\r
+                             &mZeroIp4Addr,\r
+                             &Config->GatewayIp\r
+                             );\r
+                             \r
     if (EFI_ERROR (Status)) {\r
       McastIo->Udp->Configure (McastIo->Udp, NULL);\r
       return Status;\r
@@ -434,8 +449,9 @@ Mtftp4RrqConfigMcastPort (
 \r
 \r
 /**\r
-  Function to process the OACK. It will first validate the OACK\r
-  packet, then update the various negotiated parameters.\r
+  Function to process the OACK. \r
+  \r
+  It will first validate the OACK packet, then update the various negotiated parameters.\r
 \r
   @param  Instance              The download MTFTP session\r
   @param  Packet                The packet received\r
@@ -451,11 +467,11 @@ Mtftp4RrqConfigMcastPort (
 **/\r
 EFI_STATUS\r
 Mtftp4RrqHandleOack (\r
-  IN  MTFTP4_PROTOCOL       *Instance,\r
-  IN  EFI_MTFTP4_PACKET     *Packet,\r
-  IN  UINT32                Len,\r
-  IN  BOOLEAN               Multicast,\r
-  OUT BOOLEAN               *Completed\r
+  IN OUT MTFTP4_PROTOCOL       *Instance,\r
+  IN     EFI_MTFTP4_PACKET     *Packet,\r
+  IN     UINT32                Len,\r
+  IN     BOOLEAN               Multicast,\r
+     OUT BOOLEAN               *Completed\r
   )\r
 {\r
   MTFTP4_OPTION             Reply;\r
@@ -498,7 +514,7 @@ Mtftp4RrqHandleOack (
     return EFI_TFTP_ERROR;\r
   }\r
 \r
-  if (Reply.Exist & MTFTP4_MCAST_EXIST) {\r
+  if ((Reply.Exist & MTFTP4_MCAST_EXIST) != 0) {\r
 \r
     //\r
     // Save the multicast info. Always update the Master, only update the\r
@@ -586,8 +602,6 @@ Mtftp4RrqHandleOack (
   @param  IoStatus              The status of the receiving\r
   @param  Context               Opaque parameter, which is the MTFTP session\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 Mtftp4RrqInput (\r
@@ -716,6 +730,9 @@ Mtftp4RrqInput (
   case EFI_MTFTP4_OPCODE_ERROR:\r
     Status = EFI_TFTP_ERROR;\r
     break;\r
+    \r
+  default:\r
+    break;\r
   }\r
 \r
 ON_EXIT:\r
index b43f94da62193e6093f5b3ec4224eca25fbff58f..51c5f3ddaf37e51262e327a8624e40b5ec79bb7f 100644 (file)
@@ -1,36 +1,27 @@
 /** @file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+  Support routines for Mtftp.\r
+  \r
+Copyright (c) 2006 - 2007, 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\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
-  Mtftp4Support.c\r
-\r
-Abstract:\r
-\r
-  Support routines for Mtftp\r
-\r
-\r
 **/\r
 \r
 #include "Mtftp4Impl.h"\r
 \r
 \r
 /**\r
-  Allocate a MTFTP4 block range, then init it to the\r
-  range of [Start, End]\r
+  Allocate a MTFTP4 block range, then init it to the range of [Start, End]\r
 \r
   @param  Start                 The start block number\r
   @param  End                   The last block number in the range\r
 \r
-  @return NULL if failed to allocate memory, otherwise the created block range.\r
+  @return Pointer to the created block range, NULL if failed to allocate memory.\r
 \r
 **/\r
 MTFTP4_BLOCK_RANGE *\r
@@ -56,16 +47,17 @@ Mtftp4AllocateRange (
 \r
 \r
 /**\r
-  Initialize the block range for either RRQ or WRQ. RRQ and WRQ have\r
-  different requirements for Start and End. For example, during start\r
-  up, WRQ initializes its whole valid block range to [0, 0xffff]. This\r
-  is bacause the server will send us a ACK0 to inform us to start the\r
-  upload. When the client received ACK0, it will remove 0 from the range,\r
-  get the next block number, which is 1, then upload the BLOCK1. For RRQ\r
-  without option negotiation, the server will directly send us the BLOCK1\r
-  in response to the client's RRQ. When received BLOCK1, the client will\r
-  remove it from the block range and send an ACK. It also works if there\r
-  is option negotiation.\r
+  Initialize the block range for either RRQ or WRQ. \r
+  \r
+  RRQ and WRQ have different requirements for Start and End. \r
+  For example, during start up, WRQ initializes its whole valid block range \r
+  to [0, 0xffff]. This is bacause the server will send us a ACK0 to inform us \r
+  to start the upload. When the client received ACK0, it will remove 0 from the \r
+  range, get the next block number, which is 1, then upload the BLOCK1. For RRQ\r
+  without option negotiation, the server will directly send us the BLOCK1 in \r
+  response to the client's RRQ. When received BLOCK1, the client will remove \r
+  it from the block range and send an ACK. It also works if there is option \r
+  negotiation.\r
 \r
   @param  Head                  The block range head to initialize\r
   @param  Start                 The Start block number.\r
@@ -100,7 +92,7 @@ Mtftp4InitBlockRange (
 \r
   @param  Head                  The block range head\r
 \r
-  @return -1: if the block range is empty. Otherwise the first valid block number.\r
+  @return The first valid block number, -1 if the block range is empty. \r
 \r
 **/\r
 INTN\r
@@ -120,17 +112,15 @@ Mtftp4GetNextBlockNum (
 \r
 \r
 /**\r
-  Set the last block number of the block range list. It will\r
-  remove all the blocks after the Last. MTFTP initialize the\r
-  block range to the maximum possible range, such as [0, 0xffff]\r
-  for WRQ. When it gets the last block number, it will call\r
-  this function to set the last block number.\r
+  Set the last block number of the block range list. \r
+  \r
+  It will remove all the blocks after the Last. MTFTP initialize the block range\r
+  to the maximum possible range, such as [0, 0xffff] for WRQ. When it gets the \r
+  last block number, it will call this function to set the last block number.\r
 \r
   @param  Head                  The block range list\r
   @param  Last                  The last block number\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 Mtftp4SetLastBlockNum (\r
@@ -321,10 +311,11 @@ Mtftp4SendRequest (
 \r
 \r
 /**\r
-  Build then send an error message\r
+  Build then send an error message.\r
 \r
   @param  Instance              The MTFTP session\r
-  @param  ErrInfo               The error code and message\r
+  @param  ErrCode               The error code  \r
+  @param  ErrInfo               The error message\r
 \r
   @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory for the error packet\r
   @retval EFI_SUCCESS           The error packet is transmitted.\r
@@ -335,7 +326,7 @@ EFI_STATUS
 Mtftp4SendError (\r
   IN MTFTP4_PROTOCOL        *Instance,\r
   IN UINT16                 ErrCode,\r
-  IN UINT8*                 ErrInfo\r
+  IN UINT8                  *ErrInfo\r
   )\r
 {\r
   NET_BUF                   *Packet;\r
@@ -361,6 +352,7 @@ Mtftp4SendError (
 \r
 /**\r
   The callback function called when the packet is transmitted.\r
+  \r
   It simply frees the packet.\r
 \r
   @param  Packet                The transmitted (or failed to) packet\r
@@ -368,8 +360,6 @@ Mtftp4SendError (
   @param  IoStatus              The result of the transmission\r
   @param  Context               Opaque parameter to the callback\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 Mtftp4OnPacketSent (\r
@@ -384,17 +374,14 @@ Mtftp4OnPacketSent (
 \r
 \r
 /**\r
-  Set the timeout for the instance. User a longer time for\r
-  passive instances.\r
+  Set the timeout for the instance. User a longer time for passive instances.\r
 \r
   @param  Instance              The Mtftp session to set time out\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 Mtftp4SetTimeout (\r
-  IN MTFTP4_PROTOCOL        *Instance\r
+  IN OUT MTFTP4_PROTOCOL        *Instance\r
   )\r
 {\r
   if (Instance->Master) {\r
@@ -406,10 +393,11 @@ Mtftp4SetTimeout (
 \r
 \r
 /**\r
-  Send the packet for the instance. It will first save a reference to\r
-  the packet for later retransmission. then determine the destination\r
-  port, listen port for requests, and connected port for others. At last,\r
-  send the packet out.\r
+  Send the packet for the instance. \r
+  \r
+  It will first save a reference to the packet for later retransmission. \r
+  Then determine the destination port, listen port for requests, and connected \r
+  port for others. At last, send the packet out.\r
 \r
   @param  Instance              The Mtftp instance\r
   @param  Packet                The packet to send\r
@@ -420,8 +408,8 @@ Mtftp4SetTimeout (
 **/\r
 EFI_STATUS\r
 Mtftp4SendPacket (\r
-  IN MTFTP4_PROTOCOL        *Instance,\r
-  IN NET_BUF                *Packet\r
+  IN OUT MTFTP4_PROTOCOL        *Instance,\r
+  IN OUT NET_BUF                *Packet\r
   )\r
 {\r
   UDP_POINTS                UdpPoint;\r
@@ -452,7 +440,8 @@ Mtftp4SendPacket (
   Value = *((UINT16 *) NetbufGetByte (Packet, 0, NULL));\r
   OpCode = NTOHS (Value);\r
 \r
-  if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) || (OpCode == EFI_MTFTP4_OPCODE_DIR) ||\r
+  if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) || \r
+      (OpCode == EFI_MTFTP4_OPCODE_DIR) ||\r
       (OpCode == EFI_MTFTP4_OPCODE_WRQ)) {\r
     UdpPoint.RemotePort = Instance->ListeningPort;\r
   } else {\r
@@ -479,7 +468,7 @@ Mtftp4SendPacket (
 \r
 \r
 /**\r
-  Retransmit the last packet for the instance\r
+  Retransmit the last packet for the instance.\r
 \r
   @param  Instance              The Mtftp instance\r
 \r
@@ -541,8 +530,6 @@ Mtftp4Retransmit (
   @param  Event                 The ticking event\r
   @param  Context               The Mtftp service instance\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 EFIAPI\r
index ddeeac657af123f1e6ae22deef737a8ae5ef0850..8c231e1fa0546fe277151511a06ef623727e9ef9 100644 (file)
@@ -1,23 +1,15 @@
 /** @file\r
-\r
-Copyright (c) 2006, Intel Corporation\r
+  Support routines for MTFTP.\r
+  \r
+Copyright (c) 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\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
-  Mtftp4Support.h\r
-\r
-Abstract:\r
-\r
-  Support routines for MTFTP\r
-\r
-\r
 **/\r
 \r
 #ifndef __EFI_MTFTP4_SUPPORT_H__\r
@@ -35,6 +27,27 @@ typedef struct {
 } MTFTP4_BLOCK_RANGE;\r
 \r
 \r
+/**\r
+  Initialize the block range for either RRQ or WRQ. \r
+  \r
+  RRQ and WRQ have different requirements for Start and End. \r
+  For example, during start up, WRQ initializes its whole valid block range \r
+  to [0, 0xffff]. This is bacause the server will send us a ACK0 to inform us \r
+  to start the upload. When the client received ACK0, it will remove 0 from the \r
+  range, get the next block number, which is 1, then upload the BLOCK1. For RRQ\r
+  without option negotiation, the server will directly send us the BLOCK1 in \r
+  response to the client's RRQ. When received BLOCK1, the client will remove \r
+  it from the block range and send an ACK. It also works if there is option \r
+  negotiation.\r
+\r
+  @param  Head                  The block range head to initialize\r
+  @param  Start                 The Start block number.\r
+  @param  End                   The last block number.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory for initial block range\r
+  @retval EFI_SUCCESS           The initial block range is created.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4InitBlockRange (\r
   IN LIST_ENTRY             *Head,\r
@@ -42,51 +55,139 @@ Mtftp4InitBlockRange (
   IN UINT16                 End\r
   );\r
 \r
+/**\r
+  Get the first valid block number on the range list.\r
+\r
+  @param  Head                  The block range head\r
+\r
+  @return The first valid block number, -1 if the block range is empty. \r
+\r
+**/\r
 INTN\r
 Mtftp4GetNextBlockNum (\r
   IN LIST_ENTRY             *Head\r
   );\r
 \r
+/**\r
+  Set the last block number of the block range list. \r
+  \r
+  It will remove all the blocks after the Last. MTFTP initialize the block range\r
+  to the maximum possible range, such as [0, 0xffff] for WRQ. When it gets the \r
+  last block number, it will call this function to set the last block number.\r
+\r
+  @param  Head                  The block range list\r
+  @param  Last                  The last block number\r
+\r
+**/\r
 VOID\r
 Mtftp4SetLastBlockNum (\r
   IN LIST_ENTRY             *Head,\r
   IN UINT16                 Last\r
   );\r
 \r
+/**\r
+  Remove the block number from the block range list.\r
+\r
+  @param  Head                  The block range list to remove from\r
+  @param  Num                   The block number to remove\r
+\r
+  @retval EFI_NOT_FOUND         The block number isn't in the block range list\r
+  @retval EFI_SUCCESS           The block number has been removed from the list\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate resource\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4RemoveBlockNum (\r
   IN LIST_ENTRY             *Head,\r
   IN UINT16                 Num\r
   );\r
 \r
+/**\r
+  Set the timeout for the instance. User a longer time for passive instances.\r
+\r
+  @param  Instance              The Mtftp session to set time out\r
+\r
+**/\r
 VOID\r
 Mtftp4SetTimeout (\r
-  IN MTFTP4_PROTOCOL        *Instance\r
+  IN OUT MTFTP4_PROTOCOL        *Instance\r
   );\r
 \r
+/**\r
+  Send the packet for the instance. \r
+  \r
+  It will first save a reference to the packet for later retransmission. \r
+  Then determine the destination port, listen port for requests, and connected \r
+  port for others. At last, send the packet out.\r
+\r
+  @param  Instance              The Mtftp instance\r
+  @param  Packet                The packet to send\r
+\r
+  @retval EFI_SUCCESS           The packet is sent out\r
+  @retval Others                Failed to transmit the packet.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4SendPacket (\r
-  IN MTFTP4_PROTOCOL        *Instance,\r
-  IN NET_BUF                *Packet\r
+  IN OUT MTFTP4_PROTOCOL        *Instance,\r
+  IN OUT NET_BUF                *Packet\r
   );\r
 \r
+/**\r
+  Build then transmit the request packet for the MTFTP session.\r
+\r
+  @param  Instance              The Mtftp session\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory for the request\r
+  @retval EFI_SUCCESS           The request is built and sent\r
+  @retval Others                Failed to transmit the packet.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4SendRequest (\r
   IN MTFTP4_PROTOCOL        *Instance\r
   );\r
 \r
+/**\r
+  Build then send an error message.\r
+\r
+  @param  Instance              The MTFTP session\r
+  @param  ErrCode               The error code  \r
+  @param  ErrInfo               The error message\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory for the error packet\r
+  @retval EFI_SUCCESS           The error packet is transmitted.\r
+  @retval Others                Failed to transmit the packet.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4SendError (\r
   IN MTFTP4_PROTOCOL        *Instance,\r
   IN UINT16                 ErrCode,\r
-  IN UINT8*                 ErrInfo\r
+  IN UINT8                  *ErrInfo\r
   );\r
 \r
+/**\r
+  Retransmit the last packet for the instance.\r
+\r
+  @param  Instance              The Mtftp instance\r
+\r
+  @retval EFI_SUCCESS           The last packet is retransmitted.\r
+  @retval Others                Failed to retransmit.\r
+\r
+**/\r
 EFI_STATUS\r
 Mtftp4Retransmit (\r
   IN MTFTP4_PROTOCOL        *Instance\r
   );\r
 \r
+/**\r
+  The timer ticking function for the Mtftp service instance.\r
+\r
+  @param  Event                 The ticking event\r
+  @param  Context               The Mtftp service instance\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 Mtftp4OnTimerTick (\r
index 12b4c4a4a15d81f0f82abc5075ad9f0a2c753e55..cb39da48c8d451349d76a03e00d4a85e4c4ec5d3 100644 (file)
@@ -1,95 +1,37 @@
 /** @file\r
-\r
-Copyright (c) 2006, Intel Corporation\r
+  Routines to process Wrq (upload).\r
+  \r
+Copyright (c) 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\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
-  Mtftp4Wrq.c\r
-\r
-Abstract:\r
-\r
-  Routines to process Wrq (upload)\r
-\r
-\r
 **/\r
 \r
 #include "Mtftp4Impl.h"\r
 \r
-VOID\r
-Mtftp4WrqInput (\r
-  IN NET_BUF                *UdpPacket,\r
-  IN UDP_POINTS             *Points,\r
-  IN EFI_STATUS             IoStatus,\r
-  IN VOID                   *Context\r
-  );\r
-\r
-\r
-/**\r
-  Start the MTFTP session for pload. It will first init some states,\r
-  then send the WRQ request packet, and start receiving the  packet.\r
-\r
-  @param  Instance              The MTFTP session\r
-  @param  Operation             Redundant parameter, which is always\r
-                                EFI_MTFTP4_OPCODE_WRQ here.\r
-\r
-  @retval EFI_SUCCESS           The upload process has been started.\r
-  @retval Others                Failed to start the upload.\r
-\r
-**/\r
-EFI_STATUS\r
-Mtftp4WrqStart (\r
-  IN MTFTP4_PROTOCOL        *Instance,\r
-  IN UINT16                 Operation\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-\r
-  //\r
-  // The valid block number range are [0, 0xffff]. For example:\r
-  // the client sends an WRQ request to the server, the server\r
-  // ACK with an ACK0 to let client start transfer the first\r
-  // packet.\r
-  //\r
-  Status = Mtftp4InitBlockRange (&Instance->Blocks, 0, 0xffff);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = Mtftp4SendRequest (Instance);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return UdpIoRecvDatagram (Instance->UnicastPort, Mtftp4WrqInput, Instance, 0);\r
-}\r
 \r
 \r
 /**\r
   Build then send a MTFTP data packet for the MTFTP upload session.\r
 \r
-  @param  Instance              The MTFTP upload session\r
-  @param  BlockNum              The block number to send\r
+  @param  Instance              The MTFTP upload session.\r
+  @param  BlockNum              The block number to send.\r
 \r
-  @retval EFI_OUT_OF_RESOURCES  Failed to build the packet\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to build the packet.\r
   @retval EFI_ABORTED           The consumer of this child directs to abort the\r
-                                transmission by return an error through\r
-                                PacketNeeded\r
+                                transmission by return an error through PacketNeeded.\r
   @retval EFI_SUCCESS           The data is sent.\r
 \r
 **/\r
 EFI_STATUS\r
 Mtftp4WrqSendBlock (\r
-  IN MTFTP4_PROTOCOL        *Instance,\r
-  IN UINT16                 BlockNum\r
+  IN OUT MTFTP4_PROTOCOL        *Instance,\r
+  IN     UINT16                 BlockNum\r
   )\r
 {\r
   EFI_MTFTP4_PACKET         *Packet;\r
@@ -109,7 +51,7 @@ Mtftp4WrqSendBlock (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  Packet = (EFI_MTFTP4_PACKET *)NetbufAllocSpace (UdpPacket, MTFTP4_DATA_HEAD_LEN, FALSE);\r
+  Packet = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (UdpPacket, MTFTP4_DATA_HEAD_LEN, FALSE);\r
 \r
   Packet->Data.OpCode = HTONS (EFI_MTFTP4_OPCODE_DATA);\r
   Packet->Data.Block  = HTONS (BlockNum);\r
@@ -139,7 +81,12 @@ Mtftp4WrqSendBlock (
     // Get data from PacketNeeded\r
     //\r
     DataBuf = NULL;\r
-    Status  = Token->PacketNeeded (&Instance->Mtftp4, Token, &DataLen, (VOID **) &DataBuf);\r
+    Status  = Token->PacketNeeded (\r
+                       &Instance->Mtftp4,\r
+                       Token,\r
+                       &DataLen,\r
+                       (VOID **) &DataBuf\r
+                       );\r
 \r
     if (EFI_ERROR (Status) || (DataLen > Instance->BlkSize)) {\r
       if (DataBuf != NULL) {\r
@@ -172,9 +119,10 @@ Mtftp4WrqSendBlock (
 \r
 \r
 /**\r
-  Function to handle received ACK packet. If the ACK number matches the\r
-  expected block number, and there are more data pending, send the next\r
-  block. Otherwise tell the caller that we are done.\r
+  Function to handle received ACK packet. \r
+  \r
+  If the ACK number matches the expected block number, and there are more \r
+  data pending, send the next block. Otherwise tell the caller that we are done.\r
 \r
   @param  Instance              The MTFTP upload session\r
   @param  Packet                The MTFTP packet received\r
@@ -188,10 +136,10 @@ Mtftp4WrqSendBlock (
 **/\r
 EFI_STATUS\r
 Mtftp4WrqHandleAck (\r
-  IN  MTFTP4_PROTOCOL       *Instance,\r
-  IN  EFI_MTFTP4_PACKET     *Packet,\r
-  IN  UINT32                Len,\r
-  OUT BOOLEAN               *Completed\r
+  IN     MTFTP4_PROTOCOL       *Instance,\r
+  IN     EFI_MTFTP4_PACKET     *Packet,\r
+  IN     UINT32                Len,\r
+     OUT BOOLEAN               *Completed\r
   )\r
 {\r
   UINT16                    AckNum;\r
@@ -221,6 +169,7 @@ Mtftp4WrqHandleAck (
   Expected = Mtftp4GetNextBlockNum (&Instance->Blocks);\r
 \r
   if (Expected < 0) {\r
+  \r
     //\r
     // The block range is empty. It may either because the the last\r
     // block has been ACKed, or the sequence number just looped back,\r
@@ -247,17 +196,19 @@ Mtftp4WrqHandleAck (
 \r
 \r
 /**\r
-  Check whether the received OACK is valid. The OACK is valid\r
-  only if:\r
+  Check whether the received OACK is valid. \r
+  \r
+  The OACK is valid only if:\r
   1. It only include options requested by us\r
   2. It can only include a smaller block size\r
   3. It can't change the proposed time out value.\r
-  4. Other requirements of the individal MTFTP options as required.s\r
+  4. Other requirements of the individal MTFTP options as required.\r
 \r
   @param  Reply                 The options included in the OACK\r
   @param  Request               The options we requested\r
 \r
-  @return TRUE if the options included in OACK is valid, otherwise FALSE.\r
+  @retval TRUE                  The options included in OACK is valid.\r
+  @retval FALSE                 The options included in OACK is invalid.\r
 \r
 **/\r
 BOOLEAN\r
@@ -269,7 +220,7 @@ Mtftp4WrqOackValid (
   //\r
   // It is invalid for server to return options we don't request\r
   //\r
-  if ((Reply->Exist &~Request->Exist) != 0) {\r
+  if ((Reply->Exist & ~Request->Exist) != 0) {\r
     return FALSE;\r
   }\r
 \r
@@ -277,8 +228,8 @@ Mtftp4WrqOackValid (
   // Server can only specify a smaller block size to be used and\r
   // return the timeout matches that requested.\r
   //\r
-  if (((Reply->Exist & MTFTP4_BLKSIZE_EXIST) && (Reply->BlkSize > Request->BlkSize)) ||\r
-      ((Reply->Exist & MTFTP4_TIMEOUT_EXIST) && (Reply->Timeout != Request->Timeout))) {\r
+  if ((((Reply->Exist & MTFTP4_BLKSIZE_EXIST) != 0) && (Reply->BlkSize > Request->BlkSize)) ||\r
+      (((Reply->Exist & MTFTP4_TIMEOUT_EXIST) != 0) && (Reply->Timeout != Request->Timeout))) {\r
     return FALSE;\r
   }\r
 \r
@@ -287,8 +238,9 @@ Mtftp4WrqOackValid (
 \r
 \r
 /**\r
-  Function to handle the MTFTP OACK packet. It parses the packet's\r
-  options, and update the internal states of the session\r
+  Function to handle the MTFTP OACK packet. \r
+  \r
+  It parses the packet's options, and update the internal states of the session.\r
 \r
   @param  Instance              The MTFTP session\r
   @param  Packet                The received OACK packet\r
@@ -302,10 +254,10 @@ Mtftp4WrqOackValid (
 **/\r
 EFI_STATUS\r
 Mtftp4WrqHandleOack (\r
-  IN  MTFTP4_PROTOCOL       *Instance,\r
-  IN  EFI_MTFTP4_PACKET     *Packet,\r
-  IN  UINT32                Len,\r
-  OUT BOOLEAN               *Completed\r
+  IN OUT MTFTP4_PROTOCOL       *Instance,\r
+  IN     EFI_MTFTP4_PACKET     *Packet,\r
+  IN     UINT32                Len,\r
+     OUT BOOLEAN               *Completed\r
   )\r
 {\r
   MTFTP4_OPTION             Reply;\r
@@ -361,7 +313,14 @@ Mtftp4WrqHandleOack (
   Bogus.Ack.OpCode    = HTONS (EFI_MTFTP4_OPCODE_ACK);\r
   Bogus.Ack.Block[0]  = 0;\r
 \r
-  return Mtftp4WrqHandleAck (Instance, &Bogus, sizeof (EFI_MTFTP4_ACK_HEADER), Completed);\r
+  Status = Mtftp4WrqHandleAck (\r
+             Instance,\r
+             &Bogus,\r
+             sizeof (EFI_MTFTP4_ACK_HEADER),\r
+             Completed\r
+             );\r
+\r
+  return Status;\r
 }\r
 \r
 \r
@@ -373,9 +332,6 @@ Mtftp4WrqHandleOack (
   @param  IoStatus              The result of the packet receiving\r
   @param  Context               Opaque parameter for the callback, which is the\r
                                 MTFTP session.\r
-\r
-  @return None\r
-\r
 **/\r
 VOID\r
 Mtftp4WrqInput (\r
@@ -494,6 +450,9 @@ Mtftp4WrqInput (
   case EFI_MTFTP4_OPCODE_ERROR:\r
     Status = EFI_TFTP_ERROR;\r
     break;\r
+    \r
+  default:\r
+    break;\r
   }\r
 \r
 ON_EXIT:\r
@@ -520,3 +479,49 @@ ON_EXIT:
     Mtftp4CleanOperation (Instance, Status);\r
   }\r
 }\r
+\r
+\r
+\r
+/**\r
+  Start the MTFTP session for upload.\r
+  \r
+  It will first init some states, then send the WRQ request packet, \r
+  and start receiving the packet.\r
+\r
+  @param  Instance              The MTFTP session\r
+  @param  Operation             Redundant parameter, which is always\r
+                                EFI_MTFTP4_OPCODE_WRQ here.\r
+\r
+  @retval EFI_SUCCESS           The upload process has been started.\r
+  @retval Others                Failed to start the upload.\r
+\r
+**/\r
+EFI_STATUS\r
+Mtftp4WrqStart (\r
+  IN MTFTP4_PROTOCOL        *Instance,\r
+  IN UINT16                 Operation\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+\r
+  //\r
+  // The valid block number range are [0, 0xffff]. For example:\r
+  // the client sends an WRQ request to the server, the server\r
+  // ACK with an ACK0 to let client start transfer the first\r
+  // packet.\r
+  //\r
+  Status = Mtftp4InitBlockRange (&Instance->Blocks, 0, 0xffff);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = Mtftp4SendRequest (Instance);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return UdpIoRecvDatagram (Instance->UnicastPort, Mtftp4WrqInput, Instance, 0);\r
+}\r
+\r
index 85afc525e83813ba1ca41db24eb4f198e1fb1e0e..a458fd37110f8eed547f64dcbc38fc6680d73fc8 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  UEFI Component Name(2) protocol implementation for Tcp4Dxe driver.\r
 \r
 Copyright (c) 2005 - 2007, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
index b8a8258bedeb2711ba19f9824da32562d3670e72..243cb681ac0b36b912d772ce990bd19b02202e51 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Implementation of the Socket.\r
 \r
 Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
index 840f6b16934fe0acca5a6376b311d300b79e7bcf..004f1cbec4df88a23081ea9f19378ac052ed1efb 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Socket implementation header file.\r
 \r
 Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
index f7b0e99c39945a5e19a5e68ae32de0a980119b85..17227424a131a99e8584159c640588b46d7336ba 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Interface function of the Socket.\r
 \r
 Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
index 0992a2c15b1f5289d7db8d6d0d3358178c2f6e6a..6f668574151b2c99692bc2310cbaf853527891eb 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Socket header file.\r
 \r
 Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
@@ -24,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DebugLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/UefiLib.h>\r
 \r
 #define SOCK_SND_BUF        0\r
@@ -81,55 +83,224 @@ typedef enum {
   SO_NO_MAPPING\r
 } SOCK_CONFIGURE_STATE;\r
 \r
+/**\r
+  Set socket SO_NO_MORE_DATA flag.\r
+  \r
+  @param Sock               Pointer to the socket\r
+  \r
+**/\r
 #define SOCK_NO_MORE_DATA(Sock)     ((Sock)->Flag |= SO_NO_MORE_DATA)\r
 \r
+/**\r
+  Check whether the socket is unconfigured.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is unconfigued\r
+  @retval False              The socket is not unconfigued\r
+  \r
+**/\r
 #define SOCK_IS_UNCONFIGURED(Sock)  ((Sock)->ConfigureState == SO_UNCONFIGURED)\r
 \r
+/**\r
+  Check whether the socket is configured.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is configued\r
+  @retval False              The socket is not configued\r
+  \r
+**/\r
 #define SOCK_IS_CONFIGURED(Sock) \\r
     (((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE) || \\r
     ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE))\r
 \r
+/**\r
+  Check whether the socket is configured to active mode.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is configued to active mode\r
+  @retval False              The socket is not configued to active mode\r
+  \r
+**/\r
 #define SOCK_IS_CONFIGURED_ACTIVE(Sock) \\r
   ((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE)\r
 \r
+/**\r
+  Check whether the socket is configured to passive mode.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is configued to passive mode\r
+  @retval False              The socket is not configued to passive mode\r
+  \r
+**/\r
 #define SOCK_IS_CONNECTED_PASSIVE(Sock) \\r
   ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE)\r
 \r
+/**\r
+  Check whether the socket is mapped.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is no mapping\r
+  @retval False              The socket is mapped\r
+  \r
+**/\r
 #define SOCK_IS_NO_MAPPING(Sock) \\r
   ((Sock)->ConfigureState == SO_NO_MAPPING)\r
 \r
+/**\r
+  Check whether the socket is closed.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is closed\r
+  @retval False              The socket is not closed\r
+  \r
+**/\r
 #define SOCK_IS_CLOSED(Sock)          ((Sock)->State == SO_CLOSED)\r
 \r
+/**\r
+  Check whether the socket is listening.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is listening\r
+  @retval False              The socket is not listening\r
+  \r
+**/\r
 #define SOCK_IS_LISTENING(Sock)       ((Sock)->State == SO_LISTENING)\r
 \r
+/**\r
+  Check whether the socket is connecting.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is connecting\r
+  @retval False              The socket is not connecting\r
+  \r
+**/\r
 #define SOCK_IS_CONNECTING(Sock)      ((Sock)->State == SO_CONNECTING)\r
 \r
+/**\r
+  Check whether the socket has connected.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket has connected\r
+  @retval False              The socket has not connected\r
+  \r
+**/\r
 #define SOCK_IS_CONNECTED(Sock)       ((Sock)->State == SO_CONNECTED)\r
 \r
+/**\r
+  Check whether the socket is disconnecting.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is disconnecting\r
+  @retval False              The socket is not disconnecting\r
+  \r
+**/\r
 #define SOCK_IS_DISCONNECTING(Sock)   ((Sock)->State == SO_DISCONNECTING)\r
 \r
+/**\r
+  Check whether the socket is no more data.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @retval True               The socket is no more data\r
+  @retval False              The socket still has data\r
+  \r
+**/\r
 #define SOCK_IS_NO_MORE_DATA(Sock)    (0 != ((Sock)->Flag & SO_NO_MORE_DATA))\r
 \r
-#define SOCK_SIGNATURE                SIGNATURE_32 ('S', 'O', 'C', 'K')\r
-\r
-#define SOCK_FROM_THIS(a)             CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)\r
+/**\r
+  Set the size of the receive buffer.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  @param  Size               The size to set\r
 \r
+**/\r
 #define SET_RCV_BUFFSIZE(Sock, Size)  ((Sock)->RcvBuffer.HighWater = (Size))\r
 \r
+/**\r
+  Get the size of the receive buffer.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @return The receive buffer size\r
+\r
+**/\r
 #define GET_RCV_BUFFSIZE(Sock)        ((Sock)->RcvBuffer.HighWater)\r
 \r
+/**\r
+  Get the size of the receive data.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @return The received data size\r
+\r
+**/\r
 #define GET_RCV_DATASIZE(Sock)        (((Sock)->RcvBuffer.DataQueue)->BufSize)\r
 \r
+/**\r
+  Set the size of the send buffer.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  @param  Size               The size to set\r
+\r
+**/\r
 #define SET_SND_BUFFSIZE(Sock, Size)  ((Sock)->SndBuffer.HighWater = (Size))\r
 \r
+/**\r
+  Get the size of the send buffer.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @return The send buffer size\r
+\r
+**/\r
 #define GET_SND_BUFFSIZE(Sock)        ((Sock)->SndBuffer.HighWater)\r
 \r
+/**\r
+  Get the size of the send data.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @return The send data size\r
+\r
+**/\r
 #define GET_SND_DATASIZE(Sock)        (((Sock)->SndBuffer.DataQueue)->BufSize)\r
 \r
+/**\r
+  Set the backlog value of the socket.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  @param  Value              The value to set\r
+\r
+**/\r
 #define SET_BACKLOG(Sock, Value)      ((Sock)->BackLog = (Value))\r
 \r
+/**\r
+  Get the backlog value of the socket.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  \r
+  @return The backlog value\r
+\r
+**/\r
 #define GET_BACKLOG(Sock)             ((Sock)->BackLog)\r
 \r
+/**\r
+  Set the socket with error state.\r
+  \r
+  @param  Sock               Pointer to the socket\r
+  @param  Error              The error state\r
+\r
+**/\r
 #define SOCK_ERROR(Sock, Error)       ((Sock)->SockError = (Error))\r
 \r
 #define SND_BUF_HDR_LEN(Sock) \\r
@@ -138,6 +309,10 @@ typedef enum {
 #define RCV_BUF_HDR_LEN(Sock) \\r
   ((SockBufFirst (&((Sock)->RcvBuffer)))->TotalSize)\r
 \r
+#define SOCK_SIGNATURE                SIGNATURE_32 ('S', 'O', 'C', 'K')\r
+\r
+#define SOCK_FROM_THIS(a)             CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)\r
+\r
 #define SOCK_FROM_TOKEN(Token)        (((SOCK_TOKEN *) (Token))->Sock)\r
 \r
 #define PROTO_TOKEN_FORM_SOCK(SockToken, Type) \\r
index dbc82b51c155573252dc4a4b183654ab4d3c26a5..e04e5eb038a4529a1392df8d75b05d57e646e4a7 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Tcp request dispatcher implementation.\r
 \r
 Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
index 94a1753b812f9a39e87a11598fcb6bed26c086d5..d4ea65d723d3e3e61aece2c325ecfab94c3d6455 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Tcp driver function.\r
 \r
 Copyright (c) 2005 - 2007, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
index 4aee9592a316ec637f62ba2e477472124cec26fd..09388b5d83b7308d45a523a8936716cfb196c16b 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Tcp driver function header.\r
 \r
 Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
index ae2c666bf2051cb6757be254cfddbd4015154a91..fc14b3b4a66e46346be26006b74302dfdde5bf46 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Tcp function header file.\r
 \r
 Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
index 3c2accf9eb8840a0134ae4a970ea3be11946cbfb..763789e41080ad1ca24f198fb8de7a8982cfc7c9 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  TCP4 protocol services header file.\r
 \r
 Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
@@ -17,6 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Socket.h"\r
 \r
 #include "Tcp4Proto.h"\r
+#include "Tcp4Func.h"\r
 #include "Tcp4Driver.h"\r
 \r
 \r
index 2caa1a4a05ecfd67cca788f1f460b259ac60bfd8..243def839aa1fbcc5c3ef0f2c47125bb8f93a607 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Tcp option's routine header file.\r
     \r
 Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
 All rights reserved. This program and the accompanying materials\r
index f1eaad5be1939011f45ea1f26222a8800def8193..56b68db904873b55a932279eac48123aa7840536 100644 (file)
@@ -1,5 +1,6 @@
 /** @file\r
-        \r
+  Tcp Protocol header 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
@@ -311,18 +312,25 @@ extern UINT32         mTcpTick;
 //\r
 #define TCP_SUB_SEQ(Seq1, Seq2)     ((UINT32) ((Seq1) - (Seq2)))\r
 \r
+//\r
+// Check whether Flag is on\r
+//\r
 #define TCP_FLG_ON(Value, Flag)     ((BOOLEAN) (((Value) & (Flag)) != 0))\r
+\r
+//\r
+// Set and Clear operation on a Flag\r
+//\r
 #define TCP_SET_FLG(Value, Flag)    ((Value) |= (Flag))\r
 #define TCP_CLEAR_FLG(Value, Flag)  ((Value) &= ~(Flag))\r
 \r
 //\r
-// test whether two peers are equal\r
+// Test whether two peers are equal\r
 //\r
 #define TCP_PEER_EQUAL(Pa, Pb) \\r
   (((Pa)->Ip == (Pb)->Ip) && ((Pa)->Port == (Pb)->Port))\r
 \r
 //\r
-// test whether Pa matches Pb, or Pa is more specific\r
+// Test whether Pa matches Pb, or Pa is more specific\r
 // than pb. Zero means wildcard.\r
 //\r
 #define TCP_PEER_MATCH(Pa, Pb) \\r
@@ -342,8 +350,7 @@ extern UINT32         mTcpTick;
 typedef\r
 VOID\r
 (*TCP_TIMER_HANDLER) (\r
-  IN TCP_CB *Tcb\r
+  IN OUT TCP_CB *Tcb\r
   );\r
 \r
-#include "Tcp4Func.h"\r
 #endif\r