summaryrefslogtreecommitdiff
path: root/ArmPkg
diff options
context:
space:
mode:
authorOlivier Martin <olivier.martin@arm.com>2013-07-26 17:10:51 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-07-26 17:10:51 +0000
commit6ea162c214c5cc71027ff9e01b02113c449ee04d (patch)
tree894a25d88b8a8812a8847f5038537e7393343b55 /ArmPkg
parent863986b3c8e67736d361b68e293d01e6f92f825c (diff)
downloadedk2-platforms-6ea162c214c5cc71027ff9e01b02113c449ee04d.tar.xz
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
Diffstat (limited to 'ArmPkg')
-rw-r--r--ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c14
1 files changed, 8 insertions, 6 deletions
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)));