summaryrefslogtreecommitdiff
path: root/EdkModulePkg
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2006-12-22 08:11:47 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2006-12-22 08:11:47 +0000
commite2d56e0a59f2788df11d02c96433e908d9f414b4 (patch)
tree52813d600df3958b19d397f8c6118b5c355d99fc /EdkModulePkg
parent2c0bc1a2cc0376b4f322d06bf8959219a2b13e80 (diff)
downloadedk2-platforms-e2d56e0a59f2788df11d02c96433e908d9f414b4.tar.xz
Optimize to preallocate big bigs to avoid latter allocations.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2131 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg')
-rw-r--r--EdkModulePkg/Core/DxeIplPeim/Ia32/VirtualMemory.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/EdkModulePkg/Core/DxeIplPeim/Ia32/VirtualMemory.c b/EdkModulePkg/Core/DxeIplPeim/Ia32/VirtualMemory.c
index 78134564e5..609fea2eca 100644
--- a/EdkModulePkg/Core/DxeIplPeim/Ia32/VirtualMemory.c
+++ b/EdkModulePkg/Core/DxeIplPeim/Ia32/VirtualMemory.c
@@ -69,12 +69,8 @@ Returns:
PAGE_MAP_AND_DIRECTORY_POINTER *PageMap;
PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;
PAGE_TABLE_ENTRY *PageDirectoryEntry;
-
- //
- // By architecture only one PageMapLevel4 exists - so lets allocate storage for it.
- //
- PageMap = AllocatePages (1);
- ASSERT (PageMap != NULL);
+ UINTN TotalPagesNum;
+ UINTN BigPageAddress;
//
// Get physical address bits supported.
@@ -98,6 +94,19 @@ Returns:
NumberOfPdpEntriesNeeded = 512;
}
+ //
+ // Pre-allocate big pages to avoid later allocations.
+ //
+ TotalPagesNum = (NumberOfPdpEntriesNeeded + 1) * NumberOfPml4EntriesNeeded + 1;
+ BigPageAddress = (UINTN) AllocatePages (TotalPagesNum);
+ ASSERT (BigPageAddress != 0);
+
+ //
+ // By architecture only one PageMapLevel4 exists - so lets allocate storage for it.
+ //
+ PageMap = (VOID *) BigPageAddress;
+ BigPageAddress += EFI_PAGE_SIZE;
+
PageMapLevel4Entry = PageMap;
PageAddress = 0;
for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) {
@@ -105,8 +114,8 @@ Returns:
// Each PML4 entry points to a page of Page Directory Pointer entires.
// So lets allocate space for them and fill them in in the IndexOfPdpEntries loop.
//
- PageDirectoryPointerEntry = AllocatePages (1);
- ASSERT (PageDirectoryPointerEntry != NULL);
+ PageDirectoryPointerEntry = (VOID *) BigPageAddress;
+ BigPageAddress += EFI_PAGE_SIZE;
//
// Make a PML4 Entry
@@ -120,8 +129,8 @@ Returns:
// Each Directory Pointer entries points to a page of Page Directory entires.
// So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.
//
- PageDirectoryEntry = AllocatePages (1);
- ASSERT (PageDirectoryEntry != NULL);
+ PageDirectoryEntry = (VOID *) BigPageAddress;
+ BigPageAddress += EFI_PAGE_SIZE;
//
// Fill in a Page Directory Pointer Entries