blob: c291efb13c7cf06168400085d2db47570d7d3df1 [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin956c4f22015-09-05 13:31:14 -05002
Kyösti Mälkkied318f22019-01-11 21:07:36 +02003/* CACHE_ROM_SIZE defined here. */
4#include <cpu/x86/mtrr.h>
5
Aaron Durbin956c4f22015-09-05 13:31:14 -05006/* This file is included inside a SECTIONS block */
7. = CONFIG_DCACHE_RAM_BASE;
8.car.data . (NOLOAD) : {
Andrey Petrovdd56de92016-02-25 17:22:17 -08009 _car_region_start = . ;
Julius Wernercd49cce2019-03-05 16:53:33 -080010#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060011 /* Page table pre-allocation. CONFIG_DCACHE_RAM_BASE should be 4KiB
12 * aligned when using this option. */
13 _pagetables = . ;
Frans Hendriksd42154a2020-11-13 11:57:23 +010014 . += 4096 * CONFIG_NUM_CAR_PAGE_TABLE_PAGES;
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060015 _epagetables = . ;
16#endif
Frans Hendriksd42154a2020-11-13 11:57:23 +010017#if CONFIG(VBOOT_STARTS_IN_BOOTBLOCK)
Joel Kitchingd6f71d02019-02-21 12:37:55 +080018 /* Vboot work buffer only needs to be available when verified boot
19 * starts in bootblock. */
Joel Kitching0097f552019-02-21 12:36:55 +080020 VBOOT2_WORK(., 12K)
Aaron Durbin75c51d92015-09-29 16:31:20 -050021#endif
Bill XIEc79e96b2019-08-22 20:28:36 +080022#if CONFIG(TPM_MEASURED_BOOT)
Frans Hendriksd42154a2020-11-13 11:57:23 +010023 /* Vboot measured boot TCPA log measurements.
24 * Needs to be transferred until CBMEM is available */
Bill XIEc79e96b2019-08-22 20:28:36 +080025 TPM_TCPA_LOG(., 2K)
Arthur Heymans3c613042019-04-21 23:59:47 +020026#endif
Andrey Petrovee9e4ae2016-02-08 17:17:05 -080027 /* Stack for CAR stages. Since it persists across all stages that
28 * use CAR it can be reused. The chipset/SoC is expected to provide
29 * the stack size. */
Arthur Heymansdf9cdcf2019-11-09 06:50:20 +010030 _car_stack = .;
Andrey Petrovee9e4ae2016-02-08 17:17:05 -080031 . += CONFIG_DCACHE_BSP_STACK_SIZE;
Arthur Heymansdf9cdcf2019-11-09 06:50:20 +010032 _ecar_stack = .;
Aaron Durbindd6fa932015-09-24 12:18:07 -050033 /* The pre-ram cbmem console as well as the timestamp region are fixed
Arthur Heymans4cc9b6c2018-12-28 17:53:36 +010034 * in size. Therefore place them above the car global section so that
Frans Hendriksd42154a2020-11-13 11:57:23 +010035 * multiple stages (romstage and verstage) have a consistent
36 * link address of these shared objects. */
Kyösti Mälkki513a1a82018-06-03 12:29:50 +030037 PRERAM_CBMEM_CONSOLE(., CONFIG_PRERAM_CBMEM_CONSOLE_SIZE)
Julius Wernercd49cce2019-03-05 16:53:33 -080038#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060039 . = ALIGN(32);
40 /* Page directory pointer table resides here. There are 4 8-byte entries
41 * totalling 32 bytes that need to be 32-byte aligned. The reason the
42 * pdpt are not colocated with the rest of the page tables is to reduce
43 * fragmentation of the CAR space that persists across stages. */
44 _pdpt = .;
45 . += 32;
46 _epdpt = .;
47#endif
Kyösti Mälkki3dd23a52019-08-22 15:06:50 +030048
Furquan Shaikh549080b2018-05-17 23:30:28 -070049 TIMESTAMP(., 0x200)
Julius Werner7fc92862019-11-18 13:01:06 -080050
51#if !CONFIG(NO_FMAP_CACHE)
Julius Wernercefe89e2019-11-06 19:29:44 -080052 FMAP_CACHE(., FMAP_SIZE)
Julius Werner7fc92862019-11-18 13:01:06 -080053#endif
Kyösti Mälkki3dd23a52019-08-22 15:06:50 +030054
Arthur Heymansdf9cdcf2019-11-09 06:50:20 +010055 _car_ehci_dbg_info = .;
Kyösti Mälkkif88208e2019-01-31 08:29:32 +020056 /* Reserve sizeof(struct ehci_dbg_info). */
Frans Hendriksd42154a2020-11-13 11:57:23 +010057 . += 80;
58 _ecar_ehci_dbg_info = .;
Kyösti Mälkki3dd23a52019-08-22 15:06:50 +030059
Kyösti Mälkki910490f2019-08-22 12:56:22 +030060 /* _bss and _ebss provide symbols to per-stage
Aaron Durbindd6fa932015-09-24 12:18:07 -050061 * variables that are not shared like the timestamp and the pre-ram
62 * cbmem console. This is useful for clearing this area on a per-stage
Arthur Heymansfdb8b132019-11-28 14:00:01 +010063 * basis when more than one stage uses cache-as-ram. */
Kyösti Mälkki910490f2019-08-22 12:56:22 +030064
65 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
66 _bss = .;
Kyösti Mälkkia165c072019-08-22 09:44:44 +030067 /* Allow global uninitialized variables for stages without CAR teardown. */
Aaron Durbin76ab2b72018-10-30 12:15:10 -060068 *(.bss)
69 *(.bss.*)
70 *(.sbss)
71 *(.sbss.*)
Aaron Durbin956c4f22015-09-05 13:31:14 -050072 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
Kyösti Mälkki910490f2019-08-22 12:56:22 +030073 _ebss = .;
Andrey Petrovdd56de92016-02-25 17:22:17 -080074
Harshit Sharmaa6ebe082020-07-20 00:21:05 -070075#if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
76 _shadow_size = (_ebss - _car_region_start) >> 3;
77 REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE)
78#endif
79 _car_unallocated_start = .;
Andrey Petrovdd56de92016-02-25 17:22:17 -080080 _car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start);
Aaron Durbin956c4f22015-09-05 13:31:14 -050081}
Kyösti Mälkkied318f22019-01-11 21:07:36 +020082. = _car_region_end;
83.car.mrc_var . (NOLOAD) : {
84 . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE;
85}
86
87#if ENV_BOOTBLOCK
88_car_mtrr_end = .;
89_car_mtrr_start = _car_region_start;
90
91_car_mtrr_size = _car_mtrr_end - _car_mtrr_start;
92_car_mtrr_sz_log2 = 1 << LOG2CEIL(_car_mtrr_size);
93_car_mtrr_mask = ~(MAX(4096, _car_mtrr_sz_log2) - 1);
94
95#if !CONFIG(NO_XIP_EARLY_STAGES)
96_xip_program_sz_log2 = 1 << LOG2CEIL(_ebootblock - _bootblock);
97_xip_mtrr_mask = ~(MAX(4096, _xip_program_sz_log2) - 1);
98#endif
99
100_rom_mtrr_mask = ~(CACHE_ROM_SIZE - 1);
101_rom_mtrr_base = _rom_mtrr_mask;
102#endif
Aaron Durbin956c4f22015-09-05 13:31:14 -0500103
104/* Global variables are not allowed in romstage
105 * This section is checked during stage creation to ensure
106 * that there are no global variables present
107 */
108
109. = 0xffffff00;
110.illegal_globals . : {
Nico Huber98fc4262016-01-23 01:24:33 +0100111 *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data)
Frans Hendriksd42154a2020-11-13 11:57:23 +0100112 *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*)
Aaron Durbin956c4f22015-09-05 13:31:14 -0500113}
114
Aaron Durbindd6fa932015-09-24 12:18:07 -0500115_bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
Julius Wernercd49cce2019-03-05 16:53:33 -0800116#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -0600117_bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned");
118#endif
Patrick Rudolphd72d52a2018-11-12 19:26:54 +0100119_bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured");
Arthur Heymansc27628e2019-11-05 00:46:01 +0100120#if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_ROMSTAGE || ENV_VERSTAGE)
121_bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !");
122_bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!");
123#endif