]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
ArmPlatformPkg: Replaced 'ArmPlatformTrustzoneSupported' by the fixed Pcd gArmTokenSp...
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibRTSM / RTSMMem.c
... / ...
CommitLineData
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/IoLib.h>\r
19#include <Library/MemoryAllocationLib.h>\r
20#include <ArmPlatform.h>\r
21\r
22// Number of Virtual Memory Map Descriptors without a Logic Tile\r
23#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5\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
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
39VOID\r
40ArmPlatformGetVirtualMemoryMap (\r
41 IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap\r
42 )\r
43{\r
44 ARM_MEMORY_REGION_ATTRIBUTES CacheAttributes;\r
45 UINTN Index = 0;\r
46 ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;\r
47\r
48 ASSERT(VirtualMemoryMap != NULL);\r
49\r
50 VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages(EFI_SIZE_TO_PAGES (sizeof(ARM_MEMORY_REGION_DESCRIPTOR) * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS));\r
51 if (VirtualMemoryTable == NULL) {\r
52 return;\r
53 }\r
54\r
55 if (FeaturePcdGet(PcdCacheEnable) == TRUE) {\r
56 CacheAttributes = DDR_ATTRIBUTES_CACHED;\r
57 } else {\r
58 CacheAttributes = DDR_ATTRIBUTES_UNCACHED;\r
59 }\r
60\r
61 // ReMap (Either NOR Flash or DRAM)\r
62 VirtualMemoryTable[Index].PhysicalBase = ARM_VE_REMAP_BASE;\r
63 VirtualMemoryTable[Index].VirtualBase = ARM_VE_REMAP_BASE;\r
64 VirtualMemoryTable[Index].Length = ARM_VE_REMAP_SZ;\r
65\r
66 if (FeaturePcdGet(PcdNorFlashRemapping) == FALSE) {\r
67 // Map the NOR Flash as Secure Memory\r
68 if (FeaturePcdGet(PcdCacheEnable) == TRUE) {\r
69 VirtualMemoryTable[Index].Attributes = DDR_ATTRIBUTES_CACHED;\r
70 } else {\r
71 VirtualMemoryTable[Index].Attributes = DDR_ATTRIBUTES_UNCACHED;\r
72 }\r
73 } else {\r
74 // DRAM mapping\r
75 VirtualMemoryTable[Index].Attributes = CacheAttributes;\r
76 }\r
77\r
78 // DDR\r
79 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_DRAM_BASE;\r
80 VirtualMemoryTable[Index].VirtualBase = ARM_VE_DRAM_BASE;\r
81 VirtualMemoryTable[Index].Length = ARM_VE_DRAM_SZ;\r
82 VirtualMemoryTable[Index].Attributes = CacheAttributes;\r
83\r
84 // CPU peripherals. TRM. Manual says not all of them are implemented.\r
85 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_ON_CHIP_PERIPH_BASE;\r
86 VirtualMemoryTable[Index].VirtualBase = ARM_VE_ON_CHIP_PERIPH_BASE;\r
87 VirtualMemoryTable[Index].Length = ARM_VE_ON_CHIP_PERIPH_SZ;\r
88 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE;\r
89\r
90 // SMB CS0-CS1 - NOR Flash 1 & 2\r
91 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_NOR0_BASE;\r
92 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_NOR0_BASE;\r
93 VirtualMemoryTable[Index].Length = ARM_VE_SMB_NOR0_SZ + ARM_VE_SMB_NOR1_SZ;\r
94 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE;\r
95\r
96 // SMB CS2 - SRAM\r
97 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_SRAM_BASE;\r
98 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_SRAM_BASE;\r
99 VirtualMemoryTable[Index].Length = ARM_VE_SMB_SRAM_SZ;\r
100 VirtualMemoryTable[Index].Attributes = CacheAttributes;\r
101\r
102 // Peripheral CS2 and CS3\r
103 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_PERIPH_BASE;\r
104 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_PERIPH_BASE;\r
105 VirtualMemoryTable[Index].Length = 2 * ARM_VE_SMB_PERIPH_SZ;\r
106 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE;
107\r
108//TODO:This should be enabled for final release. Right now, ARM VE RTSM crashes.\r
109// // If a Logic Tile is connected to The ARM Versatile Express Motherboard\r
110// if (MmioRead32(ARM_VE_SYS_PROCID1_REG) != 0) {\r
111// VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_EXT_AXI_BASE;\r
112// VirtualMemoryTable[Index].VirtualBase = ARM_VE_EXT_AXI_BASE;\r
113// VirtualMemoryTable[Index].Length = ARM_VE_EXT_AXI_SZ;\r
114// VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE;\r
115//\r
116// ASSERT((Index + 1) == (MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS + 1));\r
117// } else {\r
118// ASSERT((Index + 1) == MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);\r
119// }\r
120\r
121 // End of Table\r
122 VirtualMemoryTable[++Index].PhysicalBase = 0;\r
123 VirtualMemoryTable[Index].VirtualBase = 0;\r
124 VirtualMemoryTable[Index].Length = 0;\r
125 VirtualMemoryTable[Index].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0;\r
126\r
127 *VirtualMemoryMap = VirtualMemoryTable;\r
128}\r
129\r
130/**\r
131 Return the EFI Memory Map provided by extension memory on your platform\r
132\r
133 This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource\r
134 Descriptor HOBs used by DXE core.\r
135 TODO: CompleteMe .... say this is the memory not covered by the System Memory PCDs\r
136\r
137 @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an\r
138 EFI Memory region. This array must be ended by a zero-filled entry\r
139\r
140**/\r
141EFI_STATUS\r
142ArmPlatformGetAdditionalSystemMemory (\r
143 OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap\r
144 )\r
145{\r
146 return EFI_UNSUPPORTED;\r
147}\r