blob: 17e6eea06d24ad52a296078d4f0837cd7ac032e2 [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. */
Jeremy Compostella0c8e5412023-11-27 15:05:29 -080020 VBOOT2_WORK(., VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE)
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
Jeremy Compostella052fb7c2023-08-18 14:25:22 -070054 . = ALIGN(CONFIG_CBFS_CACHE_ALIGN);
55 CBFS_CACHE(., CONFIG_PRERAM_CBFS_CACHE_SIZE)
56
Kyösti Mälkkif88208e2019-01-31 08:29:32 +020057 /* Reserve sizeof(struct ehci_dbg_info). */
Julius Werner82d16b12020-12-30 15:51:10 -080058 REGION(car_ehci_dbg_info, ., 80, 1)
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
Jeremy Compostellab7832de2023-08-30 15:42:09 -070065#if ENV_SEPARATE_DATA_AND_BSS
Kyösti Mälkki910490f2019-08-22 12:56:22 +030066 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
67 _bss = .;
Kyösti Mälkkia165c072019-08-22 09:44:44 +030068 /* Allow global uninitialized variables for stages without CAR teardown. */
Aaron Durbin76ab2b72018-10-30 12:15:10 -060069 *(.bss)
70 *(.bss.*)
71 *(.sbss)
72 *(.sbss.*)
Aaron Durbin956c4f22015-09-05 13:31:14 -050073 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
Kyösti Mälkki910490f2019-08-22 12:56:22 +030074 _ebss = .;
Julius Werner82d16b12020-12-30 15:51:10 -080075 RECORD_SIZE(bss)
Arthur Heymans9efb0c02020-11-30 14:03:51 +010076#endif
Andrey Petrovdd56de92016-02-25 17:22:17 -080077
Arthur Heymansa2bc2542021-05-29 08:10:49 +020078#if ENV_SEPARATE_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
Harshit Sharmaa6ebe082020-07-20 00:21:05 -070079 _shadow_size = (_ebss - _car_region_start) >> 3;
80 REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE)
81#endif
Aaron Durbin956c4f22015-09-05 13:31:14 -050082}
Arthur Heymans7a5c3692021-01-04 12:49:39 +010083
Jeremy Compostellab7832de2023-08-30 15:42:09 -070084#if ENV_SEPARATE_DATA_AND_BSS
85/* This symbol defines the load address of the Cache-As-RAM .data
86 * section. It should be right at the end of the .text section (_etext)
87 * and ARCH_POINTER_ALIGN_SIZE aligned. */
88_data_load = _etext;
89
90_bogus = ASSERT(_etext == ALIGN(_etext, ARCH_POINTER_ALIGN_SIZE), "Cache-As-RAM load address is improperly defined.");
91
92.data ALIGN(ARCH_POINTER_ALIGN_SIZE) : AT (_data_load) {
93 _data = .;
94 *(.data);
95 *(.data.*);
96 *(.sdata);
97 *(.sdata.*);
98 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
99 _edata = .;
100 RECORD_SIZE(data)
101} : data_segment
102#endif
103
104_car_unallocated_start = .;
105_car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start)
106 - CONFIG_FSP_T_RESERVED_SIZE;
107
Arthur Heymans7a5c3692021-01-04 12:49:39 +0100108. = _car_region_start;
109.car.fspm_rc_heap . (NOLOAD) : {
110. += CONFIG_FSP_M_RC_HEAP_SIZE;
111}
112
Kyösti Mälkkied318f22019-01-11 21:07:36 +0200113. = _car_region_end;
114.car.mrc_var . (NOLOAD) : {
115 . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE;
116}
Arthur Heymans97896892021-01-04 12:22:57 +0100117.car.fspt_reserved . (NOLOAD) : {
118 . += CONFIG_FSP_T_RESERVED_SIZE;
119}
120
Kyösti Mälkkied318f22019-01-11 21:07:36 +0200121#if ENV_BOOTBLOCK
122_car_mtrr_end = .;
123_car_mtrr_start = _car_region_start;
124
125_car_mtrr_size = _car_mtrr_end - _car_mtrr_start;
126_car_mtrr_sz_log2 = 1 << LOG2CEIL(_car_mtrr_size);
127_car_mtrr_mask = ~(MAX(4096, _car_mtrr_sz_log2) - 1);
128
129#if !CONFIG(NO_XIP_EARLY_STAGES)
130_xip_program_sz_log2 = 1 << LOG2CEIL(_ebootblock - _bootblock);
131_xip_mtrr_mask = ~(MAX(4096, _xip_program_sz_log2) - 1);
132#endif
133
134_rom_mtrr_mask = ~(CACHE_ROM_SIZE - 1);
135_rom_mtrr_base = _rom_mtrr_mask;
136#endif
Aaron Durbin956c4f22015-09-05 13:31:14 -0500137
Jeremy Compostellab7832de2023-08-30 15:42:09 -0700138#if ENV_SEPARATE_DATA_AND_BSS
139_bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) + SIZEOF(.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
140#else
Aaron Durbindd6fa932015-09-24 12:18:07 -0500141_bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
Jeremy Compostellab7832de2023-08-30 15:42:09 -0700142#endif
Julius Wernercd49cce2019-03-05 16:53:33 -0800143#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -0600144_bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned");
145#endif
Patrick Rudolphd72d52a2018-11-12 19:26:54 +0100146_bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured");
Arthur Heymansa2bc2542021-05-29 08:10:49 +0200147#if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_SEPARATE_ROMSTAGE || ENV_SEPARATE_VERSTAGE)
Arthur Heymansc27628e2019-11-05 00:46:01 +0100148_bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !");
149_bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!");
150#endif