ArmPkg/ArmLib/AArch64: Use the appropriate macros and update comments

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14506 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Olivier Martin 2013-07-26 17:10:51 +00:00 committed by oliviermartin
parent 863986b3c8
commit 6ea162c214
1 changed files with 8 additions and 6 deletions

View File

@ -301,8 +301,10 @@ GetBlockEntryListFromAddress (
// Identify the Page Level the RegionStart must belongs to // Identify the Page Level the RegionStart must belongs to
PageLevel = 3 - ((BaseAddressAlignment - 12) / 9); PageLevel = 3 - ((BaseAddressAlignment - 12) / 9);
// If the required size is smaller than the current block size then we need to go to the page bellow. // If the required size is smaller than the current block size then we need to go to the page below.
if (*BlockEntrySize < TT_ADDRESS_AT_LEVEL(PageLevel)) { // The PageLevel was calculated on the Base Address alignment but did not take in account the alignment
// of the allocation size
if (*BlockEntrySize < TT_BLOCK_ENTRY_SIZE_AT_LEVEL (PageLevel)) {
// It does not fit so we need to go a page level above // It does not fit so we need to go a page level above
PageLevel++; PageLevel++;
} }
@ -311,7 +313,7 @@ GetBlockEntryListFromAddress (
*TableLevel = PageLevel; *TableLevel = PageLevel;
// Now, we have the Table Level we can get the Block Size associated to this table // Now, we have the Table Level we can get the Block Size associated to this table
*BlockEntrySize = TT_ADDRESS_AT_LEVEL(PageLevel); *BlockEntrySize = TT_BLOCK_ENTRY_SIZE_AT_LEVEL (PageLevel);
// //
// Get the Table Descriptor for the corresponding PageLevel. We need to decompose RegionStart to get appropriate entries // Get the Table Descriptor for the corresponding PageLevel. We need to decompose RegionStart to get appropriate entries
@ -357,8 +359,8 @@ GetBlockEntryListFromAddress (
// Shift back to right to set zero before the effective address // Shift back to right to set zero before the effective address
BlockEntryAddress = BlockEntryAddress << TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel); BlockEntryAddress = BlockEntryAddress << TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel);
// Set the correct entry type // Set the correct entry type for the next page level
if (IndexLevel + 1 == 3) { if ((IndexLevel + 1) == 3) {
Attributes |= TT_TYPE_BLOCK_ENTRY_LEVEL3; Attributes |= TT_TYPE_BLOCK_ENTRY_LEVEL3;
} else { } else {
Attributes |= TT_TYPE_BLOCK_ENTRY; Attributes |= TT_TYPE_BLOCK_ENTRY;
@ -371,7 +373,7 @@ GetBlockEntryListFromAddress (
} }
TranslationTable = (UINT64*)((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE); TranslationTable = (UINT64*)((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE);
// Fill the new BlockEntry with the TranslationTable // Fill the BlockEntry with the new TranslationTable
*BlockEntry = ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) | TableAttributes | TT_TYPE_TABLE_ENTRY; *BlockEntry = ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) | TableAttributes | TT_TYPE_TABLE_ENTRY;
// Update the last block entry with the newly created translation table // Update the last block entry with the newly created translation table
*LastBlockEntry = (UINT64*)((UINTN)TranslationTable + ((TT_ENTRY_COUNT - 1) * sizeof(UINT64))); *LastBlockEntry = (UINT64*)((UINTN)TranslationTable + ((TT_ENTRY_COUNT - 1) * sizeof(UINT64)));