]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Optimize to preallocate big bigs to avoid latter allocations.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Dec 2006 08:11:47 +0000 (08:11 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Dec 2006 08:11:47 +0000 (08:11 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2131 6f19259b-4bc3-4df7-8a09-765794883524

EdkModulePkg/Core/DxeIplPeim/Ia32/VirtualMemory.c

index 78134564e5b49917f7834c4afa215c91331e4a54..609fea2eca629a4ebe0bd26fb64d39e22559b7dd 100644 (file)
@@ -69,12 +69,8 @@ Returns:
   PAGE_MAP_AND_DIRECTORY_POINTER                *PageMap;\r
   PAGE_MAP_AND_DIRECTORY_POINTER                *PageDirectoryPointerEntry;\r
   PAGE_TABLE_ENTRY                              *PageDirectoryEntry;\r
-\r
-  //\r
-  // By architecture only one PageMapLevel4 exists - so lets allocate storage for it.\r
-  //\r
-  PageMap = AllocatePages (1);\r
-  ASSERT (PageMap != NULL);\r
+  UINTN                                         TotalPagesNum;\r
+  UINTN                                         BigPageAddress;\r
 \r
   //\r
   // Get physical address bits supported.\r
@@ -98,6 +94,19 @@ Returns:
     NumberOfPdpEntriesNeeded = 512;\r
   }\r
 \r
+  //\r
+  // Pre-allocate big pages to avoid later allocations. \r
+  //\r
+  TotalPagesNum = (NumberOfPdpEntriesNeeded + 1) * NumberOfPml4EntriesNeeded + 1;\r
+  BigPageAddress = (UINTN) AllocatePages (TotalPagesNum);\r
+  ASSERT (BigPageAddress != 0);\r
+\r
+  //\r
+  // By architecture only one PageMapLevel4 exists - so lets allocate storage for it.\r
+  //\r
+  PageMap         = (VOID *) BigPageAddress;\r
+  BigPageAddress += EFI_PAGE_SIZE;\r
+\r
   PageMapLevel4Entry = PageMap;\r
   PageAddress        = 0;\r
   for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) {\r
@@ -105,8 +114,8 @@ Returns:
     // Each PML4 entry points to a page of Page Directory Pointer entires.\r
     // So lets allocate space for them and fill them in in the IndexOfPdpEntries loop.\r
     //\r
-    PageDirectoryPointerEntry = AllocatePages (1);\r
-    ASSERT (PageDirectoryPointerEntry != NULL);\r
+    PageDirectoryPointerEntry = (VOID *) BigPageAddress;\r
+    BigPageAddress += EFI_PAGE_SIZE;\r
 \r
     //\r
     // Make a PML4 Entry\r
@@ -120,8 +129,8 @@ Returns:
       // Each Directory Pointer entries points to a page of Page Directory entires.\r
       // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.\r
       //       \r
-      PageDirectoryEntry = AllocatePages (1);\r
-      ASSERT (PageDirectoryEntry != NULL);\r
+      PageDirectoryEntry = (VOID *) BigPageAddress;\r
+      BigPageAddress += EFI_PAGE_SIZE;\r
 \r
       //\r
       // Fill in a Page Directory Pointer Entries\r