]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbMem.c
ArmPlatformPkg/ArmPlatformLib: Move the UEFI memory partionning to MemoryInitPei
[mirror_edk2.git] / ArmPlatformPkg / ArmRealViewEbPkg / Library / ArmRealViewEbLibRTSM / ArmRealViewEbMem.c
CommitLineData
1d5d0ae9 1/** @file\r
2*\r
3* Copyright (c) 2011, ARM 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/PcdLib.h>\r
18#include <Library/MemoryAllocationLib.h>\r
6377d2f1 19#include <Library/IoLib.h>\r
1d5d0ae9 20\r
21// DDR attributes\r
22#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK\r
23#define DDR_ATTRIBUTES_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED\r
24#define DDR_ATTRIBUTES_SECURE_CACHED ARM_MEMORY_REGION_ATTRIBUTE_SECURE_WRITE_BACK\r
25#define DDR_ATTRIBUTES_SECURE_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_SECURE_UNCACHED_UNBUFFERED\r
26\r
1d5d0ae9 27/**\r
28 Return the Virtual Memory Map of your platform\r
29\r
30 This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU on your platform.\r
31\r
32 @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR describing a Physical-to-\r
33 Virtual Memory mapping. This array must be ended by a zero-filled\r
34 entry\r
35\r
36**/\r
37VOID ArmPlatformGetVirtualMemoryMap(ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap) {\r
1d5d0ae9 38 UINT32 CacheAttributes;\r
39 BOOLEAN bTrustzoneSupport = FALSE;\r
40 UINTN Index = 0;\r
41 ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;\r
42\r
43 ASSERT(VirtualMemoryMap != NULL);\r
44\r
45 VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages(sizeof(ARM_MEMORY_REGION_DESCRIPTOR) * 9);\r
46 if (VirtualMemoryTable == NULL) {\r
47 return;\r
48 }\r
49\r
50 if (FeaturePcdGet(PcdCacheEnable) == TRUE) {\r
51 CacheAttributes = (bTrustzoneSupport ? DDR_ATTRIBUTES_CACHED : DDR_ATTRIBUTES_SECURE_CACHED);\r
52 } else {\r
53 CacheAttributes = (bTrustzoneSupport ? DDR_ATTRIBUTES_UNCACHED : DDR_ATTRIBUTES_SECURE_UNCACHED);\r
54 }\r
55\r
56 // ReMap (Either NOR Flash or DRAM)\r
57 VirtualMemoryTable[Index].PhysicalBase = ARM_EB_REMAP_BASE;\r
58 VirtualMemoryTable[Index].VirtualBase = ARM_EB_REMAP_BASE;\r
59 VirtualMemoryTable[Index].Length = ARM_EB_REMAP_SZ;\r
60 VirtualMemoryTable[Index].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;\r
61\r
62 // DDR\r
63 VirtualMemoryTable[++Index].PhysicalBase = ARM_EB_DRAM_BASE;\r
64 VirtualMemoryTable[Index].VirtualBase = ARM_EB_DRAM_BASE;\r
65 VirtualMemoryTable[Index].Length = ARM_EB_DRAM_SZ;\r
66 VirtualMemoryTable[Index].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;\r
67\r
68 // SMC CS7\r
69 VirtualMemoryTable[++Index].PhysicalBase = ARM_EB_SMB_MB_ON_CHIP_PERIPH_BASE;\r
70 VirtualMemoryTable[Index].VirtualBase = ARM_EB_SMB_MB_ON_CHIP_PERIPH_BASE;\r
71 VirtualMemoryTable[Index].Length = ARM_EB_SMB_MB_ON_CHIP_PERIPH_SZ;\r
72 VirtualMemoryTable[Index].Attributes = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
73\r
74 // SMB CS0-CS1 - NOR Flash 1 & 2\r
75 VirtualMemoryTable[++Index].PhysicalBase = ARM_EB_SMB_NOR_BASE;\r
76 VirtualMemoryTable[Index].VirtualBase = ARM_EB_SMB_NOR_BASE;\r
77 VirtualMemoryTable[Index].Length = ARM_EB_SMB_NOR_SZ + ARM_EB_SMB_DOC_SZ;\r
78 VirtualMemoryTable[Index].Attributes = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
79\r
80 // SMB CS2 - SRAM\r
81 VirtualMemoryTable[++Index].PhysicalBase = ARM_EB_SMB_SRAM_BASE;\r
82 VirtualMemoryTable[Index].VirtualBase = ARM_EB_SMB_SRAM_BASE;\r
83 VirtualMemoryTable[Index].Length = ARM_EB_SMB_SRAM_SZ;\r
84 VirtualMemoryTable[Index].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;\r
85\r
86 // SMB CS3-CS6 - Motherboard Peripherals\r
87 VirtualMemoryTable[++Index].PhysicalBase = ARM_EB_SMB_PERIPH_BASE;\r
88 VirtualMemoryTable[Index].VirtualBase = ARM_EB_SMB_PERIPH_BASE;\r
89 VirtualMemoryTable[Index].Length = ARM_EB_SMB_PERIPH_SZ;\r
90 VirtualMemoryTable[Index].Attributes = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
91\r
92 // If a Logic Tile is connected to The ARM Versatile Express Motherboard\r
93 if (MmioRead32(ARM_EB_SYS_PROCID1_REG) != 0) {\r
94 VirtualMemoryTable[++Index].PhysicalBase = ARM_EB_LOGIC_TILE_BASE;\r
95 VirtualMemoryTable[Index].VirtualBase = ARM_EB_LOGIC_TILE_BASE;\r
96 VirtualMemoryTable[Index].Length = ARM_EB_LOGIC_TILE_SZ;\r
97 VirtualMemoryTable[Index].Attributes = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
98 }\r
99\r
100 // End of Table\r
101 VirtualMemoryTable[++Index].PhysicalBase = 0;\r
102 VirtualMemoryTable[Index].VirtualBase = 0;\r
103 VirtualMemoryTable[Index].Length = 0;\r
104 VirtualMemoryTable[Index].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0;\r
105\r
106 *VirtualMemoryMap = VirtualMemoryTable;\r
107}\r
108\r
109/**\r
110 Return the EFI Memory Map of your platform\r
111\r
112 This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource\r
113 Descriptor HOBs used by DXE core.\r
114\r
115 @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an\r
116 EFI Memory region. This array must be ended by a zero-filled entry\r
117\r
118**/\r
964680c1 119EFI_STATUS\r
120ArmPlatformGetAdditionalSystemMemory (\r
1d5d0ae9 121 OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap\r
122) {\r
964680c1 123 return EFI_UNSUPPORTED;\r
1d5d0ae9 124}\r