]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/ArmVirtXen: add ArmVirtMemInfoLib implementation
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 17 Nov 2017 13:58:07 +0000 (13:58 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 23 Nov 2017 16:05:28 +0000 (16:05 +0000)
Clone the existing ArmPlatformGetVirtualMemoryMap () for this platform,
clean it up slightly (by using a static buffer rather than a heap
allocation, and removing the support for uncached DRAM mappings), and
turn it into a new ArmVirtMemInfoLib implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Julien Grall <julien.grall@linaro.org>
ArmVirtPkg/ArmVirtXen.dsc
ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S [new file with mode: 0644]
ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S [new file with mode: 0644]
ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c [new file with mode: 0644]
ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf [new file with mode: 0644]

index 7a443483d1ac0340efb001fa69fa3c546add7101..3df684d13cb0dece13e17aa4455e5012fc6e39d9 100644 (file)
@@ -44,6 +44,7 @@
   VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf\r
 \r
   ArmPlatformLib|ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ArmXenRelocatablePlatformLib.inf\r
+  ArmVirtMemInfoLib|ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf\r
 \r
   TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf\r
 \r
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S b/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S
new file mode 100644 (file)
index 0000000..a1f6a19
--- /dev/null
@@ -0,0 +1,39 @@
+#\r
+#  Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
+#  Copyright (c) 2016-2017, Linaro Limited. All rights reserved.\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+\r
+#include <AsmMacroIoLibV8.h>\r
+\r
+//EFI_PHYSICAL_ADDRESS\r
+//GetPhysAddrTop (\r
+//  VOID\r
+//  );\r
+ASM_FUNC(ArmGetPhysAddrTop)\r
+  mrs   x0, id_aa64mmfr0_el1\r
+  adr   x1, .LPARanges\r
+  and   x0, x0, #7\r
+  ldrb  w1, [x1, x0]\r
+  mov   x0, #1\r
+  lsl   x0, x0, x1\r
+  ret\r
+\r
+//\r
+// Bits 0..2 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
+// 6 and 7 are reserved\r
+//\r
+.LPARanges:\r
+  .byte 32, 36, 40, 42, 44, 48, -1, -1\r
+\r
+ASM_FUNCTION_REMOVE_IF_UNREFERENCED\r
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S b/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S
new file mode 100644 (file)
index 0000000..9cd8152
--- /dev/null
@@ -0,0 +1,24 @@
+#\r
+#  Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
+#  Copyright (c) 2014-2017, Linaro Limited. All rights reserved.\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+\r
+#include <AsmMacroIoLib.h>\r
+\r
+//EFI_PHYSICAL_ADDRESS\r
+//GetPhysAddrTop (\r
+//  VOID\r
+//  );\r
+ASM_FUNC(ArmGetPhysAddrTop)\r
+  mov   r0, #0x00000000\r
+  mov   r1, #0x10000\r
+  bx    lr\r
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c
new file mode 100644 (file)
index 0000000..88ff316
--- /dev/null
@@ -0,0 +1,63 @@
+/** @file\r
+\r
+  Copyright (c) 2014-2017, Linaro Limited. All rights reserved.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Base.h>\r
+#include <Library/ArmLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+STATIC ARM_MEMORY_REGION_DESCRIPTOR  mVirtualMemoryTable[2];\r
+\r
+EFI_PHYSICAL_ADDRESS\r
+ArmGetPhysAddrTop (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Return the Virtual Memory Map of your platform\r
+\r
+  This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU\r
+  on your platform.\r
+\r
+  @param[out]   VirtualMemoryMap    Array of ARM_MEMORY_REGION_DESCRIPTOR\r
+                                    describing a Physical-to-Virtual Memory\r
+                                    mapping. This array must be ended by a\r
+                                    zero-filled entry. The allocated memory\r
+                                    will not be freed.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ArmVirtGetMemoryMap (\r
+  OUT ARM_MEMORY_REGION_DESCRIPTOR   **VirtualMemoryMap\r
+  )\r
+{\r
+  ASSERT (VirtualMemoryMap != NULL);\r
+\r
+  //\r
+  // Map the entire physical memory space as cached. The only device\r
+  // we care about is the GIC, which will be stage 2 mapped as a device\r
+  // by the hypervisor, overriding the cached mapping we install here.\r
+  //\r
+  mVirtualMemoryTable[0].PhysicalBase = 0x0;\r
+  mVirtualMemoryTable[0].VirtualBase  = 0x0;\r
+  mVirtualMemoryTable[0].Length       = ArmGetPhysAddrTop ();\r
+  mVirtualMemoryTable[0].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;\r
+\r
+  mVirtualMemoryTable[1].PhysicalBase = 0x0;\r
+  mVirtualMemoryTable[1].VirtualBase  = 0x0;\r
+  mVirtualMemoryTable[1].Length       = 0x0;\r
+  mVirtualMemoryTable[1].Attributes   = 0x0;\r
+\r
+  *VirtualMemoryMap = mVirtualMemoryTable;\r
+}\r
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
new file mode 100644 (file)
index 0000000..cd4c805
--- /dev/null
@@ -0,0 +1,41 @@
+#/* @file\r
+#\r
+#  Copyright (c) 2011-2015, ARM Limited. All rights reserved.\r
+#  Copyright (c) 2014-2017, Linaro Limited. All rights reserved.\r
+#\r
+#  This program and the accompanying materials are licensed and made available\r
+#  under the terms and conditions of the BSD License which accompanies this\r
+#  distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#*/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x0001001A\r
+  BASE_NAME                      = XenVirtMemInfoLib\r
+  FILE_GUID                      = 40d1f8f5-4dfe-4e0f-9a15-b1de9dc9f4ed\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = ArmVirtMemInfoLib\r
+\r
+[Sources]\r
+  XenVirtMemInfoLib.c\r
+\r
+[Sources.ARM]\r
+  Arm/PhysAddrTop.S\r
+\r
+[Sources.AARCH64]\r
+  AArch64/PhysAddrTop.S\r
+\r
+[Packages]\r
+  ArmPkg/ArmPkg.dec\r
+  ArmVirtPkg/ArmVirtPkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+  ArmLib\r
+  DebugLib\r