]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c
ArmVirtPkg/XenVirtMemInfoLib: refactor reading of the PA space size
[mirror_edk2.git] / ArmVirtPkg / Library / XenVirtMemInfoLib / XenVirtMemInfoLib.c
1 /** @file
2
3 Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
4
5 This program and the accompanying materials are licensed and made available
6 under the terms and conditions of the BSD License which accompanies this
7 distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <Base.h>
16 #include <Library/ArmLib.h>
17 #include <Library/BaseLib.h>
18 #include <Library/DebugLib.h>
19
20 STATIC ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[2];
21
22 /**
23 Return the Virtual Memory Map of your platform
24
25 This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
26 on your platform.
27
28 @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
29 describing a Physical-to-Virtual Memory
30 mapping. This array must be ended by a
31 zero-filled entry. The allocated memory
32 will not be freed.
33
34 **/
35 VOID
36 EFIAPI
37 ArmVirtGetMemoryMap (
38 OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
39 )
40 {
41 EFI_PHYSICAL_ADDRESS TopOfAddressSpace;
42
43 ASSERT (VirtualMemoryMap != NULL);
44
45 TopOfAddressSpace = LShiftU64 (1ULL, ArmGetPhysicalAddressBits ());
46
47 //
48 // Map the entire physical memory space as cached. The only device
49 // we care about is the GIC, which will be stage 2 mapped as a device
50 // by the hypervisor, overriding the cached mapping we install here.
51 //
52 mVirtualMemoryTable[0].PhysicalBase = 0x0;
53 mVirtualMemoryTable[0].VirtualBase = 0x0;
54 mVirtualMemoryTable[0].Length = TopOfAddressSpace;
55 mVirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
56
57 mVirtualMemoryTable[1].PhysicalBase = 0x0;
58 mVirtualMemoryTable[1].VirtualBase = 0x0;
59 mVirtualMemoryTable[1].Length = 0x0;
60 mVirtualMemoryTable[1].Attributes = 0x0;
61
62 *VirtualMemoryMap = mVirtualMemoryTable;
63 }