mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-25 14:44:28 +02:00
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
This commit is contained in:
parent
2c0bc1a2cc
commit
e2d56e0a59
@ -69,12 +69,8 @@ Returns:
|
|||||||
PAGE_MAP_AND_DIRECTORY_POINTER *PageMap;
|
PAGE_MAP_AND_DIRECTORY_POINTER *PageMap;
|
||||||
PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;
|
PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;
|
||||||
PAGE_TABLE_ENTRY *PageDirectoryEntry;
|
PAGE_TABLE_ENTRY *PageDirectoryEntry;
|
||||||
|
UINTN TotalPagesNum;
|
||||||
//
|
UINTN BigPageAddress;
|
||||||
// By architecture only one PageMapLevel4 exists - so lets allocate storage for it.
|
|
||||||
//
|
|
||||||
PageMap = AllocatePages (1);
|
|
||||||
ASSERT (PageMap != NULL);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get physical address bits supported.
|
// Get physical address bits supported.
|
||||||
@ -98,6 +94,19 @@ Returns:
|
|||||||
NumberOfPdpEntriesNeeded = 512;
|
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;
|
PageMapLevel4Entry = PageMap;
|
||||||
PageAddress = 0;
|
PageAddress = 0;
|
||||||
for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) {
|
for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) {
|
||||||
@ -105,8 +114,8 @@ Returns:
|
|||||||
// Each PML4 entry points to a page of Page Directory Pointer entires.
|
// 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.
|
// So lets allocate space for them and fill them in in the IndexOfPdpEntries loop.
|
||||||
//
|
//
|
||||||
PageDirectoryPointerEntry = AllocatePages (1);
|
PageDirectoryPointerEntry = (VOID *) BigPageAddress;
|
||||||
ASSERT (PageDirectoryPointerEntry != NULL);
|
BigPageAddress += EFI_PAGE_SIZE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make a PML4 Entry
|
// Make a PML4 Entry
|
||||||
@ -120,8 +129,8 @@ Returns:
|
|||||||
// Each Directory Pointer entries points to a page of Page Directory entires.
|
// 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.
|
// So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.
|
||||||
//
|
//
|
||||||
PageDirectoryEntry = AllocatePages (1);
|
PageDirectoryEntry = (VOID *) BigPageAddress;
|
||||||
ASSERT (PageDirectoryEntry != NULL);
|
BigPageAddress += EFI_PAGE_SIZE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fill in a Page Directory Pointer Entries
|
// Fill in a Page Directory Pointer Entries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user