Debian Codegraph @

src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld

raw
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <memlayout.h>
4 #include <arch/header.ld>
5 #include <psp_verstage/psp_transfer.h>
6
7 #define EARLY_RESERVED_DRAM_START(addr) REGION_START(early_reserved_dram, addr)
8 #define EARLY_RESERVED_DRAM_END(addr) REGION_END(early_reserved_dram, addr)
9
10 #define PSP_SHAREDMEM_DRAM_START(addr) REGION_START(psp_sharedmem_dram, addr)
11 #define PSP_SHAREDMEM_DRAM_END(addr) REGION_END(psp_sharedmem_dram, addr)
12
13 BOOTBLOCK_END = CONFIG_ROMSTAGE_ADDR;
14 BOOTBLOCK_ADDR = BOOTBLOCK_END - CONFIG_C_ENV_BOOTBLOCK_SIZE;
15
16 /*
17 *
18 * +--------------------------------+
19 * | |
20 * | |
21 * | |
22 * | |
23 * | |
24 * | |
25 * | |
26 * reserved_dram_end +--------------------------------+
27 * | |
28 * | cbfs_cache (if reqd) |
29 * | (CBFS_CACHE_SIZE) |
30 * +--------------------------------+ VERSTAGE_ADDR + VERSTAGE_SIZE + PRERAM_CBMEM_CONSOLE_SIZE
31 * | Preram CBMEM console |
32 * | (PRERAM_CBMEM_CONSOLE_SIZE) |
33 * +--------------------------------+ VERSTAGE_ADDR + VERSTAGE_SIZE
34 * | |
35 * | verstage (if reqd) |
36 * | (VERSTAGE_SIZE) |
37 * +--------------------------------+ VERSTAGE_ADDR
38 * | |
39 * | FSP-M |
40 * | (FSP_M_SIZE) |
41 * +--------------------------------+ FSP_M_ADDR
42 * | romstage |
43 * | (ROMSTAGE_SIZE) |
44 * +--------------------------------+ ROMSTAGE_ADDR = BOOTBLOCK_END
45 * | | X86_RESET_VECTOR = BOOTBLOCK_END - 0x10
46 * | bootblock |
47 * | (C_ENV_BOOTBLOCK_SIZE) |
48 * +--------------------------------+ BOOTBLOCK_ADDR = BOOTBLOCK_END - C_ENV_BOOTBLOCK_SIZE
49 * | Unused hole |
50 * +--------------------------------+
51 * | FMAP cache (FMAP_SIZE) |
52 * +--------------------------------+
53 * | CBFS mcache (CBFS_MCACHE_SIZE) |
54 * +--------------------------------+ PSP_SHAREDMEM_BASE + 0x40 + VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE + PRE_X86_CBMEM_CONSOLE_SIZE + 0x200
55 * | Early Timestamp region (512B) |
56 * +--------------------------------+ PSP_SHAREDMEM_BASE + 0x40 + VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE + PRE_X86_CBMEM_CONSOLE_SIZE
57 * | PSP Verstage CBMEM console |
58 * | (PRE_X86_CBMEM_CONSOLE_SIZE) |
59 * +--------------------------------+ PSP_SHAREDMEM_BASE + 0x40 + VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE
60 * | PSP shared (vboot workbuf) |
61 * |(VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE) |
62 * +--------------------------------+ PSP_SHAREDMEM_BASE + 0x40
63 * | Transfer Info Structure |
64 * +--------------------------------+ PSP_SHAREDMEM_BASE
65 * | APOB (PSP_APOB_DRAM_SIZE) |
66 * +--------------------------------+ PSP_APOB_DRAM_ADDRESS
67 * | Early BSP stack |
68 * | (EARLYRAM_BSP_STACK_SIZE) |
69 * reserved_dram_start +--------------------------------+ EARLY_RESERVED_DRAM_BASE
70 * | DRAM |
71 * +--------------------------------+ 0x100000
72 * | Option ROM |
73 * +--------------------------------+ 0xc0000
74 * | Legacy VGA |
75 * +--------------------------------+ 0xa0000
76 * | DRAM |
77 * +--------------------------------+ 0x0
78 */
79 SECTIONS
80 {
81 DRAM_START(0x0)
82
83 EARLY_RESERVED_DRAM_START(CONFIG_EARLY_RESERVED_DRAM_BASE)
84
85 EARLYRAM_STACK(., CONFIG_EARLYRAM_BSP_STACK_SIZE)
86 REGION(apob, CONFIG_PSP_APOB_DRAM_ADDRESS, CONFIG_PSP_APOB_DRAM_SIZE, 1)
87
88 #if CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)
89 PSP_SHAREDMEM_DRAM_START(CONFIG_PSP_SHAREDMEM_BASE)
90 #endif
91
92 #include "memlayout_transfer_buffer.inc"
93
94 #if CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)
95 PSP_SHAREDMEM_DRAM_END(CONFIG_PSP_SHAREDMEM_BASE + CONFIG_PSP_SHAREDMEM_SIZE)
96 #endif
97 _ = ASSERT(BOOTBLOCK_END == ((BOOTBLOCK_END + 0xFFFF) & 0xFFFF0000), "Bootblock end must be 16 bit aligned");
98 REGION(bootblock_overlap_detection, BOOTBLOCK_ADDR, CONFIG_C_ENV_BOOTBLOCK_SIZE, 1)
99 ROMSTAGE(CONFIG_ROMSTAGE_ADDR, CONFIG_ROMSTAGE_SIZE)
100
101 #if CONFIG(PLATFORM_USES_FSP2_0)
102 REGION(fspm, CONFIG_FSP_M_ADDR, CONFIG_FSP_M_SIZE, 1)
103 #endif
104
105 #if CONFIG(VBOOT_SEPARATE_VERSTAGE) && !CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)
106 VERSTAGE(CONFIG_VERSTAGE_ADDR, CONFIG_VERSTAGE_SIZE)
107 #endif
108
109 PRERAM_CBMEM_CONSOLE(., CONFIG_PRERAM_CBMEM_CONSOLE_SIZE)
110
111 #if CONFIG_CBFS_CACHE_SIZE > 0
112 . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
113 CBFS_CACHE(., CONFIG_CBFS_CACHE_SIZE)
114 #endif
115
116 EARLY_RESERVED_DRAM_END(.)
117
118 /* Relocated at runtime in cbmem so the address does not matter. */
119 RAMSTAGE(512M, 8M)
120 }
121
122 #if ENV_BOOTBLOCK
123
124 gdtptr_offset = gdtptr & 0xffff;
125 nullidt_offset = nullidt & 0xffff;
126
127 MEMORY
128 {
129 /* Make sure all the 16bit code is in the same 64K segment as the reset vector */
130 resetsection (rwx) : ORIGIN = BOOTBLOCK_END - 64K, LENGTH = 64K
131 }
132
133 SECTIONS {
134 /*
135 * AMD's PSP will verify the integrity of the BIOS Reset Image at S3 resume,
136 * thus it must not change during execution. Having .data and .bss between
137 * .text and .reset breaks the integrity, as .bss or .data might get modified.
138 *
139 * Enable ENV_SEPARATE_DATA_AND_BSS for AMD's bootblock and mark as
140 * data_segment to place it in the second PT_LOAD area. The second PT_LOAD area
141 * must be removed using objcopy since AMDCOMPRESS doesn't support multiple
142 * PT_LOAD segments.
143 */
144 . = BOOTBLOCK_ADDR & ~(16 - 1);
145 .data . : {
146 _data = .;
147 *(.data);
148 *(.data.*);
149 *(.ldata);
150 *(.ldata.*);
151 *(.sdata);
152 *(.sdata.*);
153 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
154 _edata = .;
155 RECORD_SIZE(data)
156 } : data_segment
157
158 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
159
160 .bss . (NOLOAD) : {
161 _bss = .;
162 *(.bss)
163 *(.bss.*)
164 *(.lbss)
165 *(.lbss.*)
166 *(.sbss)
167 *(.sbss.*)
168 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
169 _ebss = .;
170 RECORD_SIZE(bss)
171 } : data_segment
172
173 . = (BOOTBLOCK_TOP - PROGRAM_SZ) & ~(4096 - 1);
174 _bootblock = .;
175
176 INCLUDE "bootblock/lib/program.ld"
177
178 /*
179 * Add free space for a copy of the data section. The assembly code will copy
180 * the section to .data at runtime when ENV_SEPARATE_DATA_AND_BSS is set.
181 *
182 * objcopy will be used during build to copy the .data to the .datacopy section.
183 * This ensures that only *one* loadable segment is being used as bootblock.
184 */
185 .datacopy . : {
186 _datacopy = .;
187 . += SIZEOF(.data);
188 _edatacopy = .;
189 } : to_load = 0xff
190 _data_load = LOADADDR(.datacopy);
191
192 PROGRAM_SZ = SIZEOF(.text) + SIZEOF(.data);
193 . = _X86_RESET_VECTOR - EARLYASM_SZ;
194 . = ALIGN(16);
195 BOOTBLOCK_TOP = .;
196 .init BOOTBLOCK_TOP : {
197 *(.init._start);
198 *(.init);
199 *(.init.*);
200 } >resetsection
201
202 /*
203 * Allocation reserves extra space here. Alignment requirements
204 * may cause the total size of a section to change when the start
205 * address gets applied.
206 */
207 EARLYASM_SZ = SIZEOF(.init) + 16;
208
209 _X86_RESET_VECTOR = BOOTBLOCK_END - 0x10;
210 _bogus = ASSERT((_X86_RESET_VECTOR & 0xffff) == 0xfff0, "IP needs to be 0xfff0");
211 .reset (_X86_RESET_VECTOR) : {
212 *(.reset);
213 } >resetsection
214
215 .last_byte (BOOTBLOCK_END - 1) : {
216 BYTE(0xff);
217 } >resetsection
218 _ebootblock = BOOTBLOCK_END;
219
220 ASSERT(_ebootblock - _bootblock <= CONFIG_C_ENV_BOOTBLOCK_SIZE, "CONFIG_C_ENV_BOOTBLOCK_SIZE is not big enough")
221 }
222 #endif /* ENV_BOOTBLOCK */