1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /* CACHE_ROM_SIZE defined here. */
4 #include <cpu/x86/mtrr.h>
7 /* This file is included inside a SECTIONS block */
8 . = CONFIG_DCACHE_RAM_BASE;
9 .car.data . (NOLOAD) : {
10 _car_region_start = . ;
11 . += CONFIG_FSP_M_RC_HEAP_SIZE;
12 #if CONFIG(FSP_SPEC_VIOLATION_XEON_SP_HEAP_WORKAROUND)
13 REGION(fspm_heap, ., CONFIG_FSP_TEMP_RAM_SIZE, 16)
16 #if CONFIG(PAGING_IN_CACHE_AS_RAM)
17 /* Page table pre-allocation. CONFIG_DCACHE_RAM_BASE should be 4KiB
18 * aligned when using this option. */
19 REGION(pagetables, ., 4K * CONFIG_NUM_CAR_PAGE_TABLE_PAGES, 4K)
21 #if CONFIG(VBOOT_STARTS_IN_BOOTBLOCK)
22 /* Vboot work buffer only needs to be available when verified boot
23 * starts in bootblock. */
24 VBOOT2_WORK(., VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE)
26 #if CONFIG(TPM_MEASURED_BOOT)
27 /* Vboot measured boot TPM log measurements.
28 * Needs to be transferred until CBMEM is available */
31 /* Stack for CAR stages. Since it persists across all stages that
32 * use CAR it can be reused. The chipset/SoC is expected to provide
34 REGION(car_stack, ., CONFIG_DCACHE_BSP_STACK_SIZE, 4)
35 /* The pre-ram cbmem console as well as the timestamp region are fixed
36 * in size. Therefore place them above the car global section so that
37 * multiple stages (romstage and verstage) have a consistent
38 * link address of these shared objects. */
39 PRERAM_CBMEM_CONSOLE(., CONFIG_PRERAM_CBMEM_CONSOLE_SIZE)
40 #if CONFIG(PAGING_IN_CACHE_AS_RAM)
42 /* Page directory pointer table resides here. There are 4 8-byte entries
43 * totalling 32 bytes that need to be 32-byte aligned. The reason the
44 * pdpt are not colocated with the rest of the page tables is to reduce
45 * fragmentation of the CAR space that persists across stages. */
46 REGION(pdpt, ., 32, 32)
51 #if !CONFIG(NO_CBFS_MCACHE)
52 CBFS_MCACHE(., CONFIG_CBFS_MCACHE_SIZE)
54 #if !CONFIG(NO_FMAP_CACHE)
55 FMAP_CACHE(., FMAP_SIZE)
58 . = ALIGN(CONFIG_CBFS_CACHE_ALIGN);
59 CBFS_CACHE(., CONFIG_PRERAM_CBFS_CACHE_SIZE)
61 /* Reserve sizeof(struct ehci_dbg_info). */
62 REGION(car_ehci_dbg_info, ., 80, 1)
64 /* _bss and _ebss provide symbols to per-stage
65 * variables that are not shared like the timestamp and the pre-ram
66 * cbmem console. This is useful for clearing this area on a per-stage
67 * basis when more than one stage uses cache-as-ram. */
69 #if ENV_SEPARATE_DATA_AND_BSS
70 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
72 /* Allow global uninitialized variables for stages without CAR teardown. */
79 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
84 #if ENV_SEPARATE_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
85 _shadow_size = (_ebss - _car_region_start) >> 3;
86 REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE)
90 #if ENV_SEPARATE_DATA_AND_BSS
91 /* This symbol defines the load address of the Cache-As-RAM .data
92 * section. It should be right at the end of the .text section (_etext)
93 * and ARCH_POINTER_ALIGN_SIZE aligned. */
96 _bogus = ASSERT(_etext == ALIGN(_etext, ARCH_POINTER_ALIGN_SIZE), "Cache-As-RAM load address is improperly defined.");
98 .data ALIGN(ARCH_POINTER_ALIGN_SIZE) : AT (_data_load) {
106 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
112 _car_unallocated_start = .;
113 _car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start)
114 - CONFIG_FSP_T_RESERVED_SIZE;
117 .car.mrc_var . (NOLOAD) : {
118 . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE;
120 .car.fspt_reserved . (NOLOAD) : {
121 . += CONFIG_FSP_T_RESERVED_SIZE;
126 _car_mtrr_start = _car_region_start;
128 _car_mtrr_size = _car_mtrr_end - _car_mtrr_start;
129 _car_mtrr_sz_log2 = 1 << LOG2CEIL(_car_mtrr_size);
130 _car_mtrr_mask = ~(MAX(4096, _car_mtrr_sz_log2) - 1);
132 #if !CONFIG(NO_XIP_EARLY_STAGES)
133 _xip_program_sz_log2 = 1 << LOG2CEIL(_ebootblock - _bootblock);
134 _xip_mtrr_mask = ~(MAX(4096, _xip_program_sz_log2) - 1);
137 _rom_mtrr_mask = ~(CACHE_ROM_SIZE - 1);
138 _rom_mtrr_base = _rom_mtrr_mask;
141 #if ENV_SEPARATE_DATA_AND_BSS
142 _bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) + SIZEOF(.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
144 _bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
146 #if CONFIG(PAGING_IN_CACHE_AS_RAM)
147 _bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned");
149 _bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured");
150 #if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_SEPARATE_ROMSTAGE || ENV_SEPARATE_VERSTAGE)
151 _bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !");
152 _bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!");