XenVirtMemInfoLib.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /** @file
  2. Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #include <Base.h>
  6. #include <Library/ArmLib.h>
  7. #include <Library/BaseLib.h>
  8. #include <Library/DebugLib.h>
  9. STATIC ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[2];
  10. /**
  11. Return the Virtual Memory Map of your platform
  12. This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
  13. on your platform.
  14. @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
  15. describing a Physical-to-Virtual Memory
  16. mapping. This array must be ended by a
  17. zero-filled entry. The allocated memory
  18. will not be freed.
  19. **/
  20. VOID
  21. EFIAPI
  22. ArmVirtGetMemoryMap (
  23. OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
  24. )
  25. {
  26. EFI_PHYSICAL_ADDRESS TopOfAddressSpace;
  27. ASSERT (VirtualMemoryMap != NULL);
  28. TopOfAddressSpace = LShiftU64 (1ULL, ArmGetPhysicalAddressBits ());
  29. //
  30. // Map the entire physical memory space as cached. The only device
  31. // we care about is the GIC, which will be stage 2 mapped as a device
  32. // by the hypervisor, overriding the cached mapping we install here.
  33. //
  34. mVirtualMemoryTable[0].PhysicalBase = 0x0;
  35. mVirtualMemoryTable[0].VirtualBase = 0x0;
  36. mVirtualMemoryTable[0].Length = TopOfAddressSpace;
  37. mVirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
  38. mVirtualMemoryTable[1].PhysicalBase = 0x0;
  39. mVirtualMemoryTable[1].VirtualBase = 0x0;
  40. mVirtualMemoryTable[1].Length = 0x0;
  41. mVirtualMemoryTable[1].Attributes = 0x0;
  42. *VirtualMemoryMap = mVirtualMemoryTable;
  43. }