blob: 9f8c2ad04553ddc965fd7bcf5a03dbf88e295076 [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
Julius Wernerbaf27db2019-10-02 17:28:56 -070051#if !CONFIG(NO_CBFS_MCACHE)
52 CBFS_MCACHE(., CONFIG_CBFS_MCACHE_SIZE)
53#endif
Julius Werner7fc92862019-11-18 13:01:06 -080054#if !CONFIG(NO_FMAP_CACHE)
Julius Wernercefe89e2019-11-06 19:29:44 -080055 FMAP_CACHE(., FMAP_SIZE)
Julius Werner7fc92862019-11-18 13:01:06 -080056#endif
Kyösti Mälkki3dd23a52019-08-22 15:06:50 +030057
Arthur Heymansdf9cdcf2019-11-09 06:50:20 +010058 _car_ehci_dbg_info = .;
Kyösti Mälkkif88208e2019-01-31 08:29:32 +020059 /* Reserve sizeof(struct ehci_dbg_info). */
Frans Hendriksd42154a2020-11-13 11:57:23 +010060 . += 80;
61 _ecar_ehci_dbg_info = .;
Kyösti Mälkki3dd23a52019-08-22 15:06:50 +030062
Kyösti Mälkki910490f2019-08-22 12:56:22 +030063 /* _bss and _ebss provide symbols to per-stage
Aaron Durbindd6fa932015-09-24 12:18:07 -050064 * variables that are not shared like the timestamp and the pre-ram
65 * cbmem console. This is useful for clearing this area on a per-stage
Arthur Heymansfdb8b132019-11-28 14:00:01 +010066 * basis when more than one stage uses cache-as-ram. */
Kyösti Mälkki910490f2019-08-22 12:56:22 +030067
68 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
69 _bss = .;
Kyösti Mälkkia165c072019-08-22 09:44:44 +030070 /* Allow global uninitialized variables for stages without CAR teardown. */
Aaron Durbin76ab2b72018-10-30 12:15:10 -060071 *(.bss)
72 *(.bss.*)
73 *(.sbss)
74 *(.sbss.*)
Aaron Durbin956c4f22015-09-05 13:31:14 -050075 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
Kyösti Mälkki910490f2019-08-22 12:56:22 +030076 _ebss = .;
Andrey Petrovdd56de92016-02-25 17:22:17 -080077
Harshit Sharmaa6ebe082020-07-20 00:21:05 -070078#if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
79 _shadow_size = (_ebss - _car_region_start) >> 3;
80 REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE)
81#endif
82 _car_unallocated_start = .;
Andrey Petrovdd56de92016-02-25 17:22:17 -080083 _car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start);
Aaron Durbin956c4f22015-09-05 13:31:14 -050084}
Kyösti Mälkkied318f22019-01-11 21:07:36 +020085. = _car_region_end;
86.car.mrc_var . (NOLOAD) : {
87 . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE;
88}
89
90#if ENV_BOOTBLOCK
91_car_mtrr_end = .;
92_car_mtrr_start = _car_region_start;
93
94_car_mtrr_size = _car_mtrr_end - _car_mtrr_start;
95_car_mtrr_sz_log2 = 1 << LOG2CEIL(_car_mtrr_size);
96_car_mtrr_mask = ~(MAX(4096, _car_mtrr_sz_log2) - 1);
97
98#if !CONFIG(NO_XIP_EARLY_STAGES)
99_xip_program_sz_log2 = 1 << LOG2CEIL(_ebootblock - _bootblock);
100_xip_mtrr_mask = ~(MAX(4096, _xip_program_sz_log2) - 1);
101#endif
102
103_rom_mtrr_mask = ~(CACHE_ROM_SIZE - 1);
104_rom_mtrr_base = _rom_mtrr_mask;
105#endif
Aaron Durbin956c4f22015-09-05 13:31:14 -0500106
107/* Global variables are not allowed in romstage
108 * This section is checked during stage creation to ensure
109 * that there are no global variables present
110 */
111
112. = 0xffffff00;
113.illegal_globals . : {
Nico Huber98fc4262016-01-23 01:24:33 +0100114 *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data)
Frans Hendriksd42154a2020-11-13 11:57:23 +0100115 *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*)
Aaron Durbin956c4f22015-09-05 13:31:14 -0500116}
117
Aaron Durbindd6fa932015-09-24 12:18:07 -0500118_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 -0800119#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -0600120_bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned");
121#endif
Patrick Rudolphd72d52a2018-11-12 19:26:54 +0100122_bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured");
Arthur Heymansc27628e2019-11-05 00:46:01 +0100123#if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_ROMSTAGE || ENV_VERSTAGE)
124_bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !");
125_bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!");
126#endif