1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /* CACHE_ROM_SIZE defined here. */
4 #include <cpu/x86/mtrr.h>
6 /* This file is included inside a SECTIONS block */
7 . = CONFIG_DCACHE_RAM_BASE;
8 .car.data . (NOLOAD) : {
9 _car_region_start = . ;
10 . += CONFIG_FSP_M_RC_HEAP_SIZE;
11 #if CONFIG(PAGING_IN_CACHE_AS_RAM)
12 /* Page table pre-allocation. CONFIG_DCACHE_RAM_BASE should be 4KiB
13 * aligned when using this option. */
14 REGION(pagetables, ., 4K * CONFIG_NUM_CAR_PAGE_TABLE_PAGES, 4K)
16 #if CONFIG(VBOOT_STARTS_IN_BOOTBLOCK)
17 /* Vboot work buffer only needs to be available when verified boot
18 * starts in bootblock. */
21 #if CONFIG(TPM_MEASURED_BOOT)
22 /* Vboot measured boot TCPA log measurements.
23 * Needs to be transferred until CBMEM is available */
26 /* Stack for CAR stages. Since it persists across all stages that
27 * use CAR it can be reused. The chipset/SoC is expected to provide
29 REGION(car_stack, ., CONFIG_DCACHE_BSP_STACK_SIZE, 4)
30 /* The pre-ram cbmem console as well as the timestamp region are fixed
31 * in size. Therefore place them above the car global section so that
32 * multiple stages (romstage and verstage) have a consistent
33 * link address of these shared objects. */
34 PRERAM_CBMEM_CONSOLE(., CONFIG_PRERAM_CBMEM_CONSOLE_SIZE)
35 #if CONFIG(PAGING_IN_CACHE_AS_RAM)
37 /* Page directory pointer table resides here. There are 4 8-byte entries
38 * totalling 32 bytes that need to be 32-byte aligned. The reason the
39 * pdpt are not colocated with the rest of the page tables is to reduce
40 * fragmentation of the CAR space that persists across stages. */
41 REGION(pdpt, ., 32, 32)
46 #if !CONFIG(NO_CBFS_MCACHE)
47 CBFS_MCACHE(., CONFIG_CBFS_MCACHE_SIZE)
49 #if !CONFIG(NO_FMAP_CACHE)
50 FMAP_CACHE(., FMAP_SIZE)
53 /* Reserve sizeof(struct ehci_dbg_info). */
54 REGION(car_ehci_dbg_info, ., 80, 1)
56 /* _bss and _ebss provide symbols to per-stage
57 * variables that are not shared like the timestamp and the pre-ram
58 * cbmem console. This is useful for clearing this area on a per-stage
59 * basis when more than one stage uses cache-as-ram. */
61 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
63 /* Allow global uninitialized variables for stages without CAR teardown. */
68 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
72 #if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
73 _shadow_size = (_ebss - _car_region_start) >> 3;
74 REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE)
76 _car_unallocated_start = .;
77 _car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start)
78 - CONFIG_FSP_T_RESERVED_SIZE;
81 . = _car_region_start;
82 .car.fspm_rc_heap . (NOLOAD) : {
83 . += CONFIG_FSP_M_RC_HEAP_SIZE;
87 .car.mrc_var . (NOLOAD) : {
88 . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE;
90 .car.fspt_reserved . (NOLOAD) : {
91 . += CONFIG_FSP_T_RESERVED_SIZE;
96 _car_mtrr_start = _car_region_start;
98 _car_mtrr_size = _car_mtrr_end - _car_mtrr_start;
99 _car_mtrr_sz_log2 = 1 << LOG2CEIL(_car_mtrr_size);
100 _car_mtrr_mask = ~(MAX(4096, _car_mtrr_sz_log2) - 1);
102 #if !CONFIG(NO_XIP_EARLY_STAGES)
103 _xip_program_sz_log2 = 1 << LOG2CEIL(_ebootblock - _bootblock);
104 _xip_mtrr_mask = ~(MAX(4096, _xip_program_sz_log2) - 1);
107 _rom_mtrr_mask = ~(CACHE_ROM_SIZE - 1);
108 _rom_mtrr_base = _rom_mtrr_mask;
111 /* Global variables are not allowed in romstage
112 * This section is checked during stage creation to ensure
113 * that there are no global variables present
117 .illegal_globals . : {
118 *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data)
119 *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*)
122 _bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
123 #if CONFIG(PAGING_IN_CACHE_AS_RAM)
124 _bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned");
126 _bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured");
127 #if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_ROMSTAGE || ENV_VERSTAGE)
128 _bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !");
129 _bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!");