]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Fix the issue cannot boot to UEFI Network after reset
authorZhang Lubo <lubo.zhang@intel.com>
Wed, 29 Jul 2015 06:37:48 +0000 (06:37 +0000)
committerluobozhang <luobozhang@Edk2>
Wed, 29 Jul 2015 06:37:48 +0000 (06:37 +0000)
DHCP4 service allows only one of its children to be configured
in the active state,If the DHCP4 D.O.R.A started by IP4 auto
configuration and has not been completed, the Dhcp4 state machine
will not be in the right state for the PXE to start a new round
D.O.R.A., so we need to switch it's policy to static.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18107 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf

index 1293f672686bd474c2a945d41711f5259a657035..6c0637300447979ff5689dbbec1593e64b7d9de8 100644 (file)
@@ -2,7 +2,7 @@
   Support for PxeBc dhcp functions.\r
 \r
 Copyright (c) 2013, Red Hat, Inc.\r
   Support for PxeBc dhcp functions.\r
 \r
 Copyright (c) 2013, Red Hat, Inc.\r
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 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
@@ -647,6 +647,53 @@ PxeBcCacheDhcpOffer (
   Private->NumOffers++;\r
 }\r
 \r
   Private->NumOffers++;\r
 }\r
 \r
+/**\r
+  Switch the Ip4 policy to static.\r
+\r
+  @param[in]  Private             The pointer to PXEBC_PRIVATE_DATA.\r
+\r
+  @retval     EFI_SUCCESS         The policy is already configured to static.\r
+  @retval     Others              Other error as indicated..\r
+\r
+**/\r
+EFI_STATUS\r
+PxeBcSetIp4Policy (   \r
+  IN PXEBC_PRIVATE_DATA            *Private\r
+  )\r
+{\r
+  EFI_STATUS                   Status;\r
+  EFI_IP4_CONFIG2_PROTOCOL     *Ip4Config2;\r
+  EFI_IP4_CONFIG2_POLICY       Policy;\r
+  UINTN                        DataSize;\r
+\r
+  Ip4Config2 = Private->Ip4Config2;\r
+  DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);\r
+  Status = Ip4Config2->GetData (\r
+                       Ip4Config2,\r
+                       Ip4Config2DataTypePolicy,\r
+                       &DataSize,\r
+                       &Policy\r
+                       );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  \r
+  if (Policy != Ip4Config2PolicyStatic) {\r
+    Policy = Ip4Config2PolicyStatic;\r
+    Status= Ip4Config2->SetData (\r
+                          Ip4Config2,\r
+                          Ip4Config2DataTypePolicy,\r
+                          sizeof (EFI_IP4_CONFIG2_POLICY),\r
+                          &Policy\r
+                          );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    } \r
+  }\r
+\r
+  return  EFI_SUCCESS;\r
+}\r
+\r
 \r
 /**\r
   Select the specified proxy offer, such as BINL, DHCP_ONLY and so on.\r
 \r
 /**\r
   Select the specified proxy offer, such as BINL, DHCP_ONLY and so on.\r
index b56d10d82a1021a540f388d4b08c98c963ed5eca..1626060ee2d87a59074b24332f315d9b91413287 100644 (file)
@@ -2,7 +2,7 @@
   Dhcp and Discover routines for PxeBc.\r
 \r
 Copyright (c) 2013, Red Hat, Inc.\r
   Dhcp and Discover routines for PxeBc.\r
 \r
 Copyright (c) 2013, Red Hat, Inc.\r
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 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
@@ -380,6 +380,19 @@ PxeBcDhcpCallBack (
   OUT EFI_DHCP4_PACKET                 **NewPacket OPTIONAL\r
   );\r
 \r
   OUT EFI_DHCP4_PACKET                 **NewPacket OPTIONAL\r
   );\r
 \r
+/**\r
+  Switch the Ip4 policy to static.\r
+\r
+  @param[in]  Private             The pointer to PXEBC_PRIVATE_DATA.\r
+\r
+  @retval     EFI_SUCCESS         The policy is already configured to static.\r
+  @retval     Others              Other error as indicated..\r
+\r
+**/\r
+EFI_STATUS\r
+PxeBcSetIp4Policy (   \r
+  IN PXEBC_PRIVATE_DATA            *Private\r
+  );\r
 \r
 /**\r
   Discover the boot of service and initialize the vendor option if exists.\r
 \r
 /**\r
   Discover the boot of service and initialize the vendor option if exists.\r
index 3c2437ef5cd022df93c3051faf2638238c174ae8..76c140d8e3ff39e4b1d9ecdc6601fc11cc5e5028 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding for UEFI PXEBC protocol.\r
 \r
 /** @file\r
   The driver binding for UEFI PXEBC protocol.\r
 \r
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 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
@@ -375,6 +375,17 @@ PxeBcDriverBindingStart (
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
+  //\r
+  // Locate Ip4->Ip4Config2 and store it for set IPv4 Policy.\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiIp4Config2ProtocolGuid,\r
+                  (VOID **) &Private->Ip4Config2\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
 \r
   return EFI_SUCCESS;\r
 \r
 \r
   return EFI_SUCCESS;\r
 \r
index 0c54f46516ac8134ddd37e1ad10bd0b5a63e9840..4dd7944e6a9a94abda5031ff7c067c6ba057a96a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Interface routines for PxeBc.\r
 \r
 /** @file\r
   Interface routines for PxeBc.\r
 \r
-Copyright (c) 2007 - 2013, 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 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
@@ -410,6 +410,18 @@ EfiPxeBcStart (
     goto ON_EXIT;\r
   }\r
 \r
     goto ON_EXIT;\r
   }\r
 \r
+  //\r
+  //DHCP4 service allows only one of its children to be configured in  \r
+  //the active state, If the DHCP4 D.O.R.A started by IP4 auto  \r
+  //configuration and has not been completed, the Dhcp4 state machine \r
+  //will not be in the right state for the PXE to start a new round D.O.R.A. \r
+  //so we need to switch it's policy to static.\r
+  //\r
+  Status = PxeBcSetIp4Policy (Private);\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_EXIT;\r
+  }\r
+    \r
   Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4ConfigData);\r
   if (EFI_ERROR (Status)) {\r
     goto ON_EXIT;\r
   Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4ConfigData);\r
   if (EFI_ERROR (Status)) {\r
     goto ON_EXIT;\r
index 97703cb5f9c83617746301be40331827f6fdd171..6e88deae47f3584a4e09778bac9174a80ef25848 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
 /** @file\r
 \r
-Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 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
@@ -30,6 +30,7 @@ typedef struct _PXEBC_PRIVATE_DATA  PXEBC_PRIVATE_DATA;
 #include <Protocol/PxeBaseCodeCallBack.h>\r
 #include <Protocol/Arp.h>\r
 #include <Protocol/Ip4.h>\r
 #include <Protocol/PxeBaseCodeCallBack.h>\r
 #include <Protocol/Arp.h>\r
 #include <Protocol/Ip4.h>\r
+#include <Protocol/Ip4Config2.h>\r
 \r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 \r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
@@ -75,6 +76,7 @@ struct _PXEBC_PRIVATE_DATA {
   EFI_ARP_PROTOCOL                          *Arp;\r
   EFI_DHCP4_PROTOCOL                        *Dhcp4;\r
   EFI_IP4_PROTOCOL                          *Ip4;\r
   EFI_ARP_PROTOCOL                          *Arp;\r
   EFI_DHCP4_PROTOCOL                        *Dhcp4;\r
   EFI_IP4_PROTOCOL                          *Ip4;\r
+  EFI_IP4_CONFIG2_PROTOCOL                  *Ip4Config2;\r
   EFI_IP4_CONFIG_DATA                       Ip4ConfigData;\r
   EFI_MTFTP4_PROTOCOL                       *Mtftp4;\r
   EFI_UDP4_PROTOCOL                         *Udp4Read;\r
   EFI_IP4_CONFIG_DATA                       Ip4ConfigData;\r
   EFI_MTFTP4_PROTOCOL                       *Mtftp4;\r
   EFI_UDP4_PROTOCOL                         *Udp4Read;\r
index a1265637c3ee321e04549844117a0241f062f77f..fe8f210467a582bf432ae31d7b2385c7331fc6ab 100644 (file)
@@ -6,7 +6,7 @@
 #  Protocol to provide one clean way to otain control from the boot manager if the\r
 #  boot patch is from the remote device.\r
 #\r
 #  Protocol to provide one clean way to otain control from the boot manager if the\r
 #  boot patch is from the remote device.\r
 #\r
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution. The full text of the license may be found at\r
 #  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
@@ -84,6 +84,7 @@
   gEfiDhcp4ProtocolGuid                            ## TO_START\r
   gEfiIp4ServiceBindingProtocolGuid                ## TO_START\r
   gEfiIp4ProtocolGuid                              ## TO_START\r
   gEfiDhcp4ProtocolGuid                            ## TO_START\r
   gEfiIp4ServiceBindingProtocolGuid                ## TO_START\r
   gEfiIp4ProtocolGuid                              ## TO_START\r
+  gEfiIp4Config2ProtocolGuid                       ## TO_START\r
 \r
 [Pcd]  \r
   gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize  ## SOMETIMES_CONSUMES  \r
 \r
 [Pcd]  \r
   gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize  ## SOMETIMES_CONSUMES  \r