]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update PXE driver to support PXE forced mode.
authorFu Siyuan <siyuan.fu@intel.com>
Mon, 6 Jan 2014 02:08:05 +0000 (02:08 +0000)
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 6 Jan 2014 02:08:05 +0000 (02:08 +0000)
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Dong, Guo <guo.dong@intel.com>
Reviewed-by: Jin, Eric <eric.jin@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15047 6f19259b-4bc3-4df7-8a09-765794883524

NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c

index 5bbefcee9d4f075e21a4bf8f4c265ea6327ff649..84031e40e05f65c24a3c03855dd443a8a1004f98 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Boot functions implementation for UefiPxeBc Driver.\r
 \r
-  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -468,7 +468,9 @@ PxeBcDhcp4BootInfo (
   EFI_STATUS                  Status;\r
   PXEBC_DHCP4_PACKET_CACHE    *Cache4;\r
   UINT16                      Value;\r
-\r
+  PXEBC_VENDOR_OPTION         *VendorOpt;\r
+  PXEBC_BOOT_SVR_ENTRY        *Entry;\r
+  \r
   PxeBc       = &Private->PxeBc;\r
   Mode        = PxeBc->Mode;\r
   Status      = EFI_SUCCESS;\r
@@ -485,17 +487,40 @@ PxeBcDhcp4BootInfo (
     Cache4 = &Private->DhcpAck.Dhcp4;\r
   }\r
 \r
+  ASSERT (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);\r
+\r
   //\r
-  // Parse the boot server Ipv4 address by next server address.\r
-  // If this field isn't available, use option 54 instead.\r
+  // Parse the boot server address.\r
+  // If prompt/discover is disabled, get the first boot server from the boot servers list.\r
+  // Otherwise, parse the boot server Ipv4 address from next server address field in DHCP header.\r
+  // If all these fields are not available, use option 54 instead.\r
   //\r
-  CopyMem (\r
-    &Private->ServerIp,\r
-    &Cache4->Packet.Offer.Dhcp4.Header.ServerAddr,\r
-    sizeof (EFI_IPv4_ADDRESS)\r
-    );\r
-\r
+  VendorOpt = &Cache4->VendorOpt;\r
+  if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) && IS_VALID_BOOT_SERVERS (VendorOpt->BitMap)) {\r
+    Entry = VendorOpt->BootSvr;\r
+    if (VendorOpt->BootSvrLen >= sizeof (PXEBC_BOOT_SVR_ENTRY) && Entry->IpCnt > 0) {\r
+      CopyMem (\r
+        &Private->ServerIp,\r
+        &Entry->IpAddr[0],\r
+        sizeof (EFI_IPv4_ADDRESS)\r
+        );\r
+    }\r
+  }\r
+  if (Private->ServerIp.Addr[0] == 0) {\r
+    //\r
+    // ServerIp.Addr[0] equals zero means we failed to get IP address from boot server list.\r
+    // Try to use next server address field.\r
+    //\r
+    CopyMem (\r
+      &Private->ServerIp,\r
+      &Cache4->Packet.Offer.Dhcp4.Header.ServerAddr,\r
+      sizeof (EFI_IPv4_ADDRESS)\r
+      );\r
+  }\r
   if (Private->ServerIp.Addr[0] == 0) {\r
+    //\r
+    // Still failed , use the IP address from option 54.\r
+    //\r
     CopyMem (\r
       &Private->ServerIp,\r
       Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]->Data,\r
@@ -506,7 +531,6 @@ PxeBcDhcp4BootInfo (
   //\r
   // Parse the boot file name by option.\r
   //\r
-  ASSERT (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);\r
   Private->BootFileName = Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data;\r
 \r
   if (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN] != NULL) {\r