]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Mem/Page.c
Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / Page.c
index 9ec83141ac50a3dc608eafe2301b8de1f0298a85..2bf457267a99b8e338a7cb5491811f5596eeb15c 100644 (file)
@@ -1,15 +1,14 @@
 /** @file\r
-\r
   UEFI Memory page management functions.\r
 \r
-Copyright (c) 2007 - 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
+Copyright (c) 2007 - 2008, 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
@@ -47,8 +46,8 @@ UINTN         mFreeMapStack = 0;
 //\r
 // This list maintain the free memory map list\r
 //\r
-LIST_ENTRY   mFreeMemoryMapEntryList  = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemoryMapEntryList);\r
-BOOLEAN mMemoryTypeInformationInitialized = FALSE;\r
+LIST_ENTRY   mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemoryMapEntryList);\r
+BOOLEAN      mMemoryTypeInformationInitialized = FALSE;\r
 \r
 EFI_MEMORY_TYPE_STAISTICS mMemoryTypeStatistics[EfiMaxMemoryType + 1] = {\r
   { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE,  FALSE },  // EfiReservedMemoryType\r
@@ -95,8 +94,7 @@ EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = {
   Find untested but initialized memory regions in GCD map and convert them to be DXE allocatable.\r
 \r
 **/\r
-STATIC\r
-VOID \r
+VOID\r
 PromoteMemoryResource (\r
   VOID\r
   );\r
