blob: ab6c3b0df822d07d392a774696f436219e01bc3a [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>
Arthur Heymans28de28d2022-05-15 21:46:44 +02005#include <memlayout.h>
Kyösti Mälkkied318f22019-01-11 21:07:36 +02006
Aaron Durbin956c4f22015-09-05 13:31:14 -05007/* This file is included inside a SECTIONS block */
8. = CONFIG_DCACHE_RAM_BASE;
9.car.data . (NOLOAD) : {
Andrey Petrovdd56de92016-02-25 17:22:17 -080010 _car_region_start = . ;
Arthur Heymans7a5c3692021-01-04 12:49:39 +010011 . += CONFIG_FSP_M_RC_HEAP_SIZE;
Julius Wernercd49cce2019-03-05 16:53:33 -080012#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060013 /* Page table pre-allocation. CONFIG_DCACHE_RAM_BASE should be 4KiB
14 * aligned when using this option. */
Julius Werner82d16b12020-12-30 15:51:10 -080015 REGION(pagetables, ., 4K * CONFIG_NUM_CAR_PAGE_TABLE_PAGES, 4K)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060016#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)
Sergii Dmytruk2710df72022-11-10 00:40:51 +020023 /* Vboot measured boot TPM log measurements.
Frans Hendriksd42154a2020-11-13 11:57:23 +010024 * Needs to be transferred until CBMEM is available */
Sergii Dmytruk2710df72022-11-10 00:40:51 +020025 TPM_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. */
Julius Werner82d16b12020-12-30 15:51:10 -080030 REGION(car_stack, ., CONFIG_DCACHE_BSP_STACK_SIZE, 4)
Aaron Durbindd6fa932015-09-24 12:18:07 -050031 /* The pre-ram cbmem console as well as the timestamp region are fixed
Arthur Heymans4cc9b6c2018-12-28 17:53:36 +010032 * in size. Therefore place them above the car global section so that
Frans Hendriksd42154a2020-11-13 11:57:23 +010033 * multiple stages (romstage and verstage) have a consistent
34 * link address of these shared objects. */
Kyösti Mälkki513a1a82018-06-03 12:29:50 +030035 PRERAM_CBMEM_CONSOLE(., CONFIG_PRERAM_CBMEM_CONSOLE_SIZE)
Julius Wernercd49cce2019-03-05 16:53:33 -080036#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060037 . = ALIGN(32);
38 /* Page directory pointer table resides here. There are 4 8-byte entries
39 * totalling 32 bytes that need to be 32-byte aligned. The reason the
40 * pdpt are not colocated with the rest of the page tables is to reduce
41 * fragmentation of the CAR space that persists across stages. */
Julius Werner82d16b12020-12-30 15:51:10 -080042 REGION(pdpt, ., 32, 32)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060043#endif
Kyösti Mälkki3dd23a52019-08-22 15:06:50 +030044
Furquan Shaikh549080b2018-05-17 23:30:28 -070045 TIMESTAMP(., 0x200)
Julius Werner7fc92862019-11-18 13:01:06 -080046
Julius Wernerbaf27db2019-10-02 17:28:56 -070047#if !CONFIG(NO_CBFS_MCACHE)
48 CBFS_MCACHE(., CONFIG_CBFS_MCACHE_SIZE)
49#endif
Julius Werner7fc92862019-11-18 13:01:06 -080050#if !CONFIG(NO_FMAP_CACHE)
Julius Wernercefe89e2019-11-06 19:29:44 -080051 FMAP_CACHE(., FMAP_SIZE)
Julius Werner7fc92862019-11-18 13:01:06 -080052#endif
Kyösti Mälkki3dd23a52019-08-22 15:06:50 +030053
Kyösti Mälkkif88208e2019-01-31 08:29:32 +020054 /* Reserve sizeof(struct ehci_dbg_info). */
Julius Werner82d16b12020-12-30 15:51:10 -080055 REGION(car_ehci_dbg_info, ., 80, 1)
Kyösti Mälkki3dd23a52019-08-22 15:06:50 +030056
Kyösti Mälkki910490f2019-08-22 12:56:22 +030057 /* _bss and _ebss provide symbols to per-stage
Aaron Durbindd6fa932015-09-24 12:18:07 -050058 * variables that are not shared like the timestamp and the pre-ram
59 * cbmem console. This is useful for clearing this area on a per-stage
Arthur Heymansfdb8b132019-11-28 14:00:01 +010060 * basis when more than one stage uses cache-as-ram. */
Kyösti Mälkki910490f2019-08-22 12:56:22 +030061
Arthur Heymans9efb0c02020-11-30 14:03:51 +010062#if ENV_SEPARATE_BSS
Kyösti Mälkki910490f2019-08-22 12:56:22 +030063 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
64 _bss = .;
Kyösti Mälkkia165c072019-08-22 09:44:44 +030065 /* Allow global uninitialized variables for stages without CAR teardown. */
Aaron Durbin76ab2b72018-10-30 12:15:10 -060066 *(.bss)
67 *(.bss.*)
68 *(.sbss)
69 *(.sbss.*)
Jeremy Compostella50139d02022-12-01 15:07:51 -070070 /* '*_E' GNAT generated global variables actually are un-initialized
71 * (filled with zeros) variables which are initialized at
72 * runtime. Therefore, they can be placed in the _bss region. */
73#if CONFIG(ROMSTAGE_LIBHWBASE)
74 *(.data.hw__*_E)
75#endif
Jeremy Compostella765e5df2022-12-01 15:45:51 -070076#if CONFIG(EARLY_GFX_GMA)
77 *(.data.gma*_E)
78 /* libgfxinit uses a boolean variable to track its initialization
79 * state. Since the initial value is False it can safely be placed in
80 * the _bss region. */
81 *(.data.hw__gfx__gma__initialized)
82#endif
Aaron Durbin956c4f22015-09-05 13:31:14 -050083 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
Kyösti Mälkki910490f2019-08-22 12:56:22 +030084 _ebss = .;
Julius Werner82d16b12020-12-30 15:51:10 -080085 RECORD_SIZE(bss)
Arthur Heymans9efb0c02020-11-30 14:03:51 +010086#endif
Andrey Petrovdd56de92016-02-25 17:22:17 -080087
Harshit Sharmaa6ebe082020-07-20 00:21:05 -070088#if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
89 _shadow_size = (_ebss - _car_region_start) >> 3;
90 REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE)
91#endif
92 _car_unallocated_start = .;
Arthur Heymans97896892021-01-04 12:22:57 +010093 _car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start)
94 - CONFIG_FSP_T_RESERVED_SIZE;
Aaron Durbin956c4f22015-09-05 13:31:14 -050095}
Arthur Heymans7a5c3692021-01-04 12:49:39 +010096
97. = _car_region_start;
98.car.fspm_rc_heap . (NOLOAD) : {
99. += CONFIG_FSP_M_RC_HEAP_SIZE;
100}
101
Kyösti Mälkkied318f22019-01-11 21:07:36 +0200102. = _car_region_end;
103.car.mrc_var . (NOLOAD) : {
104 . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE;
105}
Arthur Heymans97896892021-01-04 12:22:57 +0100106.car.fspt_reserved . (NOLOAD) : {
107 . += CONFIG_FSP_T_RESERVED_SIZE;
108}
109
Kyösti Mälkkied318f22019-01-11 21:07:36 +0200110#if ENV_BOOTBLOCK
111_car_mtrr_end = .;
112_car_mtrr_start = _car_region_start;
113
114_car_mtrr_size = _car_mtrr_end - _car_mtrr_start;
115_car_mtrr_sz_log2 = 1 << LOG2CEIL(_car_mtrr_size);
116_car_mtrr_mask = ~(MAX(4096, _car_mtrr_sz_log2) - 1);
117
118#if !CONFIG(NO_XIP_EARLY_STAGES)
119_xip_program_sz_log2 = 1 << LOG2CEIL(_ebootblock - _bootblock);
120_xip_mtrr_mask = ~(MAX(4096, _xip_program_sz_log2) - 1);
121#endif
122
123_rom_mtrr_mask = ~(CACHE_ROM_SIZE - 1);
124_rom_mtrr_base = _rom_mtrr_mask;
125#endif
Aaron Durbin956c4f22015-09-05 13:31:14 -0500126
127/* Global variables are not allowed in romstage
128 * This section is checked during stage creation to ensure
129 * that there are no global variables present
130 */
131
132. = 0xffffff00;
133.illegal_globals . : {
Arthur Heymanscd259cb2022-05-16 13:20:18 +0200134 *(.data)
135 *(.data.*)
Aaron Durbin956c4f22015-09-05 13:31:14 -0500136}
137
Aaron Durbindd6fa932015-09-24 12:18:07 -0500138_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 -0800139#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -0600140_bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned");
141#endif
Patrick Rudolphd72d52a2018-11-12 19:26:54 +0100142_bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured");
Arthur Heymansc3ca8ed2023-05-08 17:04:45 +0200143#if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_ROMSTAGE || ENV_SEPARATE_VERSTAGE)
Arthur Heymansc27628e2019-11-05 00:46:01 +0100144_bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !");
145_bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!");
146#endif