]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmLib: Introduced TT_LAST_BLOCK_ADDRESS()
authorOlivier Martin <olivier.martin@arm.com>
Mon, 19 Aug 2013 17:36:16 +0000 (17:36 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 19 Aug 2013 17:36:16 +0000 (17:36 +0000)
This macro return the address of the last entry of a translation table.

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@14565 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Include/Chipset/AArch64Mmu.h
ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

index 0799734a19d1bf046910ed32401bfebc82a15f30..17c28fa205c35aa9129658bc51a73814ce117066 100644 (file)
@@ -43,6 +43,9 @@
 // The first offset starts at 12bit. There are 4 levels of 9-bit address range from level 3 to level 0\r
 #define TT_ADDRESS_AT_LEVEL(TableLevel)       (1 << TT_ADDRESS_OFFSET_AT_LEVEL(TableLevel))\r
 \r
+#define TT_LAST_BLOCK_ADDRESS(TranslationTable, EntryCount) \\r
+    ((UINT64*)((EFI_PHYSICAL_ADDRESS)(TranslationTable) + (((EntryCount) - 1) * sizeof(UINT64))))\r
+\r
 // There are 512 entries per table when 4K Granularity\r
 #define TT_ENTRY_COUNT                          512\r
 #define TT_ALIGNMENT_BLOCK_ENTRY                BIT12\r
index ae22e86fa97a4634f4a6d1176d128c7e1bb136bb..bca397dcff1003558d7ec2f322a4d7cd2e453e78 100644 (file)
@@ -279,7 +279,7 @@ GetBlockEntryListFromAddress (
   // Get the Table info from T0SZ\r
   GetRootTranslationTableInfo (T0SZ, &RootTableLevel, &RootTableEntryCount);\r
   // The last block of the root table depends on the number of entry in this table\r
-  *LastBlockEntry = (UINT64*)((UINTN)RootTable + ((RootTableEntryCount - 1) * sizeof(UINT64)));\r
+  *LastBlockEntry = TT_LAST_BLOCK_ADDRESS(RootTable, RootTableEntryCount);\r
 \r
   // If the start address is 0x0 then we use the size of the region to identify the alignment\r
   if (RegionStart == 0) {\r
@@ -333,7 +333,7 @@ GetBlockEntryListFromAddress (
         BlockEntry = (UINT64*)TT_GET_ENTRY_FOR_ADDRESS (TranslationTable, IndexLevel + 1, RegionStart);\r
 \r
         // Set the last block for this new table\r
-        *LastBlockEntry = (UINT64*)((UINTN)TranslationTable + ((TT_ENTRY_COUNT - 1) * sizeof(UINT64)));\r
+        *LastBlockEntry = TT_LAST_BLOCK_ADDRESS(TranslationTable, TT_ENTRY_COUNT);\r
       }\r
     } else if ((*BlockEntry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY) {\r
       // If we are not at the last level then we need to split this BlockEntry\r
@@ -376,7 +376,7 @@ GetBlockEntryListFromAddress (
         // 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
+        *LastBlockEntry = TT_LAST_BLOCK_ADDRESS(TranslationTable, TT_ENTRY_COUNT);\r
 \r
         // Populate the newly created lower level table\r
         BlockEntry = TranslationTable;\r