]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
ArmPkg/ArmMmuLib: Reuse XIP MMU routines when splitting entries
[mirror_edk2.git] / ArmPkg / Library / ArmMmuLib / AArch64 / ArmMmuLibCore.c
index ae59e9a7d04e34ba2e328b8afb246e668aea5493..764c7d362e2e480ab6f9aec538dff43f2e7e1aff 100644 (file)
@@ -10,6 +10,7 @@
 **/\r
 \r
 #include <Uefi.h>\r
+#include <Pi/PiMultiPhase.h>\r
 #include <Chipset/AArch64.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/CacheMaintenanceLib.h>\r
@@ -120,14 +121,14 @@ ReplaceTableEntry (
     // use an ordinary break before make. Otherwise, we will need to\r
     // temporarily disable the MMU.\r
     DisableMmu = FALSE;\r
-    if ((((RegionStart ^ (UINTN)ArmReplaceLiveTranslationEntry) & ~BlockMask) == 0) ||\r
+    if ((((RegionStart ^ (UINTN)mReplaceLiveEntryFunc) & ~BlockMask) == 0) ||\r
         (((RegionStart ^ (UINTN)Entry) & ~BlockMask) == 0))\r
     {\r
       DisableMmu = TRUE;\r
       DEBUG ((DEBUG_WARN, "%a: splitting block entry with MMU disabled\n", __FUNCTION__));\r
     }\r
 \r
-    ArmReplaceLiveTranslationEntry (Entry, Value, RegionStart, DisableMmu);\r
+    mReplaceLiveEntryFunc (Entry, Value, RegionStart, DisableMmu);\r
   }\r
 }\r
 \r
@@ -747,15 +748,21 @@ ArmMmuBaseLibConstructor (
   )\r
 {\r
   extern UINT32  ArmReplaceLiveTranslationEntrySize;\r
+  VOID           *Hob;\r
 \r
-  //\r
-  // The ArmReplaceLiveTranslationEntry () helper function may be invoked\r
-  // with the MMU off so we have to ensure that it gets cleaned to the PoC\r
-  //\r
-  WriteBackDataCacheRange (\r
-    (VOID *)(UINTN)ArmReplaceLiveTranslationEntry,\r
-    ArmReplaceLiveTranslationEntrySize\r
-    );\r
+  Hob = GetFirstGuidHob (&gArmMmuReplaceLiveTranslationEntryFuncGuid);\r
+  if (Hob != NULL) {\r
+    mReplaceLiveEntryFunc = *(VOID **)GET_GUID_HOB_DATA (Hob);\r
+  } else {\r
+    //\r
+    // The ArmReplaceLiveTranslationEntry () helper function may be invoked\r
+    // with the MMU off so we have to ensure that it gets cleaned to the PoC\r
+    //\r
+    WriteBackDataCacheRange (\r
+      (VOID *)(UINTN)ArmReplaceLiveTranslationEntry,\r
+      ArmReplaceLiveTranslationEntrySize\r
+      );\r
+  }\r
 \r
   return RETURN_SUCCESS;\r
 }\r