]> git.proxmox.com Git - mirror_edk2.git/blame - ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
ArmVirtPkg/QemuVirtMemInfoLib: remove 1:1 mapping of top of PA range
[mirror_edk2.git] / ArmVirtPkg / Library / QemuVirtMemInfoLib / QemuVirtMemInfoLib.c
CommitLineData
30436034
AB
1/** @file\r
2\r
3 Copyright (c) 2014-2017, Linaro Limited. All rights reserved.\r
4\r
5 This program and the accompanying materials are licensed and made available\r
6 under the terms and conditions of the BSD License which accompanies this\r
7 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 <Base.h>\r
16#include <Library/ArmLib.h>\r
17#include <Library/BaseMemoryLib.h>\r
18#include <Library/DebugLib.h>\r
19#include <Library/MemoryAllocationLib.h>\r
20\r
21// Number of Virtual Memory Map Descriptors\r
22#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5\r
23\r
30436034
AB
24/**\r
25 Return the Virtual Memory Map of your platform\r
26\r
27 This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU\r
28 on your platform.\r
29\r
30 @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR\r
31 describing a Physical-to-Virtual Memory\r
32 mapping. This array must be ended by a\r
33 zero-filled entry. The allocated memory\r
34 will not be freed.\r
35\r
36**/\r
37VOID\r
38ArmVirtGetMemoryMap (\r
39 OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap\r
40 )\r
41{\r
42 ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;\r
30436034
AB
43\r
44 ASSERT (VirtualMemoryMap != NULL);\r
45\r
46 VirtualMemoryTable = AllocatePool (sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *\r
47 MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);\r
48\r
49 if (VirtualMemoryTable == NULL) {\r
50 DEBUG ((DEBUG_ERROR, "%a: Error: Failed AllocatePool()\n", __FUNCTION__));\r
51 return;\r
52 }\r
53\r
54 // System DRAM\r
55 VirtualMemoryTable[0].PhysicalBase = PcdGet64 (PcdSystemMemoryBase);\r
56 VirtualMemoryTable[0].VirtualBase = VirtualMemoryTable[0].PhysicalBase;\r
57 VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);\r
58 VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;\r
59\r
60 DEBUG ((DEBUG_INFO, "%a: Dumping System DRAM Memory Map:\n"\r
61 "\tPhysicalBase: 0x%lX\n"\r
62 "\tVirtualBase: 0x%lX\n"\r
63 "\tLength: 0x%lX\n",\r
64 __FUNCTION__,\r
65 VirtualMemoryTable[0].PhysicalBase,\r
66 VirtualMemoryTable[0].VirtualBase,\r
67 VirtualMemoryTable[0].Length));\r
68\r
69 // Peripheral space before DRAM\r
70 VirtualMemoryTable[1].PhysicalBase = 0x0;\r
71 VirtualMemoryTable[1].VirtualBase = 0x0;\r
72 VirtualMemoryTable[1].Length = VirtualMemoryTable[0].PhysicalBase;\r
73 VirtualMemoryTable[1].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
74\r
30436034 75 // Remap the FD region as normal executable memory\r
364eed84
AB
76 VirtualMemoryTable[2].PhysicalBase = PcdGet64 (PcdFdBaseAddress);\r
77 VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase;\r
78 VirtualMemoryTable[2].Length = FixedPcdGet32 (PcdFdSize);\r
79 VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;\r
30436034
AB
80\r
81 // End of Table\r
364eed84 82 ZeroMem (&VirtualMemoryTable[3], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));\r
30436034
AB
83\r
84 *VirtualMemoryMap = VirtualMemoryTable;\r
85}\r