]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Mem.c
ArmPlatformPkg: Remove an unused function.
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibCTA15-A7 / CTA15-A7Mem.c
CommitLineData
295c2eb8 1/** @file\r
2*\r
3* Copyright (c) 2012, 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/HobLib.h>\r
18#include <Library/IoLib.h>\r
19#include <Library/MemoryAllocationLib.h>\r
20#include <Library/PcdLib.h>\r
21\r
22#include <ArmPlatform.h>\r
23\r
24#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 14\r
25\r
26// DDR attributes\r
27#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK\r
28#define DDR_ATTRIBUTES_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED\r
29\r
30/**\r
31 Return the Virtual Memory Map of your platform\r
32\r
33 This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU on your platform.\r
34\r
35 @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR describing a Physical-to-\r
36 Virtual Memory mapping. This array must be ended by a zero-filled\r
37 entry\r
38\r
39**/\r
40VOID\r
41ArmPlatformGetVirtualMemoryMap (\r
42 IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap\r
43 )\r
44{\r
45 ARM_MEMORY_REGION_ATTRIBUTES CacheAttributes;\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 = DDR_ATTRIBUTES_CACHED;\r
58 } else {\r
59 CacheAttributes = DDR_ATTRIBUTES_UNCACHED;\r
60 }\r
61\r
62 // Detect if it is a 1GB or 2GB Test Chip\r
63 // [16:19]: 0=1GB TC2, 1=2GB TC2\r
64 if (MmioRead32(ARM_VE_SYS_PROCID0_REG) & (0xF << 16)) {\r
65 DEBUG((EFI_D_ERROR,"Info: 2GB Test Chip 2 detected.\n"));\r
66 BuildResourceDescriptorHob (\r
67 EFI_RESOURCE_SYSTEM_MEMORY,\r
68 EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
69 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |\r
70 EFI_RESOURCE_ATTRIBUTE_TESTED,\r
71 PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemorySize),\r
72 0x40000000\r
73 );\r
74 }\r
75\r
76#ifdef ARM_BIGLITTLE_TC2\r
77 // Secure NOR0 Flash\r
78 VirtualMemoryTable[Index].PhysicalBase = ARM_VE_SEC_NOR0_BASE;\r
79 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SEC_NOR0_BASE;\r
80 VirtualMemoryTable[Index].Length = ARM_VE_SEC_NOR0_SZ;\r
81 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
82 // Secure RAM\r
83 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SEC_RAM0_BASE;\r
84 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SEC_RAM0_BASE;\r
85 VirtualMemoryTable[Index].Length = ARM_VE_SEC_RAM0_SZ;\r
86 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
87#endif\r
88\r
89 // SMB CS0 - NOR0 Flash\r
90 VirtualMemoryTable[Index].PhysicalBase = ARM_VE_SMB_NOR0_BASE;\r
91 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_NOR0_BASE;\r
92 VirtualMemoryTable[Index].Length = SIZE_256KB * 255;\r
93 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
94 // Environment Variables region\r
95 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_NOR0_BASE + (SIZE_256KB * 255);\r
96 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_NOR0_BASE + (SIZE_256KB * 255);\r
97 VirtualMemoryTable[Index].Length = SIZE_64KB * 4;\r
98 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
99\r
100 // SMB CS1 or CS4 - NOR1 Flash\r
101 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_NOR1_BASE;\r
102 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_NOR1_BASE;\r
103 VirtualMemoryTable[Index].Length = SIZE_256KB * 255;\r
104 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
105 // Environment Variables region\r
106 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_NOR1_BASE + (SIZE_256KB * 255);\r
107 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_NOR1_BASE + (SIZE_256KB * 255);\r
108 VirtualMemoryTable[Index].Length = SIZE_64KB * 4;\r
109 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
110\r
111 // SMB CS3 or CS1 - PSRAM\r
112 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_SRAM_BASE;\r
113 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_SRAM_BASE;\r
114 VirtualMemoryTable[Index].Length = ARM_VE_SMB_SRAM_SZ;\r
115 VirtualMemoryTable[Index].Attributes = CacheAttributes;\r
116\r
117 // Motherboard peripherals\r
118 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_PERIPH_BASE;\r
119 VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_PERIPH_BASE;\r
120 VirtualMemoryTable[Index].Length = ARM_VE_SMB_PERIPH_SZ;\r
121 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
122\r
123#ifdef ARM_BIGLITTLE_TC2\r
124 // Non-secure ROM\r
125 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_TC2_NON_SECURE_ROM_BASE;\r
126 VirtualMemoryTable[Index].VirtualBase = ARM_VE_TC2_NON_SECURE_ROM_BASE;\r
127 VirtualMemoryTable[Index].Length = ARM_VE_TC2_NON_SECURE_ROM_SZ;\r
128 VirtualMemoryTable[Index].Attributes = CacheAttributes;\r
129#endif\r
130\r
131 // OnChip peripherals\r
132 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_ONCHIP_PERIPH_BASE;\r
133 VirtualMemoryTable[Index].VirtualBase = ARM_VE_ONCHIP_PERIPH_BASE;\r
134 VirtualMemoryTable[Index].Length = ARM_VE_ONCHIP_PERIPH_SZ;\r
135 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
136\r
137 // SCC Region\r
138 VirtualMemoryTable[++Index].PhysicalBase = ARM_CTA15A7_SCC_BASE;\r
139 VirtualMemoryTable[Index].VirtualBase = ARM_CTA15A7_SCC_BASE;\r
140 VirtualMemoryTable[Index].Length = SIZE_64KB;\r
141 VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;\r
142\r
143#ifdef ARM_BIGLITTLE_TC2\r
144 // TC2 OnChip non-secure SRAM\r
145 VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_TC2_NON_SECURE_SRAM_BASE;\r
146 VirtualMemoryTable[Index].VirtualBase = ARM_VE_TC2_NON_SECURE_SRAM_BASE;\r
147 VirtualMemoryTable[Index].Length = ARM_VE_TC2_NON_SECURE_SRAM_SZ;\r
148 VirtualMemoryTable[Index].Attributes = CacheAttributes;\r
149#endif\r
150\r
151#ifndef ARM_BIGLITTLE_TC2\r
152 // Workaround for SRAM bug in RTSM\r
153 if (PcdGet32 (PcdSystemMemoryBase) != 0x80000000) {\r
154 VirtualMemoryTable[++Index].PhysicalBase = 0x80000000;\r
155 VirtualMemoryTable[Index].VirtualBase = 0x80000000;\r
156 VirtualMemoryTable[Index].Length = PcdGet32 (PcdSystemMemoryBase) - 0x80000000;\r
157 VirtualMemoryTable[Index].Attributes = CacheAttributes;\r
158 }\r
159#endif\r
160\r
161 // DDR\r
162 VirtualMemoryTable[++Index].PhysicalBase = PcdGet32 (PcdSystemMemoryBase);\r
163 VirtualMemoryTable[Index].VirtualBase = PcdGet32 (PcdSystemMemoryBase);\r
164 VirtualMemoryTable[Index].Length = PcdGet32 (PcdSystemMemorySize);\r
165 VirtualMemoryTable[Index].Attributes = CacheAttributes;\r
166\r
167 // End of Table\r
168 VirtualMemoryTable[++Index].PhysicalBase = 0;\r
169 VirtualMemoryTable[Index].VirtualBase = 0;\r
170 VirtualMemoryTable[Index].Length = 0;\r
171 VirtualMemoryTable[Index].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0;\r
172\r
173 ASSERT((Index + 1) <= MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);\r
174\r
175 *VirtualMemoryMap = VirtualMemoryTable;\r
176}\r