@@ -112,10 +110,7 @@ PromoteMemoryResource (
                                  byte of a page \r
   @param  Attribute              The attributes of the memory range to add \r
 \r
-  @return None.  The range is added to the memory map\r
-\r
 **/\r
-STATIC\r
 VOID\r
 CoreAddRange (\r
   IN EFI_MEMORY_TYPE          Type,\r
@@ -129,7 +124,6 @@ CoreAddRange (
   temporary descriptor stack to heap.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 CoreFreeMemoryMapStack (\r
   VOID\r
@@ -151,7 +145,6 @@ CoreFreeMemoryMapStack (
                                  specified type.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 CoreConvertPages (\r
   IN UINT64           Start,\r
@@ -165,7 +158,6 @@ CoreConvertPages (
   @param  Entry                  The entry to remove\r
 \r
 **/\r
-STATIC\r
 VOID\r
 RemoveMemoryMapEntry (\r
   MEMORY_MAP      *Entry\r
@@ -184,7 +176,6 @@ RemoveMemoryMapEntry (
   @return The Memory map descriptor dequed from the mFreeMemoryMapEntryList\r
 \r
 **/\r
-STATIC\r
 MEMORY_MAP *\r
 AllocateMemoryMapEntry (\r
   VOID\r
@@ -222,7 +213,6 @@ CoreReleaseMemoryLock (
   Find untested but initialized memory regions in GCD map and convert them to be DXE allocatable.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 PromoteMemoryResource (\r
   VOID\r
@@ -449,7 +439,6 @@ CoreAddMemoryDescriptor (
   @return None.  The range is added to the memory map\r
 \r
 **/\r
-STATIC\r
 VOID\r
 CoreAddRange (\r
   IN EFI_MEMORY_TYPE          Type,\r
@@ -542,7 +531,6 @@ CoreAddRange (
   temporary descriptor stack to heap.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 CoreFreeMemoryMapStack (\r
   VOID\r
@@ -557,7 +545,7 @@ CoreFreeMemoryMapStack (
   //\r
   // If already freeing the map stack, then return\r
   //\r
-  if (mFreeMapStack) {\r
+  if (mFreeMapStack != 0) {\r
     return ;\r
   }\r
 \r
@@ -566,7 +554,7 @@ CoreFreeMemoryMapStack (
   //\r
   mFreeMapStack += 1;\r
 \r
-  while (mMapDepth) {\r
+  while (mMapDepth != 0) {\r
     //\r
     // Deque an memory map entry from mFreeMemoryMapEntryList \r
     //\r
@@ -621,10 +609,9 @@ CoreFreeMemoryMapStack (
   @param  Entry                  The entry to remove\r
 \r
 **/\r
-STATIC\r
 VOID\r
 RemoveMemoryMapEntry (\r
-  MEMORY_MAP      *Entry\r
+  IN OUT MEMORY_MAP      *Entry\r
   )\r
 {\r
   RemoveEntryList (&Entry->Link);\r
@@ -652,7 +639,6 @@ RemoveMemoryMapEntry (
   @return The Memory map descriptor dequed from the mFreeMemoryMapEntryList\r
 \r
 **/\r
-STATIC\r
 MEMORY_MAP *\r
 AllocateMemoryMapEntry (\r
   VOID\r
@@ -705,7 +691,6 @@ AllocateMemoryMapEntry (
                                  specified type.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 CoreConvertPages (\r
   IN UINT64           Start,\r
@@ -730,7 +715,7 @@ CoreConvertPages (
   ASSERT (End > Start) ;\r
   ASSERT_LOCKED (&gMemoryLock);\r
 \r
-  if (NumberOfPages == 0 || (Start & EFI_PAGE_MASK ) || (Start > (Start + NumberOfBytes))) {\r
+  if (NumberOfPages == 0 || ((Start & EFI_PAGE_MASK) != 0) || (Start > (Start + NumberOfBytes))) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -898,7 +883,6 @@ CoreConvertPages (
   @return The base address of the range, or 0 if the range was not found\r
 \r
 **/\r
-STATIC\r
 UINT64\r
 CoreFindFreePagesI (\r
   IN UINT64           MaxAddress,\r
@@ -1019,7 +1003,6 @@ CoreFindFreePagesI (
   @return The base address of the range, or 0 if the range was not found.\r
 \r
 **/\r
-STATIC\r
 UINT64\r
 FindFreePages (\r
     IN UINT64           MaxAddress,\r
@@ -1042,9 +1025,9 @@ FindFreePages (
   }\r
 \r
   Start = CoreFindFreePagesI (NewMaxAddress, NoPages, NewType, Alignment);\r
-  if (!Start) {\r
+  if (Start == 0) {\r
     Start = CoreFindFreePagesI (MaxAddress, NoPages, NewType, Alignment);\r
-    if (!Start) {\r
+    if (Start == 0) {\r
       //\r
       // Here means there may be no enough memory to use, so try to go through\r
       // all the memory descript to promote the untested memory directly\r
@@ -1166,9 +1149,6 @@ Done:
 }\r
 \r
 \r
-\r
-\r
-\r
 /**\r
   Frees previous allocated pages.\r
 \r
@@ -1250,8 +1230,6 @@ CoreFreePages (
 }\r
 \r
 \r
-\r
-\r
 /**\r
   This function returns a copy of the current memory map. The map is an array of\r
   memory descriptors, each of which describes a contiguous block of memory.\r
@@ -1388,7 +1366,7 @@ CoreGetMemoryMap (
         if (mMemoryTypeStatistics[Type].Special                        &&\r
             mMemoryTypeStatistics[Type].NumberOfPages > 0              &&\r
             Entry->Start >= mMemoryTypeStatistics[Type].BaseAddress    &&\r
-            Entry->End   <= mMemoryTypeStatistics[Type].MaximumAddress    ) {\r
+            Entry->End   <= mMemoryTypeStatistics[Type].MaximumAddress) {\r
           MemoryMap->Type = Type;\r
         }\r
       }\r
@@ -1482,7 +1460,7 @@ CoreAllocatePoolPages (
     CoreConvertPages (Start, NumberOfPages, PoolType);\r
   }\r
 \r
-  return (VOID *)(UINTN)Start;\r
+  return (VOID *)(UINTN) Start;\r
 }\r
 \r
 \r