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