git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2131
6f19259b-4bc3-4df7-8a09-
765794883524
PAGE_MAP_AND_DIRECTORY_POINTER *PageMap;\r
PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;\r
PAGE_TABLE_ENTRY *PageDirectoryEntry;\r
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
\r
//\r
// Get physical address bits supported.\r
NumberOfPdpEntriesNeeded = 512;\r
}\r
\r
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
PageMapLevel4Entry = PageMap;\r
PageAddress = 0;\r
for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) {\r
// 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
// 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
\r
//\r
// Make a PML4 Entry\r
// 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
// 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
\r
//\r
// Fill in a Page Directory Pointer Entries\r