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