]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. retired NicIp4ConfigProtocolGuid
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 13 May 2009 09:29:44 +0000 (09:29 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 13 May 2009 09:29:44 +0000 (09:29 +0000)
2. moved NicIp4ConfigVariableGuid to Include/Guid/NicIp4ConfigNvData.h
3. updated Ip4ConfigDxe module to publish one setup page to Get/Set network parameters. Also, Ip4ConfgiDxe installed EFI HII Config Access protocol for each network devices.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8309 6f19259b-4bc3-4df7-8a09-765794883524

15 files changed:
MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h [new file with mode: 0644]
MdeModulePkg/Include/Protocol/NicIp4Config.h [deleted file]
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.vfr [new file with mode: 0644]
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeStrings.uni [new file with mode: 0644]
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c [new file with mode: 0644]
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.h [new file with mode: 0644]
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4NvData.h [new file with mode: 0644]
MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h

diff --git a/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h b/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h
new file mode 100644 (file)
index 0000000..94a2a5b
--- /dev/null
@@ -0,0 +1,73 @@
+/** @file\r
+  This file defines NIC_IP4_CONFIG_INFO structure.\r
+  \r
+Copyright (c) 2009, Intel Corporation\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
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __NIC_IP4_CONFIG_NVDATA_H__\r
+#define __NIC_IP4_CONFIG_NVDATA_H__\r
+\r
+#include <Protocol/Ip4Config.h>\r
+\r
+#define EFI_NIC_IP4_CONFIG_VARIABLE_GUID \\r
+  { \\r
+    0xd8944553, 0xc4dd, 0x41f4, { 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b } \\r
+  }\r
+\r
+#define EFI_NIC_IP4_CONFIG_VARIABLE          L"EfiNicIp4ConfigVariable"\r
+\r
+typedef enum {\r
+  //\r
+  // Config source: dhcp or static\r
+  //\r
+  IP4_CONFIG_SOURCE_DHCP     = 0,\r
+  IP4_CONFIG_SOURCE_STATIC,\r
+  IP4_CONFIG_SOURCE_MAX,\r
+\r
+  IP4_NIC_NAME_LENGTH        = 64,\r
+  MAX_IP4_CONFIG_IN_VARIABLE = 16\r
+} IP4_CONFIG_TYPE;\r
+\r
+//\r
+// The following structures are used by drivers/applications other\r
+// than EFI_IP4_PROTOCOL, such as ifconfig shell application, to\r
+// communicate the IP configuration information to EFI_IP4_CONFIG_PROTOCOL.\r
+// EFI_IP4_CONFIG_PROTOCOL in turn is used by EFI_IP4_PROTOCOL to get\r
+// the default IP4 configuration. ifconfig can't use the EFI_IP4_PROTOCOL\r
+// because it don't know how to configure the default IP address even\r
+// it has got the address.\r
+//\r
+\r
+///\r
+/// NIC_ADDR contains the interface's type and MAC address to identify\r
+/// a specific NIC.\r
+///\r
+typedef struct {\r
+  UINT16                    Type;       ///< Interface type\r
+  UINT8                     Len;        ///< Length of MAC address\r
+  EFI_MAC_ADDRESS           MacAddr;    ///< MAC address of interface\r
+} NIC_ADDR;\r
+\r
+///\r
+/// NIC_IP4_CONFIG_INFO contains the IP4 configure\r
+/// parameters for that NIC. NIC_IP4_CONFIG_INFO is\r
+/// of variable length.\r
+///\r
+typedef struct {\r
+  NIC_ADDR                  NicAddr;      ///< Link layer address to identify the NIC\r
+  UINT32                    Source;       ///< Static or DHCP\r
+  BOOLEAN                   Perment;      ///< Survive the reboot or not\r
+  EFI_IP4_IPCONFIG_DATA     Ip4Info;      ///< IP addresses\r
+} NIC_IP4_CONFIG_INFO;\r
+\r
+extern EFI_GUID gEfiNicIp4ConfigVariableGuid;\r
+\r
+#endif\r
diff --git a/MdeModulePkg/Include/Protocol/NicIp4Config.h b/MdeModulePkg/Include/Protocol/NicIp4Config.h
deleted file mode 100644 (file)
index 28284fe..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/** @file\r
-  This file defines NicIp4Config Protocol.\r
-  EFI_NIC_IP4_CONFIG_PROTOCOL is a proprietary protocol, not defined by UEFI2.0.\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation\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
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __NIC_IP4_CONFIG_H__\r
-#define __NIC_IP4_CONFIG_H__\r
-\r
-#include <Protocol/Ip4Config.h>\r
-\r
-\r
-#define EFI_NIC_IP4_CONFIG_PROTOCOL_GUID \\r
-  { \\r
-    0xdca3d4d, 0x12da, 0x4728, { 0xbf, 0x7e, 0x86, 0xce, 0xb9, 0x28, 0xd0, 0x67 } \\r
-  }\r
-\r
-#define EFI_NIC_IP4_CONFIG_VARIABLE_GUID \\r
-  { \\r
-    0xd8944553, 0xc4dd, 0x41f4, { 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b } \\r
-  }\r
-\r
-#define EFI_NIC_IP4_CONFIG_VARIABLE          L"EfiNicIp4ConfigVariable"\r
-\r
-\r
-typedef struct _EFI_NIC_IP4_CONFIG_PROTOCOL EFI_NIC_IP4_CONFIG_PROTOCOL;\r
-\r
-typedef enum {\r
-  //\r
-  // Config source: dhcp or static\r
-  //\r
-  IP4_CONFIG_SOURCE_DHCP     = 0,\r
-  IP4_CONFIG_SOURCE_STATIC,\r
-  IP4_CONFIG_SOURCE_MAX,\r
-\r
-  IP4_NIC_NAME_LENGTH        = 64,\r
-  MAX_IP4_CONFIG_IN_VARIABLE = 16\r
-} IP4_CONFIG_TYPE;\r
-\r
-//\r
-// The following structures are used by drivers/applications other\r
-// than EFI_IP4_PROTOCOL, such as ifconfig shell application, to\r
-// communicate the IP configuration information to EFI_IP4_CONFIG_PROTOCOL.\r
-// EFI_IP4_CONFIG_PROTOCOL in turn is used by EFI_IP4_PROTOCOL to get\r
-// the default IP4 configuration. ifconfig can't use the EFI_IP4_PROTOCOL\r
-// because it don't know how to configure the default IP address even\r
-// it has got the address.\r
-//\r
-\r
-///\r
-/// NIC_ADDR contains the interface's type and MAC address to identify\r
-/// a specific NIC.\r
-///\r
-typedef struct {\r
-  UINT16                    Type;       ///< Interface type\r
-  UINT8                     Len;        ///< Length of MAC address\r
-  EFI_MAC_ADDRESS           MacAddr;    ///< MAC address of interface\r
-} NIC_ADDR;\r
-\r
-///\r
-/// NIC_IP4_CONFIG_INFO contains the IP4 configure\r
-/// parameters for that NIC. NIC_IP4_CONFIG_INFO is\r
-/// of variable length.\r
-///\r
-typedef struct {\r
-  NIC_ADDR                  NicAddr;    ///< Link layer address to identify the NIC\r
-  UINT32                    Source;     ///< Static or DHCP\r
-  BOOLEAN                   Perment;    ///< Survive the reboot or not\r
-  EFI_IP4_IPCONFIG_DATA     Ip4Info;    ///< IP addresses\r
-} NIC_IP4_CONFIG_INFO;\r
-\r
-///\r
-/// IP4_CONFIG_VARIABLE is the EFI variable to\r
-/// save the configuration. IP4_CONFIG_VARIABLE is\r
-/// of variable length.\r
-///\r
-typedef struct {\r
-  UINT32                    Len;        ///< Total length of the variable\r
-  UINT16                    CheckSum;   ///< CheckSum, the same as IP4 head checksum\r
-  UINT32                    Count;      ///< Number of NIC_IP4_CONFIG_INFO follows\r
-  NIC_IP4_CONFIG_INFO       ConfigInfo;\r
-} IP4_CONFIG_VARIABLE;\r
-\r
-/**\r
-  Get the configure parameter for this NIC.\r
-\r
-  @param  This                   The NIC IP4 CONFIG protocol.\r
-  @param  Len                    The length of the NicConfig buffer.\r
-  @param  NicConfig              The buffer to receive the NIC's configure\r
-                                 parameter.\r
-\r
-  @retval EFI_SUCCESS            The configure parameter for this NIC was \r
-                                 obtained successfully .\r
-  @retval EFI_INVALID_PARAMETER  This or ConfigLen is NULL.\r
-  @retval EFI_NOT_FOUND          There is no configure parameter for the NIC in\r
-                                 NVRam.\r
-  @retval EFI_BUFFER_TOO_SMALL   The ConfigLen is too small or the NicConfig is \r
-                                 NULL.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_NIC_IP4_CONFIG_GET_INFO)(\r
-  IN EFI_NIC_IP4_CONFIG_PROTOCOL  *This,\r
-  IN OUT UINTN                    *Len,\r
-  OUT NIC_IP4_CONFIG_INFO         *NicConfig     OPTIONAL\r
-  );\r
-\r
-/**\r
-  Set the IP configure parameters for this NIC. \r
-\r
-  If Reconfig is TRUE, the IP driver will be informed to discard current \r
-  auto configure parameter and restart the auto configuration process. \r
-  If current there is a pending auto configuration, EFI_ALREADY_STARTED is\r
-  returned. You can only change the configure setting when either\r
-  the configure has finished or not started yet. If NicConfig, the\r
-  NIC's configure parameter is removed from the variable.\r
-\r
-  @param  This                   The NIC IP4 CONFIG protocol\r
-  @param  NicConfig              The new NIC IP4 configure parameter\r
-  @param  Reconfig               Inform the IP4 driver to restart the auto\r
-                                 configuration\r
-                                 \r
-  @retval EFI_SUCCESS            The configure parameter for this NIC was \r
-                                 set successfully .\r
-  @retval EFI_INVALID_PARAMETER  This is NULL or the configure parameter is\r
-                                 invalid.\r
-  @retval EFI_ALREADY_STARTED    There is a pending auto configuration.\r
-  @retval EFI_NOT_FOUND          No auto configure parameter is found\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_NIC_IP4_CONFIG_SET_INFO)(\r
-  IN EFI_NIC_IP4_CONFIG_PROTOCOL  *This,\r
-  IN NIC_IP4_CONFIG_INFO          *NicConfig     OPTIONAL,\r
-  IN BOOLEAN                      ReConfig\r
-  );\r
-\r
-/**\r
-  Return the name and MAC address for the NIC. The Name, if not NULL,\r
-  has at least IP4_NIC_NAME_LENGTH bytes.\r
-\r
-  @param  This                   The NIC IP4 CONFIG protocol\r
-  @param  Name                   The buffer to return the name\r
-  @param  NicAddr                The buffer to return the MAC addr\r
-\r
-  @retval EFI_INVALID_PARAMETER  This is NULL\r
-  @retval EFI_SUCCESS            The name or address of the NIC are returned.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_NIC_IP4_CONFIG_GET_NAME)(\r
-  IN  EFI_NIC_IP4_CONFIG_PROTOCOL *This,\r
-  OUT  UINT16                     *Name          OPTIONAL,\r
-  OUT  NIC_ADDR                   *NicAddr       OPTIONAL\r
-  );\r
-\r
-struct _EFI_NIC_IP4_CONFIG_PROTOCOL {\r
-  EFI_NIC_IP4_CONFIG_GET_NAME     GetName;\r
-  EFI_NIC_IP4_CONFIG_GET_INFO     GetInfo;\r
-  EFI_NIC_IP4_CONFIG_SET_INFO     SetInfo;\r
-};\r
-\r
-extern EFI_GUID gEfiNicIp4ConfigVariableGuid;\r
-extern EFI_GUID gEfiNicIp4ConfigProtocolGuid;\r
-#endif\r
index b69bd20a40ce00bb8bffe873d3e7cb893677b77b..59da12ce9140606aa0004f3dee379f796b780e5b 100644 (file)
@@ -15,11 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Protocol/ServiceBinding.h>\r
 #include <Protocol/SimpleNetwork.h>\r
-#include <Protocol/NicIp4Config.h>\r
+#include <Protocol/HiiConfigRouting.h>\r
 #include <Protocol/ComponentName.h>\r
 #include <Protocol/ComponentName2.h>\r
 #include <Protocol/Dpc.h>\r
 \r
+#include <Guid/NicIp4ConfigNvData.h>\r
+\r
 #include <Library/NetLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
@@ -28,11 +30,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DevicePathLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/PrintLib.h>\r
 \r
 EFI_DPC_PROTOCOL *mDpc = NULL;\r
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mNetLibHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};\r
 \r
+#define NIC_ITEM_CONFIG_SIZE   sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 2\r
+\r
 //\r
 // All the supported IP4 maskes in host byte order.\r
 //\r
@@ -1248,43 +1254,98 @@ NetLibDefaultAddressIsStatic (
   IN EFI_HANDLE  Controller\r
   )\r
 {\r
-  EFI_STATUS                   Status;\r
-  EFI_NIC_IP4_CONFIG_PROTOCOL  *NicIp4;\r
-  UINTN                        Len;\r
-  NIC_IP4_CONFIG_INFO          *ConfigInfo;\r
-  BOOLEAN                      IsStatic;\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Controller,\r
-                  &gEfiNicIp4ConfigProtocolGuid,\r
-                  (VOID **) &NicIp4\r
-                  );\r
+  EFI_STATUS                       Status;\r
+  EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;\r
+  UINTN                            Len;\r
+  NIC_IP4_CONFIG_INFO              *ConfigInfo;\r
+  BOOLEAN                          IsStatic;\r
+  EFI_STRING                       ConfigHdr;\r
+  EFI_STRING                       ConfigResp;\r
+  EFI_STRING                       AccessProgress;\r
+  EFI_STRING                       AccessResults;\r
+  EFI_STRING                       String;\r
+\r
+  ConfigInfo       = NULL;\r
+  ConfigHdr        = NULL;\r
+  ConfigResp       = NULL;\r
+  AccessProgress   = NULL;\r
+  AccessResults    = NULL;\r
+  IsStatic         = TRUE;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                &gEfiHiiConfigRoutingProtocolGuid,\r
+                NULL,\r
+                (VOID **) &HiiConfigRouting\r
+                );\r
   if (EFI_ERROR (Status)) {\r
     return TRUE;\r
   }\r
 \r
-  Len = 0;\r
-  Status = NicIp4->GetInfo (NicIp4, &Len, NULL);\r
-  if (Status != EFI_BUFFER_TOO_SMALL) {\r
-    return TRUE;\r
+  //\r
+  // Construct config request string header\r
+  //\r
+  ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Controller);\r
+  \r
+  Len = StrLen (ConfigHdr);\r
+  ConfigResp = AllocateZeroPool (Len + NIC_ITEM_CONFIG_SIZE * 2 + 200);\r
+  if (ConfigResp == NULL) {\r
+    goto ON_EXIT;\r
+  }\r
+  StrCpy (ConfigResp, ConfigHdr);\r
+\r
+  String = ConfigResp + Len;\r
+  UnicodeSPrint (\r
+    String, \r
+    (8 + 4 + 7 + 4) * sizeof (CHAR16), \r
+    L"&OFFSET=%04X&WIDTH=%04X", \r
+    OFFSET_OF (NIC_IP4_CONFIG_INFO, Source), \r
+    sizeof (UINT32)\r
+    );\r
+\r
+  Status = HiiConfigRouting->ExtractConfig (\r
+                               HiiConfigRouting,\r
+                               ConfigResp,\r
+                               &AccessProgress,\r
+                               &AccessResults\r
+                               );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_EXIT;\r
   }\r
 \r
-  ConfigInfo = AllocatePool (Len);\r
+  ConfigInfo = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO));\r
   if (ConfigInfo == NULL) {\r
-    return TRUE;\r
+    goto ON_EXIT;\r
   }\r
 \r
-  IsStatic = TRUE;\r
-  Status = NicIp4->GetInfo (NicIp4, &Len, ConfigInfo);\r
+  ConfigInfo->Source = IP4_CONFIG_SOURCE_STATIC;\r
+  Len = NIC_ITEM_CONFIG_SIZE;\r
+  Status = HiiConfigRouting->ConfigToBlock (\r
+                               HiiConfigRouting,\r
+                               AccessResults,\r
+                               (UINT8 *) ConfigInfo,\r
+                               &Len,\r
+                               &AccessProgress\r
+                               );\r
   if (EFI_ERROR (Status)) {\r
     goto ON_EXIT;\r
   }\r
 \r
   IsStatic = (BOOLEAN) (ConfigInfo->Source == IP4_CONFIG_SOURCE_STATIC);\r
-\r
\r
 ON_EXIT:\r
 \r
-  gBS->FreePool (ConfigInfo);\r
+  if (AccessResults != NULL) {\r
+    FreePool (AccessResults);\r
+  }\r
+  if (ConfigInfo != NULL) {\r
+    FreePool (ConfigInfo);\r
+  }\r
+  if (ConfigResp != NULL) {\r
+    FreePool (ConfigResp);\r
+  }\r
+  if (ConfigHdr != NULL) {\r
+    FreePool (ConfigHdr);\r
+  }\r
 \r
   return IsStatic;\r
 }\r
index 4ac01a7ca3fd295444c16dad6c2af2dab269d9e4..2f2b2d095fdd54752dd30186a37e9bb3d6985b9d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Instance of DxeNetLib.\r
 \r
-Copyright (c) 2006, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, 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
@@ -48,13 +48,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   UefiLib\r
   MemoryAllocationLib\r
   DevicePathLib\r
-  \r
+  HiiLib\r
+  PrintLib\r
+\r
+[Guids]  \r
+  gEfiNicIp4ConfigVariableGuid                  \r
+\r
 [Protocols]\r
   gEfiSimpleNetworkProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiNicIp4ConfigProtocolGuid                  # PROTOCOL ALWAYS_CONSUMED\r
   gEfiDpcProtocolGuid                           # PROTOCOL ALWAYS_CONSUMED\r
   gEfiComponentNameProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r
   gEfiComponentName2ProtocolGuid                # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiHiiConfigRoutingProtocolGuid              # PROTOCOL ALWAYS_CONSUMED\r
 \r
 [Depex]\r
   gEfiDpcProtocolGuid\r
index 4b8b85b1212db96959449af776d759d08e805573..d4905a8c9a1aa37360edc055598295431538b089 100644 (file)
   ## Include/Guid/Crc32GuidedSectionExtraction.h\r
   gEfiCrc32GuidedSectionExtractionGuid = { 0xFC1BCDB0, 0x7D31, 0x49aa, {0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } }\r
 \r
+  ## Include/Guid/NicIp4ConfigNvData.h\r
+  gEfiNicIp4ConfigVariableGuid   = {0xd8944553, 0xc4dd, 0x41f4, { 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b }}\r
+\r
 [Protocols.common] \r
   ## Load File protocol provides capability to load and unload EFI image into memory and execute it.\r
   ## Include/Protocol/LoadPe32Image.h\r
   ## Include/Protocol/GenericMemoryTest.h\r
   gEfiGenericMemTestProtocolGuid = { 0x309DE7F1, 0x7F5E, 0x4ACE, { 0xB4, 0x9C, 0x53, 0x1B, 0xE5, 0xAA, 0x95, 0xEF }}\r
   \r
-  ## Include/Protocol/NicIp4Config.h\r
-  gEfiNicIp4ConfigProtocolGuid   = {0xdca3d4d, 0x12da, 0x4728,  { 0xbf, 0x7e, 0x86, 0xce, 0xb9, 0x28, 0xd0, 0x67 }}\r
-  \r
-  ## Include/Protocol/NicIp4Config.h\r
-  gEfiNicIp4ConfigVariableGuid   = {0xd8944553, 0xc4dd, 0x41f4, { 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b }}\r
-  \r
   ## Include/Protocol/Dpc.h\r
   gEfiDpcProtocolGuid            = {0x480f8ae9, 0xc46, 0x4aa9,  { 0xbc, 0x89, 0xdb, 0x9f, 0xba, 0x61, 0x98, 0x6 }}\r
   \r
index 291ea1a933b62f57cea58f30e754115cda826afd..ed130d9c88400fb9e1cf202b508a758ab2c4b9b5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This code implements the IP4Config and NicIp4Config protocols.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation.<BR>                                                         \r
+Copyright (c) 2006 - 2009, 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<BR>\r
@@ -16,45 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];\r
 \r
-/**\r
-  Return the name and MAC address for the NIC. The Name, if not NULL,\r
-  has at least IP4_NIC_NAME_LENGTH bytes.\r
-\r
-  @param  This                   The NIC IP4 CONFIG protocol\r
-  @param  Name                   The buffer to return the name\r
-  @param  NicAddr                The buffer to return the MAC addr\r
-\r
-  @retval EFI_INVALID_PARAMETER  This is NULL\r
-  @retval EFI_SUCCESS            The name or address of the NIC are returned.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EfiNicIp4ConfigGetName (\r
-  IN  EFI_NIC_IP4_CONFIG_PROTOCOL  *This,\r
-  OUT  UINT16                      *Name          OPTIONAL,\r
-  OUT  NIC_ADDR                    *NicAddr       OPTIONAL\r
-  )\r
-{\r
-  IP4_CONFIG_INSTANCE       *Instance;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Instance = IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG (This);\r
-\r
-  if (Name != NULL) {\r
-    CopyMem (Name, Instance->NicName, IP4_NIC_NAME_LENGTH);\r
-  }\r
-\r
-  if (NicAddr != NULL) {\r
-    CopyMem (NicAddr, &Instance->NicAddr, sizeof (*NicAddr));\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
 \r
 /**\r
   Get the NIC's configure information from the IP4 configure variable.\r
@@ -116,7 +77,7 @@ Ip4ConfigGetNicInfo (
 /**\r
   Get the configure parameter for this NIC.\r
 \r
-  @param  This                   The NIC IP4 CONFIG protocol.\r
+  @param  Instance               The IP4 CONFIG Instance.\r
   @param  ConfigLen              The length of the NicConfig buffer.\r
   @param  NicConfig              The buffer to receive the NIC's configure\r
                                  parameter.\r
@@ -133,24 +94,22 @@ Ip4ConfigGetNicInfo (
 EFI_STATUS\r
 EFIAPI\r
 EfiNicIp4ConfigGetInfo (\r
-  IN  EFI_NIC_IP4_CONFIG_PROTOCOL *This,\r
+  IN  IP4_CONFIG_INSTANCE         *Instance,\r
   IN OUT  UINTN                   *ConfigLen,\r
   OUT NIC_IP4_CONFIG_INFO         *NicConfig\r
   )\r
 {\r
-  IP4_CONFIG_INSTANCE *Instance;\r
   NIC_IP4_CONFIG_INFO *Config;\r
   EFI_STATUS          Status;\r
   UINTN               Len;\r
 \r
-  if ((This == NULL) || (ConfigLen == NULL)) {\r
+  if ((Instance == NULL) || (ConfigLen == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   //\r
   // Read the Nic's configuration parameter from variable\r
   //\r
-  Instance  = IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG (This);\r
   Config    = Ip4ConfigGetNicInfo (&Instance->NicAddr);\r
 \r
   if (Config == NULL) {\r
@@ -187,7 +146,7 @@ EfiNicIp4ConfigGetInfo (
   the configure has finished or not started yet. If NicConfig, the\r
   NIC's configure parameter is removed from the variable.\r
 \r
-  @param  This                   The NIC IP4 CONFIG protocol\r
+  @param  Instance               The IP4 CONFIG instance.\r
   @param  NicConfig              The new NIC IP4 configure parameter\r
   @param  Reconfig               Inform the IP4 driver to restart the auto\r
                                  configuration\r
@@ -203,12 +162,11 @@ EfiNicIp4ConfigGetInfo (
 EFI_STATUS\r
 EFIAPI\r
 EfiNicIp4ConfigSetInfo (\r
-  IN EFI_NIC_IP4_CONFIG_PROTOCOL  *This,\r
+  IN IP4_CONFIG_INSTANCE          *Instance,\r
   IN NIC_IP4_CONFIG_INFO          *NicConfig     OPTIONAL,\r
   IN BOOLEAN                      Reconfig\r
   )\r
 {\r
-  IP4_CONFIG_INSTANCE *Instance;\r
   IP4_CONFIG_VARIABLE *Variable;\r
   IP4_CONFIG_VARIABLE *NewVariable;\r
   EFI_STATUS          Status;\r
@@ -216,12 +174,10 @@ EfiNicIp4ConfigSetInfo (
   //\r
   // Validate the parameters\r
   //\r
-  if (This == NULL) {\r
+  if (Instance == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  Instance = IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG (This);\r
-\r
   if ((NicConfig != NULL) && (!Ip4ConfigIsValid (NicConfig) ||\r
       !NIC_ADDR_EQUAL (&NicConfig->NicAddr, &Instance->NicAddr))) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -372,7 +328,7 @@ Ip4ConfigOnDhcp4Complete (
     // ignore the return status of EfiNicIp4ConfigSetInfo. Network\r
     // stack can operate even that failed.\r
     //\r
-    EfiNicIp4ConfigSetInfo (&Instance->NicIp4Protocol, Instance->NicConfig, FALSE);\r
+    EfiNicIp4ConfigSetInfo (Instance, Instance->NicConfig, FALSE);\r
   }\r
 \r
 ON_EXIT:\r
@@ -802,8 +758,3 @@ EFI_IP4_CONFIG_PROTOCOL     mIp4ConfigProtocolTemplate = {
   EfiIp4ConfigGetData\r
 };\r
 \r
-EFI_NIC_IP4_CONFIG_PROTOCOL mNicIp4ConfigProtocolTemplate = {\r
-  EfiNicIp4ConfigGetName,\r
-  EfiNicIp4ConfigGetInfo,\r
-  EfiNicIp4ConfigSetInfo\r
-};\r
index e18c22ca7b085c476e8a244f5f54eae4a650126b..c685fc7443cd8ddbf5234603290199781623e982 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Header file for IP4Config driver.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 2009, 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<BR>\r
@@ -20,7 +20,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/Dhcp4.h>\r
 #include <Protocol/Ip4Config.h>\r
 #include <Protocol/ManagedNetwork.h>\r
+#include <Protocol/HiiConfigAccess.h>\r
+#include <Protocol/HiiDatabase.h>\r
+#include <Protocol/HiiConfigRouting.h>\r
 \r
+#include <Guid/MdeModuleHii.h>\r
+\r
+#include <Library/DevicePathLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -29,13 +35,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/NetLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/PrintLib.h>\r
 \r
 #include "NicIp4Variable.h"\r
 \r
 typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE;\r
 \r
 //\r
-// Global variables \r
+// Global variables\r
 //\r
 extern EFI_DRIVER_BINDING_PROTOCOL   gIp4ConfigDriverBinding;\r
 extern EFI_COMPONENT_NAME_PROTOCOL   gIp4ConfigComponentName;\r
@@ -43,7 +51,6 @@ extern EFI_COMPONENT_NAME2_PROTOCOL  gIp4ConfigComponentName2;
 \r
 extern IP4_CONFIG_INSTANCE           *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];\r
 extern EFI_IP4_CONFIG_PROTOCOL       mIp4ConfigProtocolTemplate;\r
-extern EFI_NIC_IP4_CONFIG_PROTOCOL   mNicIp4ConfigProtocolTemplate;\r
 \r
 #define IP4_PROTO_ICMP                 0x01\r
 #define IP4_CONFIG_INSTANCE_SIGNATURE  SIGNATURE_32 ('I', 'P', '4', 'C')\r
@@ -71,13 +78,53 @@ typedef struct {
 } IP4_CONFIG_DHCP4_OPTION;\r
 #pragma pack()\r
 \r
+\r
+typedef struct {\r
+  UINTN             DeviceNum;\r
+  BOOLEAN           Enabled;\r
+  EFI_IPv4_ADDRESS  LocalIp;\r
+  EFI_IPv4_ADDRESS  SubnetMask;\r
+  EFI_IPv4_ADDRESS  Gateway;\r
+} IP4_CONFIG_SESSION_DATA;\r
+\r
+typedef struct _IP4_CONFIG_FORM_ENTRY {\r
+  LIST_ENTRY                    Link;\r
+  IP4_CONFIG_INSTANCE           *Ip4ConfigInstance;\r
+  EFI_HANDLE                    Controller;\r
+  CHAR16                        MacString[95];\r
+  EFI_STRING_ID                 PortTitleToken;\r
+  EFI_STRING_ID                 PortTitleHelpToken;\r
+  IP4_CONFIG_SESSION_DATA       SessionConfigData;\r
+} IP4CONFIG_FORM_ENTRY;\r
+\r
+#define IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE  SIGNATURE_32 ('I', 'P', '4', 'C')\r
+\r
+typedef struct _IP4_FORM_CALLBACK_INFO_INSTANCE {\r
+  UINTN                            Signature;\r
+  EFI_HANDLE                       DriverHandle;\r
+  EFI_HII_CONFIG_ACCESS_PROTOCOL   ConfigAccess;\r
+  EFI_HII_DATABASE_PROTOCOL        *HiiDatabase;\r
+  EFI_HII_CONFIG_ROUTING_PROTOCOL  *ConfigRouting;\r
+  EFI_HII_HANDLE                   RegisteredHandle;\r
+  IP4CONFIG_FORM_ENTRY             *Current;\r
+} IP4_FORM_CALLBACK_INFO;\r
+\r
+#define IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK(Callback) \\r
+  CR ( \\r
+  Callback, \\r
+  IP4_FORM_CALLBACK_INFO, \\r
+  ConfigAccess, \\r
+  IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE \\r
+  )\r
+\r
 struct _IP4_CONFIG_INSTANCE {\r
   UINT32                        Signature;\r
   EFI_HANDLE                    Controller;\r
   EFI_HANDLE                    Image;\r
 \r
   EFI_IP4_CONFIG_PROTOCOL       Ip4ConfigProtocol;\r
-  EFI_NIC_IP4_CONFIG_PROTOCOL   NicIp4Protocol;\r
+\r
+  IP4_FORM_CALLBACK_INFO        Ip4FormCallbackInfo;\r
 \r
   //\r
   // NicConfig's state, such as IP4_CONFIG_STATE_IDLE\r
@@ -116,8 +163,65 @@ struct _IP4_CONFIG_INSTANCE {
 #define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \\r
   CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)\r
 \r
-#define IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG(this) \\r
-  CR (this, IP4_CONFIG_INSTANCE, NicIp4Protocol, IP4_CONFIG_INSTANCE_SIGNATURE)\r
+#define IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO(this) \\r
+  CR (this, IP4_CONFIG_INSTANCE, Ip4FormCallbackInfo, IP4_CONFIG_INSTANCE_SIGNATURE)\r
+\r
+\r
+/**\r
+  Set the IP configure parameters for this NIC. \r
+\r
+  If Reconfig is TRUE, the IP driver will be informed to discard current \r
+  auto configure parameter and restart the auto configuration process. \r
+  If current there is a pending auto configuration, EFI_ALREADY_STARTED is\r
+  returned. You can only change the configure setting when either\r
+  the configure has finished or not started yet. If NicConfig, the\r
+  NIC's configure parameter is removed from the variable.\r
+\r
+  @param  Instance               The IP4 CONFIG instance.\r
+  @param  NicConfig              The new NIC IP4 configure parameter\r
+  @param  Reconfig               Inform the IP4 driver to restart the auto\r
+                                 configuration\r
+                                 \r
+  @retval EFI_SUCCESS            The configure parameter for this NIC was \r
+                                 set successfully .\r
+  @retval EFI_INVALID_PARAMETER  This is NULL or the configure parameter is\r
+                                 invalid.\r
+  @retval EFI_ALREADY_STARTED    There is a pending auto configuration.\r
+  @retval EFI_NOT_FOUND          No auto configure parameter is found\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiNicIp4ConfigSetInfo (\r
+  IN IP4_CONFIG_INSTANCE          *Instance,\r
+  IN NIC_IP4_CONFIG_INFO          *NicConfig     OPTIONAL,\r
+  IN BOOLEAN                      Reconfig\r
+  );\r
+\r
+/**\r
+  Get the configure parameter for this NIC.\r
+\r
+  @param  Instance               The IP4 CONFIG Instance.\r
+  @param  ConfigLen              The length of the NicConfig buffer.\r
+  @param  NicConfig              The buffer to receive the NIC's configure\r
+                                 parameter.\r
+\r
+  @retval EFI_SUCCESS            The configure parameter for this NIC was \r
+                                 obtained successfully .\r
+  @retval EFI_INVALID_PARAMETER  This or ConfigLen is NULL.\r
+  @retval EFI_NOT_FOUND          There is no configure parameter for the NIC in\r
+                                 NVRam.\r
+  @retval EFI_BUFFER_TOO_SMALL   The ConfigLen is too small or the NicConfig is \r
+                                 NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiNicIp4ConfigGetInfo (\r
+  IN  IP4_CONFIG_INSTANCE         *Instance,\r
+  IN OUT  UINTN                   *ConfigLen,\r
+  OUT NIC_IP4_CONFIG_INFO         *NicConfig\r
+  );\r
 \r
 /**\r
   Release all the DHCP related resources.\r
@@ -144,7 +248,7 @@ VOID
 Ip4ConfigCleanConfig (\r
   IN IP4_CONFIG_INSTANCE        *Instance\r
   );\r
-  \r
+\r
 //\r
 // EFI Component Name Functions\r
 //\r
@@ -168,7 +272,7 @@ Ip4ConfigCleanConfig (
                                 languages specified in SupportedLanguages. The\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.                                \r
+                                in RFC 3066 or ISO 639-2 language code format.\r
   @param  DriverName[out]       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
@@ -225,14 +329,14 @@ Ip4ConfigComponentNameGetDriverName (
                                 languages specified in SupportedLanguages. The\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
+                                RFC 3066 or ISO 639-2 language code format.\r
   @param  ControllerName[out]   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
                                 Language from the point of view of the driver\r
                                 specified by This.\r
-                                \r
+\r
   @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
                                 the language specified by Language for the\r
                                 driver specified by This was returned in\r
@@ -258,7 +362,7 @@ Ip4ConfigComponentNameGetControllerName (
   IN  CHAR8                                           *Language,\r
   OUT CHAR16                                          **ControllerName\r
   );\r
-  \r
+\r
 /**\r
   Test to see if this driver supports ControllerHandle.\r
 \r
@@ -279,7 +383,7 @@ Ip4ConfigDriverBindingSupported (
   IN EFI_HANDLE                   ControllerHandle,\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL\r
   );\r
-  \r
+\r
 /**\r
   Start this driver on ControllerHandle.\r
 \r
@@ -300,7 +404,7 @@ Ip4ConfigDriverBindingStart (
   IN EFI_HANDLE                   ControllerHandle,\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
   );\r
-  \r
+\r
 /**\r
   Stop this driver on ControllerHandle.\r
 \r
@@ -322,5 +426,5 @@ Ip4ConfigDriverBindingStop (
   IN UINTN                        NumberOfChildren,\r
   IN EFI_HANDLE                   *ChildHandleBuffer\r
   );\r
-  \r
+\r
 #endif\r
index 7fcd6b851e43a04578bfde891e2efe29b493e5dd..ade299d6b4680c0d67d564374f70c8cb737d0e58 100644 (file)
@@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 \r
 #include "Ip4Config.h"\r
+#include "Ip4ConfigNV.h"\r
 \r
 EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding = {\r
   Ip4ConfigDriverBindingSupported,\r
@@ -41,6 +42,8 @@ EfiIp4ConfigUnload (
 {\r
   UINT32      Index;\r
 \r
+  Ip4ConfigFormUnload ();\r
+\r
   //\r
   //  Stop all the IP4_CONFIG instances\r
   //\r
@@ -78,6 +81,8 @@ Ip4ConfigDriverEntryPoint (
   IN EFI_SYSTEM_TABLE       *SystemTable\r
   )\r
 {\r
+  Ip4ConfigFormInit ();\r
+\r
   return EfiLibInstallDriverBindingComponentName2 (\r
            ImageHandle,\r
            SystemTable,\r
@@ -219,7 +224,6 @@ Ip4ConfigDriverBindingStart (
   Instance->Image             = This->DriverBindingHandle;\r
 \r
   CopyMem (&Instance->Ip4ConfigProtocol, &mIp4ConfigProtocolTemplate, sizeof (mIp4ConfigProtocolTemplate));\r
-  CopyMem (&Instance->NicIp4Protocol, &mNicIp4ConfigProtocolTemplate, sizeof (mNicIp4ConfigProtocolTemplate));\r
 \r
   Instance->State             = IP4_CONFIG_STATE_IDLE;\r
   Instance->Mnp               = Mnp;\r
@@ -242,7 +246,7 @@ Ip4ConfigDriverBindingStart (
 \r
   Instance->NicAddr.Type    = (UINT16) SnpMode.IfType;\r
   Instance->NicAddr.Len     = (UINT8) SnpMode.HwAddressSize;\r
-  CopyMem (&Instance->NicAddr.MacAddr, &SnpMode.CurrentAddress, sizeof (Instance->NicAddr.MacAddr));\r
+  CopyMem (&Instance->NicAddr.MacAddr, &SnpMode.CurrentAddress, Instance->NicAddr.Len);\r
 \r
   //\r
   // Add it to the global list, and compose the name\r
@@ -275,6 +279,14 @@ Ip4ConfigDriverBindingStart (
     goto ON_ERROR;\r
   }\r
 \r
+  Status = Ip4ConfigDeviceInit (Instance);\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Try to add a port configuration page for this controller.\r
+    //\r
+    Ip4ConfigUpdateForm (Instance, TRUE);\r
+  }\r
+\r
   //\r
   // Install the IP4_CONFIG and NIC_IP4CONFIG protocols\r
   //\r
@@ -282,8 +294,6 @@ Ip4ConfigDriverBindingStart (
                   &ControllerHandle,\r
                   &gEfiIp4ConfigProtocolGuid,\r
                   &Instance->Ip4ConfigProtocol,\r
-                  &gEfiNicIp4ConfigProtocolGuid,\r
-                  &Instance->NicIp4Protocol,\r
                   NULL\r
                   );\r
 \r
@@ -464,6 +474,8 @@ Ip4ConfigDriverBindingStop (
 \r
   Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (Ip4Config);\r
 \r
+  Ip4ConfigDeviceUnload (Instance);\r
+\r
   //\r
   // Unload the protocols first to inform the top drivers\r
   //\r
@@ -471,8 +483,6 @@ Ip4ConfigDriverBindingStop (
                   NicHandle,\r
                   &gEfiIp4ConfigProtocolGuid,\r
                   &Instance->Ip4ConfigProtocol,\r
-                  &gEfiNicIp4ConfigProtocolGuid,\r
-                  &Instance->NicIp4Protocol,\r
                   NULL\r
                   );\r
 \r
index e7e509a8b63758cb06ba0f1392ccdd90d982ab69..8a3aed75d3fbc0adf6fa87c2b18c2b213c397c02 100644 (file)
@@ -2,7 +2,7 @@
 # Component name for module Ip4Config\r
 #\r
 # FIX ME!\r
-# Copyright (c) 2006, Intel Corporation\r
+# Copyright (c) 2006 - 2009, Intel Corporation\r
 #\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
   Ip4Config.h\r
   NicIp4Variable.h\r
   Ip4Config.c\r
+  Ip4ConfigDxe.vfr\r
+  Ip4ConfigDxeStrings.uni\r
+  Ip4NvData.h\r
+  Ip4ConfigNv.h\r
+  Ip4ConfigNv.c\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   UefiRuntimeServicesTableLib\r
   DebugLib\r
   NetLib\r
+  HiiLib\r
+  PrintLib\r
 \r
 \r
 [Protocols]\r
   gEfiDhcp4ServiceBindingProtocolGuid           # PROTOCOL ALWAYS_CONSUMED\r
   gEfiManagedNetworkServiceBindingProtocolGuid  # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiIp4ConfigProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiIp4ConfigProtocolGuid                     # PROTOCOL ALWAYS_PRODUCED\r
   gEfiManagedNetworkProtocolGuid                # PROTOCOL ALWAYS_CONSUMED\r
   gEfiDhcp4ProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiNicIp4ConfigVariableGuid                  # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiNicIp4ConfigProtocolGuid                  # PROTOCOL ALWAYS_CONSUMED
\ No newline at end of file
+  gEfiHiiDatabaseProtocolGuid                   # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiHiiConfigAccessProtocolGuid               # PROTOCOL ALWAYS_CONSUMED\r
+\r
+[Guids]\r
+  gEfiIfrTianoGuid                              ## CONSUMES ## Guid\r
+  gEfiNicIp4ConfigVariableGuid                  ## CONSUMES ## Guid\r
+   
\ No newline at end of file
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.vfr b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.vfr
new file mode 100644 (file)
index 0000000..eb5b408
--- /dev/null
@@ -0,0 +1,92 @@
+/** @file\r
+  Vfr file for IP4 config.\r
+\r
+Copyright (c) 2009, 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
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include "Ip4NvData.h"\r
+\r
+#define EFI_NETWORK_DEVICE_CLASS  0x04\r
+\r
+formset\r
+  guid     = EFI_NIC_IP4_CONFIG_VARIABLE_GUID,\r
+  title    = STRING_TOKEN(STR_IP4_CONFIG_FORM_TITLE),\r
+  help     = STRING_TOKEN(STR_IP4_CONFIG_FORM_HELP),\r
+  class    = EFI_NETWORK_DEVICE_CLASS,\r
+  subclass = 0x03,\r
+\r
+  varstore IP4_CONFIG_IFR_NVDATA,\r
+    name = EfiNicIp4ConfigVariable,\r
+    guid = EFI_NIC_IP4_CONFIG_VARIABLE_GUID;\r
+\r
+  form formid = FORMID_MAIN_FORM,\r
+    title  = STRING_TOKEN(STR_IP4_MAIN_FORM_TITLE);\r
+\r
+    label DEVICE_ENTRY_LABEL;\r
+    label LABEL_END;\r
+\r
+  endform;\r
+\r
+  form formid = FORMID_DEVICE_FORM,\r
+    title  = STRING_TOKEN(STR_IP4_DEVICE_FORM_TITLE);\r
+\r
+    checkbox varid = EfiNicIp4ConfigVariable.DhcpEnable,\r
+            prompt = STRING_TOKEN(STR_IP4_ENABLE_DHCP),\r
+            help   = STRING_TOKEN(STR_IP4_ENABLE_DHCP),\r
+            flags  = INTERACTIVE,\r
+            key    = KEY_DHCP_ENABLE,\r
+    endcheckbox;\r
+\r
+    suppressif ideqval EfiNicIp4ConfigVariable.DhcpEnable == 0x01;\r
+    string  varid   = EfiNicIp4ConfigVariable.StationAddress,\r
+            prompt  = STRING_TOKEN(STR_IP4_LOCAL_IP_ADDRESS),\r
+            help    = STRING_TOKEN(STR_IP4_IP_ADDRESS_HELP),\r
+            flags   = INTERACTIVE,\r
+            key     = KEY_LOCAL_IP,\r
+            minsize = IP_MIN_SIZE,\r
+            maxsize = IP_MAX_SIZE,\r
+    endstring;\r
+\r
+    string  varid   = EfiNicIp4ConfigVariable.SubnetMask,\r
+            prompt  = STRING_TOKEN(STR_IP4_LOCAL_MASK),\r
+            help    = STRING_TOKEN(STR_IP4_IP_ADDRESS_HELP),\r
+            flags   = INTERACTIVE,\r
+            key     = KEY_SUBNET_MASK,\r
+            minsize = IP_MIN_SIZE,\r
+           maxsize = IP_MAX_SIZE,\r
+    endstring;\r
+\r
+    string  varid   = EfiNicIp4ConfigVariable.GatewayAddress,\r
+            prompt  = STRING_TOKEN(STR_IP4_LOCAL_GATEWAY),\r
+            help    = STRING_TOKEN(STR_IP4_IP_ADDRESS_HELP),\r
+            flags   = INTERACTIVE,\r
+            key     = KEY_GATE_WAY,\r
+            minsize = IP_MIN_SIZE,\r
+            maxsize = IP_MAX_SIZE,\r
+    endstring;\r
+    endif;\r
+\r
+    subtitle text = STRING_TOKEN(STR_NULL);\r
+\r
+    goto FORMID_DEVICE_FORM,\r
+    prompt = STRING_TOKEN (STR_SAVE_CHANGES),\r
+    help   = STRING_TOKEN (STR_SAVE_CHANGES),\r
+    flags  = INTERACTIVE,\r
+    key    = KEY_SAVE_CHANGES;\r
+\r
+    goto FORMID_MAIN_FORM,\r
+    prompt = STRING_TOKEN (STR_RETURN_MAIN_FORM),\r
+    help   = STRING_TOKEN (STR_RETURN_MAIN_FORM),\r
+    flags  = 0;\r
+\r
+  endform;\r
+\r
+endformset;\r
+\r
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeStrings.uni b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeStrings.uni
new file mode 100644 (file)
index 0000000..8951913
Binary files /dev/null and b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeStrings.uni differ
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c
new file mode 100644 (file)
index 0000000..c25e682
--- /dev/null
@@ -0,0 +1,1139 @@
+/** @file\r
+  Helper functions for configuring or getting the parameters relating to Ip4.\r
+\r
+Copyright (c) 2009, 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
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "Ip4ConfigNv.h"\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8  Ip4HexString[] = "0123456789ABCDEFabcdef";\r
+\r
+UINTN           mNumberOfIp4Devices      = 0;\r
+\r
+IP4_FORM_CALLBACK_INFO  *mCallbackInfo = NULL;\r
+\r
+LIST_ENTRY      mIp4ConfigFormList = {\r
+  &mIp4ConfigFormList,\r
+  &mIp4ConfigFormList\r
+};\r
+\r
+HII_VENDOR_DEVICE_PATH  mIp4ConifgHiiVendorDevicePath = {\r
+  {\r
+    {\r
+      HARDWARE_DEVICE_PATH,\r
+      HW_VENDOR_DP,\r
+      {\r
+        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
+        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
+      }\r
+    },\r
+    //\r
+    // {6D3FD906-42B9-4220-9E63-9D8C972D58EE}\r
+    //\r
+    { 0x6d3fd906, 0x42b9, 0x4220, { 0x9e, 0x63, 0x9d, 0x8c, 0x97, 0x2d, 0x58, 0xee } }\r
+  },\r
+  {\r
+    END_DEVICE_PATH_TYPE,\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+    {\r
+      (UINT8) (END_DEVICE_PATH_LENGTH),\r
+      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
+    }\r
+  }\r
+};\r
+\r
+/**\r
+  Convert the mac address into a hexadecimal encoded "-" seperated string.\r
+\r
+  @param[in]  Mac The mac address.\r
+  @param[in]  Len  Length in bytes of the mac address.\r
+  @param[out] Str The storage to return the mac string.\r
+\r
+**/\r
+VOID\r
+Ip4MacAddrToStr (\r
+  IN  EFI_MAC_ADDRESS  *Mac,\r
+  IN  UINT32           Len,\r
+  OUT CHAR16           *Str\r
+  )\r
+{\r
+  UINT32  Index;\r
+\r
+  for (Index = 0; Index < Len; Index++) {\r
+    Str[3 * Index]      = (CHAR16) Ip4HexString[(Mac->Addr[Index] >> 4) & 0x0F];\r
+    Str[3 * Index + 1]  = (CHAR16) Ip4HexString[Mac->Addr[Index] & 0x0F];\r
+    Str[3 * Index + 2]  = L'-';\r
+  }\r
+\r
+  Str[3 * Index - 1] = L'\0';\r
+}\r
+\r
+/**\r
+  Calculate the prefix length of the IPv4 subnet mask.\r
+\r
+  @param[in]  SubnetMask The IPv4 subnet mask.\r
+\r
+  @return The prefix length of the subnet mask.\r
+  @retval 0 Other errors as indicated.\r
+**/\r
+UINT8\r
+GetSubnetMaskPrefixLength (\r
+  IN EFI_IPv4_ADDRESS  *SubnetMask\r
+  )\r
+{\r
+  UINT8   Len;\r
+  UINT32  ReverseMask;\r
+\r
+  //\r
+  // The SubnetMask is in network byte order.\r
+  //\r
+  ReverseMask = (SubnetMask->Addr[0] << 24) | (SubnetMask->Addr[1] << 16) | (SubnetMask->Addr[2] << 8) | (SubnetMask->Addr[3]);\r
+\r
+  //\r
+  // Reverse it.\r
+  //\r
+  ReverseMask = ~ReverseMask;\r
+\r
+  if ((ReverseMask & (ReverseMask + 1)) != 0) {\r
+    return 0;\r
+  }\r
+\r
+  Len = 0;\r
+\r
+  while (ReverseMask != 0) {\r
+    ReverseMask = ReverseMask >> 1;\r
+    Len++;\r
+  }\r
+\r
+  return (UINT8) (32 - Len);\r
+}\r
+\r
+/**\r
+  Convert the decimal dotted IPv4 address into the binary IPv4 address.\r
+\r
+  @param[in]   Str             The UNICODE string.\r
+  @param[out]  Ip              The storage to return the ASCII string.\r
+\r
+  @retval EFI_SUCCESS           The binary IP address is returned in Ip.\r
+  @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r
+**/\r
+EFI_STATUS\r
+Ip4AsciiStrToIp (\r
+  IN  CHAR8             *Str,\r
+  OUT EFI_IPv4_ADDRESS  *Ip\r
+  )\r
+{\r
+  UINTN Index;\r
+  UINTN Number;\r
+\r
+  Index = 0;\r
+\r
+  while (*Str != 0) {\r
+\r
+    if (Index > 3) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    Number = 0;\r
+    while (NET_IS_DIGIT (*Str)) {\r
+      Number = Number * 10 + (*Str - '0');\r
+      Str++;\r
+    }\r
+\r
+    if (Number > 0xFF) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    Ip->Addr[Index] = (UINT8) Number;\r
+\r
+    if ((*Str != '\0') && (*Str != '.')) {\r
+      //\r
+      // The current character should be either the NULL terminator or\r
+      // the dot delimiter.\r
+      //\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    if (*Str == '.') {\r
+      //\r
+      // Skip the delimiter.\r
+      //\r
+      Str++;\r
+    }\r
+\r
+    Index++;\r
+  }\r
+\r
+  if (Index != 4) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Convert the IPv4 address into a dotted string.\r
+\r
+  @param[in]   Ip   The IPv4 address.\r
+  @param[out]  Str  The dotted IP string.\r
+**/\r
+VOID\r
+Ip4ConfigIpToStr (\r
+  IN  EFI_IPv4_ADDRESS  *Ip,\r
+  OUT CHAR16            *Str\r
+  )\r
+{\r
+  UnicodeSPrint (Str, 2 * IP4_STR_MAX_SIZE, L"%d.%d.%d.%d", Ip->Addr[0], Ip->Addr[1], Ip->Addr[2], Ip->Addr[3]);\r
+}\r
+\r
+\r
+/**\r
+  Convert the network configuration data into the IFR data.\r
+\r
+  @param[in]   ConfigFormEntry The IP4 configuration form entry.\r
+  @param[out]  IfrNvData       The IFR nv data.\r
+**/\r
+VOID\r
+Ip4ConfigConvertDeviceConfigDataToIfrNvData (\r
+  IN  IP4_CONFIG_INSTANCE       *Ip4ConfigInstance,\r
+  OUT IP4_CONFIG_IFR_NVDATA     *IfrFormNvData\r
+  )\r
+{\r
+  EFI_STATUS                    Status;\r
+  NIC_IP4_CONFIG_INFO           *NicConfig;\r
+  UINTN                         ConfigLen;\r
+\r
+  IfrFormNvData->DhcpEnable = 1;\r
+\r
+  ConfigLen = sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 2;\r
+  NicConfig = AllocateZeroPool (ConfigLen);\r
+  ASSERT (NicConfig != NULL);\r
+  Status = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance, &ConfigLen, NicConfig);\r
+  if (!EFI_ERROR (Status)) {\r
+    if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) {\r
+      IfrFormNvData->DhcpEnable = 1;\r
+    } else {\r
+      IfrFormNvData->DhcpEnable = 0;\r
+      Ip4ConfigIpToStr (&NicConfig->Ip4Info.StationAddress, IfrFormNvData->StationAddress);\r
+      Ip4ConfigIpToStr (&NicConfig->Ip4Info.SubnetMask, IfrFormNvData->SubnetMask);\r
+      Ip4ConfigIpToStr (&NicConfig->Ip4Info.RouteTable[1].GatewayAddress, IfrFormNvData->GatewayAddress);\r
+    }\r
+  }\r
+  FreePool (NicConfig);\r
+}\r
+\r
+/**\r
+  Get the IP4 configuration form entry by the index of the goto opcode actived.\r
+\r
+  @param[in]  Index The 0-based index of the goto opcode actived.\r
+\r
+  @return The IP4 configuration form entry found.\r
+**/\r
+IP4CONFIG_FORM_ENTRY *\r
+Ip4GetConfigFormEntryByIndex (\r
+  IN UINT32 Index\r
+  )\r
+{\r
+  UINT32                  CurrentIndex;\r
+  LIST_ENTRY              *Entry;\r
+  IP4CONFIG_FORM_ENTRY    *ConfigFormEntry;\r
+\r
+  CurrentIndex    = 0;\r
+  ConfigFormEntry = NULL;\r
+\r
+  NET_LIST_FOR_EACH (Entry, &mIp4ConfigFormList) {\r
+    if (CurrentIndex == Index) {\r
+      ConfigFormEntry = NET_LIST_USER_STRUCT (Entry, IP4CONFIG_FORM_ENTRY, Link);\r
+      break;\r
+    }\r
+\r
+    CurrentIndex++;\r
+  }\r
+\r
+  return ConfigFormEntry;\r
+}\r
+\r
+/**\r
+  This function allows the caller to request the current\r
+  configuration for one or more named elements. The resulting\r
+  string is in <ConfigAltResp> format. Any and all alternative\r
+  configuration strings shall also be appended to the end of the\r
+  current configuration string. If they are, they must appear\r
+  after the current configuration. They must contain the same\r
+  routing (GUID, NAME, PATH) as the current configuration string.\r
+  They must have an additional description indicating the type of\r
+  alternative configuration the string represents,\r
+  "ALTCFG=<StringToken>". That <StringToken> (when\r
+  converted from Hex UNICODE to binary) is a reference to a\r
+  string in the associated string pack.\r
+\r
+  @param[in] This       Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+  @param[in] Request    A null-terminated Unicode string in\r
+                        <ConfigRequest> format. Note that this\r
+                        includes the routing information as well as\r
+                        the configurable name / value pairs. It is\r
+                        invalid for this string to be in\r
+                        <MultiConfigRequest> format.\r
+  @param[out] Progress  On return, points to a character in the\r
+                        Request string. Points to the string's null\r
+                        terminator if request was successful. Points\r
+                        to the most recent "&" before the first\r
+                        failing name / value pair (or the beginning\r
+                        of the string if the failure is in the first\r
+                        name / value pair) if the request was not\r
+                        successful.\r
+  @param[out] Results   A null-terminated Unicode string in\r
+                        <ConfigAltResp> format which has all values\r
+                        filled in for the names in the Request string.\r
+                        String to be allocated by the called function.\r
+\r
+  @retval EFI_SUCCESS             The Results string is filled with the\r
+                                  values corresponding to all requested\r
+                                  names.\r
+  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the\r
+                                  parts of the results that must be\r
+                                  stored awaiting possible future\r
+                                  protocols.\r
+  @retval EFI_INVALID_PARAMETER   For example, passing in a NULL\r
+                                  for the Request parameter\r
+                                  would result in this type of\r
+                                  error. In this case, the\r
+                                  Progress parameter would be\r
+                                  set to NULL.\r
+  @retval EFI_NOT_FOUND           Routing data doesn't match any\r
+                                  known driver. Progress set to the\r
+                                  first character in the routing header.\r
+                                  Note: There is no requirement that the\r
+                                  driver validate the routing data. It\r
+                                  must skip the <ConfigHdr> in order to\r
+                                  process the names.\r
+  @retval EFI_INVALID_PARAMETER   Illegal syntax. Progress set\r
+                                  to most recent & before the\r
+                                  error or the beginning of the\r
+                                  string.\r
+  @retval EFI_INVALID_PARAMETER   Unknown name. Progress points\r
+                                  to the & before the name in\r
+                                  question.Currently not implemented.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Ip4DeviceExtractConfig (\r
+  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
+  IN  CONST EFI_STRING                       Request,\r
+  OUT EFI_STRING                             *Progress,\r
+  OUT EFI_STRING                             *Results\r
+  )\r
+{\r
+  EFI_STATUS                       Status;\r
+  UINTN                            ConfigLen;\r
+  NIC_IP4_CONFIG_INFO              *IfrDeviceNvData;\r
+  IP4_FORM_CALLBACK_INFO           *Private;\r
+  EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;\r
+  IP4_CONFIG_INSTANCE              *Ip4ConfigInstance;\r
+\r
+  if (Request == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *Progress = Request;\r
+\r
+  Private = IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
+  Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO (Private);\r
+\r
+  IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
+  if (IfrDeviceNvData == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance, &ConfigLen, IfrDeviceNvData);\r
+  if (EFI_ERROR (Status)) {\r
+    FreePool (IfrDeviceNvData);\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  //\r
+  // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
+  //\r
+  HiiConfigRouting = Private->ConfigRouting;\r
+  Status = HiiConfigRouting->BlockToConfig (\r
+                               HiiConfigRouting,\r
+                               Request,\r
+                               (UINT8 *) IfrDeviceNvData,\r
+                               NIC_ITEM_CONFIG_SIZE,\r
+                               Results,\r
+                               Progress\r
+                               );\r
+\r
+  *Progress = Request + StrLen (Request);\r
+  FreePool (IfrDeviceNvData);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  This function applies changes in a driver's configuration.\r
+  Input is a Configuration, which has the routing data for this\r
+  driver followed by name / value configuration pairs. The driver\r
+  must apply those pairs to its configurable storage. If the\r
+  driver's configuration is stored in a linear block of data\r
+  and the driver's name / value pairs are in <BlockConfig>\r
+  format, it may use the ConfigToBlock helper function (above) to\r
+  simplify the job. Currently not implemented.\r
+\r
+  @param[in]  This           Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+  @param[in]  Configuration  A null-terminated Unicode string in\r
+                             <ConfigString> format.\r
+  @param[out] Progress       A pointer to a string filled in with the\r
+                             offset of the most recent '&' before the\r
+                             first failing name / value pair (or the\r
+                             beginn ing of the string if the failure\r
+                             is in the first name / value pair) or\r
+                             the terminating NULL if all was\r
+                             successful.\r
+\r
+  @retval EFI_SUCCESS             The results have been distributed or are\r
+                                  awaiting distribution.\r
+  @retval EFI_OUT_OF_MEMORY       Not enough memory to store the\r
+                                  parts of the results that must be\r
+                                  stored awaiting possible future\r
+                                  protocols.\r
+  @retval EFI_INVALID_PARAMETERS  Passing in a NULL for the\r
+                                  Results parameter would result\r
+                                  in this type of error.\r
+  @retval EFI_NOT_FOUND           Target for the specified routing data\r
+                                  was not found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Ip4DeviceRouteConfig (\r
+  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
+  IN  CONST EFI_STRING                       Configuration,\r
+  OUT EFI_STRING                             *Progress\r
+  )\r
+{\r
+  EFI_STATUS                       Status;\r
+  UINTN                            BufferSize;\r
+  NIC_IP4_CONFIG_INFO              *IfrDeviceNvData;\r
+  IP4_FORM_CALLBACK_INFO           *Private;\r
+  EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;\r
+  IP4_CONFIG_INSTANCE              *Ip4ConfigInstance;\r
+  EFI_MAC_ADDRESS                  ZeroMac;\r
+\r
+  if (Configuration == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *Progress = Configuration;\r
+\r
+  Private = IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
+  Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO (Private);\r
+\r
+  IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
+  if (IfrDeviceNvData == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
+  //\r
+  HiiConfigRouting = Private->ConfigRouting;\r
+  BufferSize = NIC_ITEM_CONFIG_SIZE;\r
+  Status = HiiConfigRouting->ConfigToBlock (\r
+                               HiiConfigRouting,\r
+                               Configuration,\r
+                               (UINT8 *) IfrDeviceNvData,\r
+                               &BufferSize,\r
+                               Progress\r
+                               );\r
+  if (!EFI_ERROR (Status)) {\r
+    ZeroMem (&ZeroMac, sizeof (EFI_MAC_ADDRESS));\r
+    if (CompareMem (&IfrDeviceNvData->NicAddr.MacAddr, &ZeroMac, IfrDeviceNvData->NicAddr.Len) != 0) {\r
+      Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, IfrDeviceNvData, TRUE);\r
+    } else {\r
+      Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NULL, TRUE);\r
+    }\r
+  }\r
+\r
+  *Progress = Configuration + StrLen (Configuration);\r
+  FreePool (IfrDeviceNvData);\r
+  return Status;\r
+\r
+}\r
+\r
+/**\r
+  This function allows the caller to request the current\r
+  configuration for one or more named elements. The resulting\r
+  string is in <ConfigAltResp> format. Any and all alternative\r
+  configuration strings shall also be appended to the end of the\r
+  current configuration string. If they are, they must appear\r
+  after the current configuration. They must contain the same\r
+  routing (GUID, NAME, PATH) as the current configuration string.\r
+  They must have an additional description indicating the type of\r
+  alternative configuration the string represents,\r
+  "ALTCFG=<StringToken>". That <StringToken> (when\r
+  converted from Hex UNICODE to binary) is a reference to a\r
+  string in the associated string pack.\r
+\r
+  @param[in] This       Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+  @param[in] Request    A null-terminated Unicode string in\r
+                        <ConfigRequest> format. Note that this\r
+                        includes the routing information as well as\r
+                        the configurable name / value pairs. It is\r
+                        invalid for this string to be in\r
+                        <MultiConfigRequest> format.\r
+  @param[out] Progress  On return, points to a character in the\r
+                        Request string. Points to the string's null\r
+                        terminator if request was successful. Points\r
+                        to the most recent "&" before the first\r
+                        failing name / value pair (or the beginning\r
+                        of the string if the failure is in the first\r
+                        name / value pair) if the request was not\r
+                        successful.\r
+  @param[out] Results   A null-terminated Unicode string in\r
+                        <ConfigAltResp> format which has all values\r
+                        filled in for the names in the Request string.\r
+                        String to be allocated by the called function.\r
+\r
+  @retval EFI_SUCCESS             The Results string is filled with the\r
+                                  values corresponding to all requested\r
+                                  names.\r
+  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the\r
+                                  parts of the results that must be\r
+                                  stored awaiting possible future\r
+                                  protocols.\r
+  @retval EFI_INVALID_PARAMETER   For example, passing in a NULL\r
+                                  for the Request parameter\r
+                                  would result in this type of\r
+                                  error. In this case, the\r
+                                  Progress parameter would be\r
+                                  set to NULL.\r
+  @retval EFI_NOT_FOUND           Routing data doesn't match any\r
+                                  known driver. Progress set to the\r
+                                  first character in the routing header.\r
+                                  Note: There is no requirement that the\r
+                                  driver validate the routing data. It\r
+                                  must skip the <ConfigHdr> in order to\r
+                                  process the names.\r
+  @retval EFI_INVALID_PARAMETER   Illegal syntax. Progress set\r
+                                  to most recent & before the\r
+                                  error or the beginning of the\r
+                                  string.\r
+  @retval EFI_INVALID_PARAMETER   Unknown name. Progress points\r
+                                  to the & before the name in\r
+                                  question.Currently not implemented.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Ip4FormExtractConfig (\r
+  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
+  IN  CONST EFI_STRING                       Request,\r
+  OUT EFI_STRING                             *Progress,\r
+  OUT EFI_STRING                             *Results\r
+  )\r
+{\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  This function applies changes in a driver's configuration.\r
+  Input is a Configuration, which has the routing data for this\r
+  driver followed by name / value configuration pairs. The driver\r
+  must apply those pairs to its configurable storage. If the\r
+  driver's configuration is stored in a linear block of data\r
+  and the driver's name / value pairs are in <BlockConfig>\r
+  format, it may use the ConfigToBlock helper function (above) to\r
+  simplify the job. Currently not implemented.\r
+\r
+  @param[in]  This           Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+  @param[in]  Configuration  A null-terminated Unicode string in\r
+                             <ConfigString> format.\r
+  @param[out] Progress       A pointer to a string filled in with the\r
+                             offset of the most recent '&' before the\r
+                             first failing name / value pair (or the\r
+                             beginn ing of the string if the failure\r
+                             is in the first name / value pair) or\r
+                             the terminating NULL if all was\r
+                             successful.\r
+\r
+  @retval EFI_SUCCESS             The results have been distributed or are\r
+                                  awaiting distribution.\r
+  @retval EFI_OUT_OF_MEMORY       Not enough memory to store the\r
+                                  parts of the results that must be\r
+                                  stored awaiting possible future\r
+                                  protocols.\r
+  @retval EFI_INVALID_PARAMETERS  Passing in a NULL for the\r
+                                  Results parameter would result\r
+                                  in this type of error.\r
+  @retval EFI_NOT_FOUND           Target for the specified routing data\r
+                                  was not found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Ip4FormRouteConfig (\r
+  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
+  IN  CONST EFI_STRING                       Configuration,\r
+  OUT EFI_STRING                             *Progress\r
+  )\r
+{\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  This function is called to provide results data to the driver.\r
+  This data consists of a unique key that is used to identify\r
+  which data is either being passed back or being asked for.\r
+\r
+  @param[in]  This               Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+  @param[in]  Action             Specifies the type of action taken by the browser.\r
+  @param[in]  QuestionId         A unique value which is sent to the original\r
+                                 exporting driver so that it can identify the type\r
+                                 of data to expect. The format of the data tends to\r
+                                 vary based on the opcode that enerated the callback.\r
+  @param[in]  Type               The type of value for the question.\r
+  @param[in]  Value              A pointer to the data being sent to the original\r
+                                 exporting driver.\r
+  @param[out]  ActionRequest     On return, points to the action requested by the\r
+                                 callback function.\r
+\r
+  @retval EFI_SUCCESS            The callback successfully handled the action.\r
+  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the\r
+                                 variable and its data.\r
+  @retval EFI_DEVICE_ERROR       The variable could not be saved.\r
+  @retval EFI_UNSUPPORTED        The specified Action is not supported by the\r
+                                 callback.Currently not implemented.\r
+  @retval EFI_INVALID_PARAMETERS Passing in wrong parameter.\r
+  @retval Others                 Other errors as indicated.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Ip4FormCallback (\r
+  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
+  IN  EFI_BROWSER_ACTION                     Action,\r
+  IN  EFI_QUESTION_ID                        QuestionId,\r
+  IN  UINT8                                  Type,\r
+  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
+  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
+  )\r
+{\r
+  IP4_CONFIG_INSTANCE       *Ip4ConfigInstance;\r
+  IP4_FORM_CALLBACK_INFO    *Private;\r
+  CHAR8                     Ip4String[IP4_STR_MAX_SIZE];\r
+  CHAR16                    PortString[128];\r
+  EFI_STRING_ID             DeviceFormTitleToken;\r
+  IP4_CONFIG_IFR_NVDATA     *IfrFormNvData;\r
+  IP4CONFIG_FORM_ENTRY      *ConfigFormEntry;\r
+  EFI_IP_ADDRESS            HostIp;\r
+  EFI_IP_ADDRESS            SubnetMask;\r
+  EFI_IP_ADDRESS            Gateway;\r
+  EFI_STATUS                Status;\r
+  EFI_INPUT_KEY             Key;\r
+  NIC_IP4_CONFIG_INFO       *NicInfo;\r
+  EFI_IP_ADDRESS            Ip;\r
+\r
+  ConfigFormEntry = NULL;\r
+\r
+  Private   = IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
+\r
+  IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG_IFR_NVDATA));\r
+  if (IfrFormNvData == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Retrive uncommitted data from Browser\r
+  //\r
+  if (!HiiGetBrowserData (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, sizeof (IP4_CONFIG_IFR_NVDATA), (UINT8 *) IfrFormNvData)) {\r
+    FreePool (IfrFormNvData);\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  Status = EFI_SUCCESS;\r
+\r
+  switch (QuestionId) {\r
+\r
+  case KEY_DHCP_ENABLE:\r
+    if (IfrFormNvData->DhcpEnable == 0) {\r
+      Private->Current->SessionConfigData.Enabled = FALSE;\r
+    } else {\r
+      Private->Current->SessionConfigData.Enabled = TRUE;\r
+    }\r
+\r
+    break;\r
+\r
+  case KEY_LOCAL_IP:\r
+    UnicodeStrToAsciiStr (IfrFormNvData->StationAddress, Ip4String);\r
+    Status = Ip4AsciiStrToIp (Ip4String, &HostIp.v4);\r
+    if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
+      Status = EFI_INVALID_PARAMETER;\r
+    } else {\r
+      CopyMem (&Private->Current->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4));\r
+    }\r
+\r
+    break;\r
+\r
+  case KEY_SUBNET_MASK:\r
+    UnicodeStrToAsciiStr (IfrFormNvData->SubnetMask, Ip4String);\r
+    Status = Ip4AsciiStrToIp (Ip4String, &SubnetMask.v4);\r
+    if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (GetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) {\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid SubnetMask!", NULL);\r
+      Status = EFI_INVALID_PARAMETER;\r
+    } else {\r
+      CopyMem (&Private->Current->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));\r
+    }\r
+\r
+    break;\r
+\r
+  case KEY_GATE_WAY:\r
+    UnicodeStrToAsciiStr (IfrFormNvData->GatewayAddress, Ip4String);\r
+    Status = Ip4AsciiStrToIp (Ip4String, &Gateway.v4);\r
+    if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !Ip4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\r
+      CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);\r
+      Status = EFI_INVALID_PARAMETER;\r
+    } else {\r
+      CopyMem (&Private->Current->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4));\r
+    }\r
+\r
+    break;\r
+\r
+  case KEY_SAVE_CHANGES:\r
+    Ip4ConfigInstance = Private->Current->Ip4ConfigInstance;\r
+    NicInfo = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO) + 2 * sizeof (EFI_IP4_ROUTE_TABLE));\r
+    NicInfo->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (NicInfo + 1);\r
+\r
+    if (!Private->Current->SessionConfigData.Enabled) {\r
+      CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.LocalIp, sizeof (HostIp.v4));\r
+      CopyMem (&SubnetMask.v4, &Private->Current->SessionConfigData.SubnetMask, sizeof (SubnetMask.v4));\r
+      CopyMem (&Gateway.v4, &Private->Current->SessionConfigData.Gateway, sizeof (Gateway.v4));\r
+\r
+      if ((Gateway.Addr[0] != 0)) {\r
+        if (SubnetMask.Addr[0] == 0) {\r
+          CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Gateway address is set but subnet mask is zero.", NULL);\r
+          Status = EFI_INVALID_PARAMETER;\r
+          break;\r
+        } else if (!IP4_NET_EQUAL (HostIp.Addr[0], Gateway.Addr[0], SubnetMask.Addr[0])) {\r
+          CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Local IP and Gateway are not in the same subnet.", NULL);\r
+          Status = EFI_INVALID_PARAMETER;\r
+          break;\r
+        }\r
+      }\r
+\r
+      NicInfo->Source = IP4_CONFIG_SOURCE_STATIC;\r
+      NicInfo->Ip4Info.RouteTableSize = 2;\r
+\r
+      CopyMem (&NicInfo->Ip4Info.StationAddress, &HostIp.v4, sizeof (EFI_IPv4_ADDRESS));\r
+      CopyMem (&NicInfo->Ip4Info.SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS));\r
+\r
+      Ip.Addr[0] = HostIp.Addr[0] & SubnetMask.Addr[0];\r
+\r
+      CopyMem (&NicInfo->Ip4Info.RouteTable[0].SubnetAddress, &Ip.v4, sizeof (EFI_IPv4_ADDRESS));\r
+      CopyMem (&NicInfo->Ip4Info.RouteTable[0].SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS));\r
+      CopyMem (&NicInfo->Ip4Info.RouteTable[1].GatewayAddress, &Gateway.v4, sizeof (EFI_IPv4_ADDRESS));\r
+    } else {\r
+      NicInfo->Source = IP4_CONFIG_SOURCE_DHCP;\r
+    }\r
+\r
+    NicInfo->Perment = TRUE;\r
+    CopyMem (&NicInfo->NicAddr, &Ip4ConfigInstance->NicAddr, sizeof (NIC_ADDR));\r
+\r
+    EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE);\r
+\r
+    *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
+    break;\r
+\r
+  default:\r
+    if ((QuestionId >= KEY_DEVICE_ENTRY_BASE) && (QuestionId < (mNumberOfIp4Devices + KEY_DEVICE_ENTRY_BASE))) {\r
+      //\r
+      // In case goto the device configuration form, update the device form title.\r
+      //\r
+      ConfigFormEntry = Ip4GetConfigFormEntryByIndex ((UINT32) (QuestionId - KEY_DEVICE_ENTRY_BASE));\r
+      ASSERT (ConfigFormEntry != NULL);\r
+\r
+      Ip4ConfigInstance = ConfigFormEntry->Ip4ConfigInstance;\r
+\r
+      UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);\r
+      DeviceFormTitleToken = (EFI_STRING_ID) STR_IP4_DEVICE_FORM_TITLE;\r
+      HiiSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString, NULL);\r
+\r
+      Ip4ConfigConvertDeviceConfigDataToIfrNvData (Ip4ConfigInstance, IfrFormNvData);\r
+\r
+      Private->Current = ConfigFormEntry;\r
+    }\r
+\r
+    break;\r
+  }\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+\r
+    //\r
+    // Pass changed uncommitted data back to Form Browser\r
+    //\r
+    HiiSetBrowserData (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, sizeof (IP4_CONFIG_IFR_NVDATA), (UINT8 *) IfrFormNvData, NULL);\r
+  }\r
+\r
+  FreePool (IfrFormNvData);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Install HII Config Access protocol for network device and allocate resource.\r
+\r
+  @param[in]  Instance            The IP4 Config instance.\r
+\r
+  @retval EFI_SUCCESS              The HII Config Access protocol is installed.\r
+  @retval EFI_OUT_OF_RESOURCES     Failed to allocate memory.\r
+  @retval Others                   Other errors as indicated.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigDeviceInit (\r
+    IN IP4_CONFIG_INSTANCE              *Instance\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_HII_DATABASE_PROTOCOL   *HiiDatabase;\r
+  IP4_FORM_CALLBACK_INFO      *CallbackInfo;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&HiiDatabase);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  CallbackInfo = &Instance->Ip4FormCallbackInfo;\r
+\r
+  CallbackInfo->Signature   = IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE;\r
+  CallbackInfo->HiiDatabase = HiiDatabase;\r
+\r
+  CallbackInfo->ConfigAccess.ExtractConfig = Ip4DeviceExtractConfig;\r
+  CallbackInfo->ConfigAccess.RouteConfig = Ip4DeviceRouteConfig;\r
+  CallbackInfo->ConfigAccess.Callback = NULL;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **)&CallbackInfo->ConfigRouting);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  CallbackInfo->DriverHandle = Instance->Controller;\r
+  //\r
+  // Install Device Path Protocol and Config Access protocol to driver handle\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &CallbackInfo->DriverHandle,\r
+                  &gEfiHiiConfigAccessProtocolGuid,\r
+                  &CallbackInfo->ConfigAccess,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Uninstall HII Config Access protocol for network device and free resource.\r
+\r
+  @param[in]  Instance            The IP4 Config instance.\r
+\r
+  @retval EFI_SUCCESS             The HII Config Access protocol is uninstalled.\r
+  @retval Others                  Other errors as indicated.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigDeviceUnload (\r
+  IN IP4_CONFIG_INSTANCE              *Instance\r
+  )\r
+{\r
+  IP4_FORM_CALLBACK_INFO      *CallbackInfo;\r
+\r
+  CallbackInfo = &Instance->Ip4FormCallbackInfo;\r
+\r
+  Ip4ConfigUpdateForm (Instance, FALSE);\r
+\r
+  //\r
+  // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL\r
+  //\r
+  gBS->UninstallMultipleProtocolInterfaces (\r
+         CallbackInfo->DriverHandle,\r
+         &gEfiHiiConfigAccessProtocolGuid,\r
+         &CallbackInfo->ConfigAccess,\r
+         NULL\r
+         );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Unload the network configuration form, this includes: delete all the network\r
+  device configuration entries, uninstall the form callback protocol and\r
+  free the resources used.\r
+\r
+  @retval EFI_SUCCESS             The network configuration form is unloaded.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigFormUnload (\r
+  VOID\r
+  )\r
+{\r
+  IP4CONFIG_FORM_ENTRY     *ConfigFormEntry;\r
+\r
+  while (!IsListEmpty (&mIp4ConfigFormList)) {\r
+    //\r
+    // Uninstall the device forms as the network driver instance may fail to\r
+    // control the controller but still install the device configuration form.\r
+    // In such case, upon driver unloading, the driver instance's driverbinding.\r
+    // stop () won't be called, so we have to take this chance here to uninstall\r
+    // the device form.\r
+    //\r
+    ConfigFormEntry = NET_LIST_USER_STRUCT (mIp4ConfigFormList.ForwardLink, IP4CONFIG_FORM_ENTRY, Link);\r
+    Ip4ConfigUpdateForm (ConfigFormEntry->Ip4ConfigInstance, FALSE);\r
+  }\r
+\r
+  //\r
+  // Remove HII package list\r
+  //\r
+  mCallbackInfo->HiiDatabase->RemovePackageList (\r
+                                mCallbackInfo->HiiDatabase,\r
+                                mCallbackInfo->RegisteredHandle\r
+                                );\r
+\r
+  //\r
+  // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL\r
+  //\r
+  gBS->UninstallMultipleProtocolInterfaces (\r
+         mCallbackInfo->DriverHandle,\r
+         &gEfiDevicePathProtocolGuid,\r
+         &mIp4ConifgHiiVendorDevicePath,\r
+         &gEfiHiiConfigAccessProtocolGuid,\r
+         &mCallbackInfo->ConfigAccess,\r
+         NULL\r
+         );\r
+\r
+  FreePool (mCallbackInfo);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Updates the network configuration form to add/delete an entry for the network\r
+  device specified by the Instance.\r
+\r
+  @param[in]  Instance            The IP4 Config instance.\r
+  @param[in]  AddForm             Whether to add or delete a form entry.\r
+\r
+  @retval EFI_SUCCESS             The network configuration form is updated.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
+  @retval Others                  Other errors as indicated.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigUpdateForm (\r
+  IN IP4_CONFIG_INSTANCE              *Instance,\r
+  IN BOOLEAN                          AddForm\r
+  )\r
+{\r
+  LIST_ENTRY                  *Entry;\r
+  IP4CONFIG_FORM_ENTRY        *ConfigFormEntry;\r
+  BOOLEAN                     EntryExisted;\r
+  EFI_STATUS                  Status;\r
+  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+  CHAR16                      PortString[128];\r
+  UINT16                      FormIndex;\r
+  VOID                        *StartOpCodeHandle;\r
+  VOID                        *EndOpCodeHandle;\r
+  EFI_IFR_GUID_LABEL          *StartLabel;\r
+  EFI_IFR_GUID_LABEL          *EndLabel;\r
+\r
+  ConfigFormEntry = NULL;\r
+  EntryExisted    = FALSE;\r
+\r
+  NET_LIST_FOR_EACH (Entry, &mIp4ConfigFormList) {\r
+    ConfigFormEntry = NET_LIST_USER_STRUCT (Entry, IP4CONFIG_FORM_ENTRY, Link);\r
+\r
+    if (ConfigFormEntry->Controller == Instance->Controller) {\r
+      EntryExisted = TRUE;\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (AddForm) {\r
+    if (EntryExisted) {\r
+      return EFI_SUCCESS;\r
+    } else {\r
+      //\r
+      // Add a new form.\r
+      //\r
+      ConfigFormEntry = (IP4CONFIG_FORM_ENTRY *) AllocateZeroPool (sizeof (IP4CONFIG_FORM_ENTRY));\r
+      if (ConfigFormEntry == NULL) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      ConfigFormEntry->Ip4ConfigInstance = Instance;\r
+      InitializeListHead (&ConfigFormEntry->Link);\r
+      ConfigFormEntry->Controller = Instance->Controller;\r
+\r
+      //\r
+      // Get the simple network protocol and convert the MAC address into\r
+      // the formatted string.\r
+      //\r
+      Status = gBS->HandleProtocol (\r
+                      Instance->Controller,\r
+                      &gEfiSimpleNetworkProtocolGuid,\r
+                      (VOID **)&Snp\r
+                      );\r
+      ASSERT (Status == EFI_SUCCESS);\r
+\r
+      Ip4MacAddrToStr (&Snp->Mode->PermanentAddress, Snp->Mode->HwAddressSize, ConfigFormEntry->MacString);\r
+\r
+      //\r
+      // Compose the Port string and create a new EFI_STRING_ID.\r
+      //\r
+      UnicodeSPrint (PortString, 128, L"%s %s", Instance->NicName, ConfigFormEntry->MacString);\r
+      ConfigFormEntry->PortTitleToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);\r
+\r
+      //\r
+      // Compose the help string of this port and create a new EFI_STRING_ID.\r
+      //\r
+      UnicodeSPrint (PortString, 128, L"Set the network parameters on eth%d %s", 0, ConfigFormEntry->MacString);\r
+      ConfigFormEntry->PortTitleHelpToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);\r
+\r
+      InsertTailList (&mIp4ConfigFormList, &ConfigFormEntry->Link);\r
+      mNumberOfIp4Devices++;\r
+    }\r
+  } else {\r
+    ASSERT (EntryExisted);\r
+\r
+    mNumberOfIp4Devices--;\r
+    RemoveEntryList (&ConfigFormEntry->Link);\r
+    gBS->FreePool (ConfigFormEntry);\r
+  }\r
+\r
+  //\r
+  // Init OpCode Handle\r
+  //\r
+  StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (StartOpCodeHandle != NULL);\r
+\r
+  EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  ASSERT (EndOpCodeHandle != NULL);\r
+\r
+  //\r
+  // Create Hii Extend Label OpCode as the start opcode\r
+  //\r
+  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  StartLabel->Number       = DEVICE_ENTRY_LABEL;\r
+\r
+  //\r
+  // Create Hii Extend Label OpCode as the end opcode\r
+  //\r
+  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
+  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
+  EndLabel->Number       = LABEL_END;\r
+\r
+  FormIndex = 0;\r
+\r
+  FormIndex = 0;\r
+  NET_LIST_FOR_EACH (Entry, &mIp4ConfigFormList) {\r
+    ConfigFormEntry = NET_LIST_USER_STRUCT (Entry, IP4CONFIG_FORM_ENTRY, Link);\r
+\r
+    HiiCreateGotoOpCode (\r
+      StartOpCodeHandle,                            // Container for dynamic created opcodes\r
+      FORMID_DEVICE_FORM,                           // Target Form ID\r
+      ConfigFormEntry->PortTitleToken,              // Prompt text\r
+      ConfigFormEntry->PortTitleHelpToken,          // Help text\r
+      EFI_IFR_FLAG_CALLBACK,                        // Question flag\r
+      (UINT16)(KEY_DEVICE_ENTRY_BASE + FormIndex)   // Question ID\r
+      );\r
+\r
+    FormIndex++;\r
+  }\r
+\r
+  HiiUpdateForm (\r
+    mCallbackInfo->RegisteredHandle,\r
+    &gEfiNicIp4ConfigVariableGuid,\r
+    FORMID_MAIN_FORM,\r
+    StartOpCodeHandle, // Label DEVICE_ENTRY_LABEL\r
+    EndOpCodeHandle    // LABEL_END\r
+    );\r
+\r
+  HiiFreeOpCodeHandle (StartOpCodeHandle);\r
+  HiiFreeOpCodeHandle (EndOpCodeHandle);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Initialize the network configuration form, this includes: delete all the network\r
+  device configuration entries, install the form callback protocol and\r
+  allocate the resources used.\r
+\r
+  @retval EFI_SUCCESS             The network configuration form is unloaded.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigFormInit (\r
+    VOID\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_HII_DATABASE_PROTOCOL   *HiiDatabase;\r
+  IP4_FORM_CALLBACK_INFO      *CallbackInfo;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&HiiDatabase);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  CallbackInfo = (IP4_FORM_CALLBACK_INFO *) AllocateZeroPool (sizeof (IP4_FORM_CALLBACK_INFO));\r
+  if (CallbackInfo == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  CallbackInfo->Signature   = IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE;\r
+  CallbackInfo->HiiDatabase = HiiDatabase;\r
+\r
+  CallbackInfo->ConfigAccess.ExtractConfig = Ip4FormExtractConfig;\r
+  CallbackInfo->ConfigAccess.RouteConfig = Ip4FormRouteConfig;\r
+  CallbackInfo->ConfigAccess.Callback = Ip4FormCallback;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **)&CallbackInfo->ConfigRouting);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  CallbackInfo->DriverHandle = NULL;\r
+  //\r
+  // Install Device Path Protocol and Config Access protocol to driver handle\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &CallbackInfo->DriverHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  &mIp4ConifgHiiVendorDevicePath,\r
+                  &gEfiHiiConfigAccessProtocolGuid,\r
+                  &CallbackInfo->ConfigAccess,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Publish our HII data\r
+  //\r
+  CallbackInfo->RegisteredHandle = HiiAddPackages (\r
+                                     &gEfiNicIp4ConfigVariableGuid,\r
+                                     CallbackInfo->DriverHandle,\r
+                                     Ip4ConfigDxeStrings,\r
+                                     Ip4ConfigDxeBin,\r
+                                     NULL\r
+                                     );\r
+  if (CallbackInfo->RegisteredHandle == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  mCallbackInfo = CallbackInfo;\r
+\r
+  return Status;\r
+}\r
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.h
new file mode 100644 (file)
index 0000000..2eb8b91
--- /dev/null
@@ -0,0 +1,104 @@
+/** @file\r
+  The header file of IP4ConfigNV.c\r
+\r
+Copyright (c) 2009, 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
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _IP4_CONFIGNV_H_\r
+#define _IP4_CONFIGNV_H_\r
+\r
+#include "Ip4Config.h"\r
+#include "Ip4NVData.h"\r
+\r
+extern UINT8  Ip4ConfigDxeBin[];\r
+extern UINT8  Ip4ConfigDxeStrings[];\r
+\r
+#define NIC_ITEM_CONFIG_SIZE   sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 2\r
+\r
+\r
+///\r
+/// HII specific Vendor Device Path definition.\r
+///\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH             VendorDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL       End;\r
+} HII_VENDOR_DEVICE_PATH;\r
+\r
+/**\r
+  Updates the network configuration form to add/delete an entry for the network\r
+  device specified by the Instance.\r
+\r
+  @param[in]  Instance            The IP4 Config instance.\r
+  @param[in]  AddForm             Whether to add or delete a form entry.\r
+\r
+  @retval EFI_SUCCESS             The network configuration form is updated.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
+  @retval Others                  Other errors as indicated.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigUpdateForm (\r
+  IN IP4_CONFIG_INSTANCE                   *Instance,\r
+  IN BOOLEAN     AddForm\r
+  );\r
+\r
+/**\r
+  Install HII Config Access protocol for network device and allocate resource.\r
+\r
+  @param[in]  Instance            The IP4 Config instance.\r
+\r
+  @retval EFI_SUCCESS              The HII Config Access protocol is installed.\r
+  @retval EFI_OUT_OF_RESOURCES     Failed to allocate memory.\r
+  @retval Others                   Other errors as indicated.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigDeviceInit (\r
+    IN IP4_CONFIG_INSTANCE                   *Instance\r
+  );\r
+\r
+/**\r
+  Uninstall HII Config Access protocol for network device and free resource.\r
+\r
+  @param[in]  Instance            The IP4 Config instance.\r
+\r
+  @retval EFI_SUCCESS             The HII Config Access protocol is uninstalled.\r
+  @retval Others                  Other errors as indicated.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigDeviceUnload (\r
+    IN IP4_CONFIG_INSTANCE                   *Instance\r
+  );\r
+\r
+/**\r
+  Initialize the network configuration form, this includes: delete all the network\r
+  device configuration entries, install the form callback protocol and\r
+  allocate the resources used.\r
+\r
+  @retval EFI_SUCCESS             The network configuration form is unloaded.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigFormInit (\r
+    VOID\r
+  );\r
+\r
+/**\r
+  Unload the network configuration form, this includes: delete all the network\r
+  device configuration entries, uninstall the form callback protocol and\r
+  free the resources used.\r
+\r
+  @retval EFI_SUCCESS             The network configuration form is unloaded.\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigFormUnload (\r
+  VOID\r
+  );\r
+\r
+#endif\r
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4NvData.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4NvData.h
new file mode 100644 (file)
index 0000000..ac2b3dc
--- /dev/null
@@ -0,0 +1,59 @@
+/** @file\r
+  Routines used to operate the Ip4 configure variable.\r
+\r
+Copyright (c) 2009, 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<BR>\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _NIC_IP4_NV_DATA_H_\r
+#define _NIC_IP4_NV_DATA_H_\r
+\r
+\r
+//\r
+// one copy from NicIp4ConfigNvData.h\r
+//\r
+#define EFI_NIC_IP4_CONFIG_VARIABLE_GUID \\r
+  { \\r
+    0xd8944553, 0xc4dd, 0x41f4, { 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b } \\r
+  }\r
+\r
+#define FORMID_MAIN_FORM    1\r
+#define FORMID_DEVICE_FORM  2\r
+\r
+#define KEY_DHCP_ENABLE           0x101\r
+#define KEY_LOCAL_IP              0x102\r
+#define KEY_SUBNET_MASK           0x103\r
+#define KEY_GATE_WAY              0x104\r
+#define KEY_SAVE_CHANGES          0x105\r
+\r
+#define DEVICE_ENTRY_LABEL        0x1234\r
+#define LABEL_END                 0xffff\r
+\r
+#define KEY_DEVICE_ENTRY_BASE     0x1000\r
+\r
+#define IP_MIN_SIZE               7\r
+#define IP_MAX_SIZE               15\r
+#define IP4_STR_MAX_SIZE          16\r
+\r
+///\r
+/// NIC_IP4_CONFIG_INFO contains the IP4 configure\r
+/// parameters for that NIC. NIC_IP4_CONFIG_INFO is\r
+/// of variable length.\r
+///\r
+typedef struct {\r
+  UINT16          NicAddr[3];         ///< NIC MAC address\r
+  UINT8           Reserved;           ///< Reserved bits\r
+  UINT8           DhcpEnable;         ///< Static or DHCP\r
+  CHAR16          StationAddress[IP4_STR_MAX_SIZE];  ///< IP addresses\r
+  CHAR16          SubnetMask[IP4_STR_MAX_SIZE];      ///< Subnet address\r
+  CHAR16          GatewayAddress[IP4_STR_MAX_SIZE];  ///< Gateway address\r
+} IP4_CONFIG_IFR_NVDATA;\r
+\r
+#endif\r
index 11ba50c149e4ecd4e13c1485e6b29f8561955663..6a4e94193e983bf72a1f94697018c0d53cc5be23 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Routines used to operate the Ip4 configure variable.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation.<BR>                                                         \r
+Copyright (c) 2006 - 2009, 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<BR>\r
@@ -17,6 +17,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Uefi.h>\r
 \r
+#include <Guid/NicIp4ConfigNvData.h>\r
+\r
 #include <Library/NetLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
@@ -24,8 +26,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 \r
-#include <Protocol/NicIp4Config.h>\r
-\r
+///\r
+/// IP4_CONFIG_VARIABLE is the EFI variable to\r
+/// save the configuration. IP4_CONFIG_VARIABLE is\r
+/// of variable length.\r
+///\r
+typedef struct {\r
+  UINT32                    Len;        ///< Total length of the variable\r
+  UINT16                    CheckSum;   ///< CheckSum, the same as IP4 head checksum\r
+  UINT32                    Count;      ///< Number of NIC_IP4_CONFIG_INFO follows\r
+  NIC_IP4_CONFIG_INFO       ConfigInfo;\r
+} IP4_CONFIG_VARIABLE;\r
 \r
 //\r
 // Return the size of NIC_IP4_CONFIG_INFO and EFI_IP4_IPCONFIG_DATA.\r
@@ -143,3 +154,4 @@ Ip4ConfigFixRouteTablePointer (
   );\r
 \r
 #endif\r
+\r