ArmPkg/ArmLib: add support for reading the max physical address space size
[mirror_edk2.git] / ArmPkg / Library / ArmLib / Arm / ArmLibSupport.S
index f2a5176..0e9f9d0 100644 (file)
@@ -165,4 +165,12 @@ ASM_FUNC(ArmWriteCpuActlr)
   isb\r
   bx      lr\r
 \r
+ASM_FUNC (ArmGetPhysicalAddressBits)\r
+  mrc     p15, 0, r0, c0, c1, 4   // MMFR0\r
+  and     r0, r0, #0xf            // VMSA [3:0]\r
+  cmp     r0, #5                  // >= 5 implies LPAE support\r
+  movlt   r0, #32                 // 32 bits if no LPAE\r
+  movge   r0, #40                 // 40 bits if LPAE\r
+  bx      lr\r
+\r
 ASM_FUNCTION_REMOVE_IF_UNREFERENCED\r