]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmLib/AArch64: Use the appropriate macros and update comments
authorOlivier Martin <olivier.martin@arm.com>
Fri, 26 Jul 2013 17:10:51 +0000 (17:10 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Jul 2013 17:10:51 +0000 (17:10 +0000)
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

ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

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