]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
ArmPkg/ArmLib: add support for reading the max physical address space size
[mirror_edk2.git] / ArmPkg / Library / ArmLib / AArch64 / ArmLibSupport.S
index 1ef2f61f5979013a63247eafb19b0e87f0d6d894..b7173e00b039f9c5b59262f8f75dbaa3d9b9dca0 100644 (file)
@@ -196,4 +196,21 @@ ASM_FUNC(ArmWriteSctlr)
 3:msr   sctlr_el3, x0\r
 4:ret\r
 \r
+ASM_FUNC(ArmGetPhysicalAddressBits)\r
+  mrs   x0, id_aa64mmfr0_el1\r
+  adr   x1, .LPARanges\r
+  and   x0, x0, #0xf\r
+  ldrb  w0, [x1, x0]\r
+  ret\r
+\r
+//\r
+// Bits 0..3 of the AA64MFR0_EL1 system register encode the size of the\r
+// physical address space support on this CPU:\r
+// 0 == 32 bits, 1 == 36 bits, etc etc\r
+// 7 and up are reserved\r
+//\r
+.LPARanges:\r
+  .byte 32, 36, 40, 42, 44, 48, 52,  0\r
+  .byte  0,  0,  0,  0,  0,  0,  0,  0\r
+\r
 ASM_FUNCTION_REMOVE_IF_UNREFERENCED\r