]> git.proxmox.com Git - mirror_edk2.git/blame - ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/XenVirtMem.c
ArmVirtPkg/ArmVirtMemoryInitPeiLib: move to ArmVirtMemInfoLib
[mirror_edk2.git] / ArmVirtPkg / Library / ArmXenRelocatablePlatformLib / XenVirtMem.c
CommitLineData
f9849036
AB
1/** @file\r
2*\r
3* Copyright (c) 2014, Linaro Limited. All rights reserved.\r
4*\r
5* This program and the accompanying materials\r
6* are licensed and made available under the terms and conditions of the BSD License\r
7* which accompanies this distribution. The full text of the license may be found at\r
8* http://opensource.org/licenses/bsd-license.php\r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12*\r
13**/\r
14\r
15#include <Library/ArmPlatformLib.h>\r
16#include <Library/DebugLib.h>\r
17#include <Library/BaseMemoryLib.h>\r
18#include <Library/PcdLib.h>\r
19#include <Library/IoLib.h>\r
20#include <Library/MemoryAllocationLib.h>\r
f9849036
AB
21\r
22// Number of Virtual Memory Map Descriptors\r
23#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 2\r
24\r
25// DDR attributes\r
26#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK\r
27#define DDR_ATTRIBUTES_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED\r
28\r
29EFI_PHYSICAL_ADDRESS\r
30ArmGetPhysAddrTop (\r
31 VOID\r
32 );\r
33\r
34/**\r
35 Return the Virtual Memory Map of your platform\r
36\r
37 This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU\r
38 on your platform.\r
39\r
40 @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR\r
41 describing a Physical-to-Virtual Memory\r
42 mapping. This array must be ended by a\r
43 zero-filled entry\r
44\r
45**/\r
46VOID\r
47ArmPlatformGetVirtualMemoryMap (\r
48 IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap\r
49 )\r
50{\r
51 ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;\r
52\r
53 ASSERT (VirtualMemoryMap != NULL);\r
54\r
55 VirtualMemoryTable = AllocatePages (\r
56 EFI_SIZE_TO_PAGES (\r
57 sizeof (ARM_MEMORY_REGION_DESCRIPTOR)\r
58 * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS\r
59 )\r
60 );\r
61\r
62 if (VirtualMemoryTable == NULL) {\r
63 DEBUG ((EFI_D_ERROR, "%a: Error: Failed AllocatePages()\n", __FUNCTION__));\r
64 return;\r
65 }\r
66\r
67 //\r
68 // Map the entire physical memory space as cached. The only device\r
69 // we care about is the GIC, which will be stage 2 mapped as a device\r
70 // by the hypervisor, which will override the cached mapping we install\r
71 // here.\r
72 //\r
73 VirtualMemoryTable[0].PhysicalBase = 0x0;\r
74 VirtualMemoryTable[0].VirtualBase = 0x0;\r
75 VirtualMemoryTable[0].Length = ArmGetPhysAddrTop ();\r
76 VirtualMemoryTable[0].Attributes = DDR_ATTRIBUTES_CACHED;\r
77\r
78 // End of Table\r
79 ZeroMem (&VirtualMemoryTable[1], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));\r
80\r
81 *VirtualMemoryMap = VirtualMemoryTable;\r
82}\r