]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
ArmPlatformPkg: Remove an unused function.
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibRTSM / RTSMMem.c
CommitLineData
1ddb209e 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
1ddb209e 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
1ddb209e 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
1ddb209e 55 if (FeaturePcdGet(PcdCacheEnable) == TRUE) {\r
12c5ae23 56 CacheAttributes = DDR_ATTRIBUTES_CACHED;\r
1ddb209e 57 } else {\r
12c5ae23 58 CacheAttributes = DDR_ATTRIBUTES_UNCACHED;\r
1ddb209e 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
12c5ae23 66 if (FeaturePcdGet(PcdNorFlashRemapping) == FALSE) {\r
1ddb209e 67 // Map the NOR Flash as Secure Memory\r
68 if (FeaturePcdGet(PcdCacheEnable) == TRUE) {\r
12c5ae23 69 VirtualMemoryTable[Index].Attributes = DDR_ATTRIBUTES_CACHED;\r
1ddb209e 70 } else {\r
12c5ae23 71 VirtualMemoryTable[Index].Attributes = DDR_ATTRIBUTES_UNCACHED;\r
1ddb209e 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
7fffeef9 88 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
1ddb209e 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
7fffeef9 94 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
1ddb209e 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
1e57a462 106 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
1ddb209e 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
7fffeef9 114// VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
1ddb209e 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