]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Mem/Page.c
Avoid DEBUG_CLEAR_MEMORY clearing MemoryMap internal structure.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / Page.c
index 2a99507c585bcb9786d7df641397ebd6a3f47465..9a78698df9aa8c82511b1a5100f365cb6a4e680a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Memory page management functions.\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -533,7 +533,7 @@ CoreAddMemoryDescriptor (
   //\r
   // If Loading Module At Fixed Address feature is enabled. try to allocate memory with Runtime code & Boot time code type\r
   //\r
-  if (FixedPcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {\r
+  if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {\r
     CoreLoadingFixedAddressHook();\r
   }\r
   \r
@@ -829,6 +829,9 @@ CoreConvertPages (
     // Add our new range in\r
     //\r
     CoreAddRange (NewType, Start, RangeEnd, Attribute);\r
+    if (NewType == EfiConventionalMemory) {\r
+      DEBUG_CLEAR_MEMORY ((VOID *)(UINTN)Start, RangeEnd - Start + 1);\r
+    }\r
 \r
     //\r
     // Move any map descriptor stack to general pool\r
@@ -1168,8 +1171,8 @@ CoreFreePages (
     }\r
   }\r
   if (Link == &gMemoryMap) {\r
-    CoreReleaseMemoryLock ();\r
-    return EFI_NOT_FOUND;\r
+    Status = EFI_NOT_FOUND;\r
+    goto Done;\r
   }\r
 \r
   Alignment = EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT;\r
@@ -1185,8 +1188,8 @@ CoreFreePages (
   }\r
 \r
   if ((Memory & (Alignment - 1)) != 0) {\r
-    CoreReleaseMemoryLock ();\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   }\r
 \r
   NumberOfPages += EFI_SIZE_TO_PAGES (Alignment) - 1;\r
@@ -1194,19 +1197,12 @@ CoreFreePages (
 \r
   Status = CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);\r
 \r
-  CoreReleaseMemoryLock ();\r
-\r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Destroy the contents\r
-  //\r
-  if (Memory < MAX_ADDRESS) {\r
-    DEBUG_CLEAR_MEMORY ((VOID *)(UINTN)Memory, NumberOfPages << EFI_PAGE_SHIFT);\r
+    goto Done;\r
   }\r
 \r
+Done:\r
+  CoreReleaseMemoryLock ();\r
   return Status;\r
 }\r
 \r