From: Olivier Martin Date: Fri, 26 Jul 2013 17:10:51 +0000 (+0000) Subject: ArmPkg/ArmLib/AArch64: Use the appropriate macros and update comments X-Git-Tag: edk2-stable201903~12400 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=6ea162c214c5cc71027ff9e01b02113c449ee04d ArmPkg/ArmLib/AArch64: Use the appropriate macros and update comments Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14506 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c index 05b2a197d5..2fdfee163a 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c @@ -301,8 +301,10 @@ GetBlockEntryListFromAddress ( // Identify the Page Level the RegionStart must belongs to 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 (*BlockEntrySize < TT_ADDRESS_AT_LEVEL(PageLevel)) { + // If the required size is smaller than the current block size then we need to go to the page below. + // 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 PageLevel++; } @@ -311,7 +313,7 @@ GetBlockEntryListFromAddress ( *TableLevel = PageLevel; // 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 @@ -357,8 +359,8 @@ GetBlockEntryListFromAddress ( // Shift back to right to set zero before the effective address BlockEntryAddress = BlockEntryAddress << TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel); - // Set the correct entry type - if (IndexLevel + 1 == 3) { + // Set the correct entry type for the next page level + if ((IndexLevel + 1) == 3) { Attributes |= TT_TYPE_BLOCK_ENTRY_LEVEL3; } else { Attributes |= TT_TYPE_BLOCK_ENTRY; @@ -371,7 +373,7 @@ GetBlockEntryListFromAddress ( } 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; // Update the last block entry with the newly created translation table *LastBlockEntry = (UINT64*)((UINTN)TranslationTable + ((TT_ENTRY_COUNT - 1) * sizeof(UINT64)));