The patch looks good. I also tested this patch on my system to boot a large 
size HTTP image (.iso), and it works well. Thanks for quickly working out the 
permanent fix.

Reviewed-by: Sunny Wang <[email protected]>

Regards,
Sunny Wang

-----Original Message-----
From: Ruiyu Ni [mailto:[email protected]] 
Sent: Tuesday, July 05, 2016 5:47 PM
To: [email protected]
Cc: Wang, Sunny (HPS SW) <[email protected]>; Star Zeng <[email protected]>
Subject: [PATCH] MdeModulePkg/Bds: MemoryTypeInformation excludes boot option 
mem use

The patch re-orders the sequences by putting updating memory type information 
before loading the boot option so that the reserved memory usage by HTTP RAM 
disk boot can be excluded by the memory type information updating.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <[email protected]>
Cc: Sunny Wang <[email protected]>
Cc: Star Zeng <[email protected]>
---
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 41 +++++++++-------------
 MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c   | 13 +------
 .../Library/UefiBootManagerLib/InternalBm.h        |  5 +--
 3 files changed, 19 insertions(+), 40 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 4da401d..bb38f00 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1569,7 +1569,6 @@ EfiBootManagerBoot (
   UINTN                     FileSize;
   EFI_BOOT_LOGO_PROTOCOL    *BootLogo;
   EFI_EVENT                 LegacyBootEvent;
-  UINTN                     RamDiskSizeInPages;
 
   if (BootOption == NULL) {
     return;
@@ -1643,8 +1642,24 @@ EfiBootManagerBoot (
   PERF_START_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber);
 
   //
-  // 5. Load EFI boot option to ImageHandle
+  // 5. Adjust the different type memory page number just before booting
+  //    and save the updated info into the variable for next boot to use
+  //
+  BmSetMemoryTypeInformationVariable (
+    (BOOLEAN) ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == 
+ LOAD_OPTION_CATEGORY_BOOT)  );
+
   //
+  // 6. Load EFI boot option to ImageHandle  //  DEBUG_CODE_BEGIN ();  
+ if (BootOption->Description == NULL) {
+    DEBUG ((DEBUG_INFO | DEBUG_LOAD, "[Bds]Booting from unknown device 
+ path\n"));  } else {
+    DEBUG ((DEBUG_INFO | DEBUG_LOAD, "[Bds]Booting %s\n", 
+ BootOption->Description));  }  DEBUG_CODE_END ();
+
   ImageHandle       = NULL;
   RamDiskDevicePath = NULL;
   if (DevicePathType (BootOption->FilePath) != BBS_DEVICE_PATH) { @@ -1701,28 
+1716,6 @@ EfiBootManagerBoot (
   }
 
   //
-  // 6. Adjust the different type memory page number just before booting
-  //    and save the updated info into the variable for next boot to use
-  //
-  if (RamDiskDevicePath == NULL) {
-    RamDiskSizeInPages = 0;
-  } else {
-    BmGetRamDiskMemoryInfo (RamDiskDevicePath, &RamDiskSizeInPages);
-  }
-  BmSetMemoryTypeInformationVariable (
-    (BOOLEAN) ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == 
LOAD_OPTION_CATEGORY_BOOT),
-    RamDiskSizeInPages
-    );
-
-  DEBUG_CODE_BEGIN();
-    if (BootOption->Description == NULL) {
-      DEBUG ((DEBUG_INFO | DEBUG_LOAD, "[Bds]Booting from unknown device 
path\n"));
-    } else {
-      DEBUG ((DEBUG_INFO | DEBUG_LOAD, "[Bds]Booting %s\n", 
BootOption->Description));
-    }
-  DEBUG_CODE_END();
-
-  //
   // Check to see if we should legacy BOOT. If yes then do the legacy boot
   // Write boot to OS performance data for Legacy boot
   //
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 93502fe..2a60f06 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -130,13 +130,10 @@ BmMatchDevicePaths (
 
   @param Boot               TRUE if current boot option belongs to boot
                             category instead of application category.
-  @param RamDiskSizeInPages Reserved memory size in pages occupied by
-                            RAM Disk.
 **/
 VOID
 BmSetMemoryTypeInformationVariable (
-  IN BOOLEAN                    Boot,
-  IN UINTN                      RamDiskSizeInPages
+  IN BOOLEAN                    Boot
   )
 {
   EFI_STATUS                   Status;
@@ -230,14 +227,6 @@ BmSetMemoryTypeInformationVariable (
     }
 
     //
-    // Do not count the reserved memory occupied by RAM Disk.
-    //
-    if ((CurrentMemoryTypeInformation[Index1].Type == EfiReservedMemoryType) &&
-        (CurrentMemoryTypeInformation[Index1].NumberOfPages > ((UINT32) 
RamDiskSizeInPages))) {
-      CurrentMemoryTypeInformation[Index1].NumberOfPages -= (UINT32) 
RamDiskSizeInPages;
-    }
-
-    //
     // Previous is the number of pages pre-allocated
     // Current is the number of pages actually needed
     //
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h 
b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
index e1c5a96..07ee45b 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
+++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
@@ -207,13 +207,10 @@ BmWriteBootToOsPerformanceData (
 
   @param Boot               TRUE if current boot option belongs to boot
                             category instead of application category.
-  @param RamDiskSizeInPages Reserved memory size in pages occupied by
-                            RAM Disk.
 **/
 VOID
 BmSetMemoryTypeInformationVariable (
-  IN BOOLEAN                    Boot,
-  IN UINTN                      RamDiskSizeInPages
+  IN BOOLEAN                    Boot
   );
 
 /**
--
2.8.3.windows.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to