blob: f99304f3961562b13d009edb52c3d38da0ce6714 [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;
Arthur Heymans0201d982024-02-18 11:45:30 +010012#if CONFIG(FSP_SPEC_VIOLATION_XEON_SP_HEAP_WORKAROUND)
13 REGION(fspm_heap, ., CONFIG_FSP_TEMP_RAM_SIZE, 16)
14#endif
15
Julius Wernercd49cce2019-03-05 16:53:33 -080016#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060017 /* Page table pre-allocation. CONFIG_DCACHE_RAM_BASE should be 4KiB
18 * aligned when using this option. */
Julius Werner82d16b12020-12-30 15:51:10 -080019 REGION(pagetables, ., 4K * CONFIG_NUM_CAR_PAGE_TABLE_PAGES, 4K)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060020#endif
Frans Hendriksd42154a2020-11-13 11:57:23 +010021#if CONFIG(VBOOT_STARTS_IN_BOOTBLOCK)
Joel Kitchingd6f71d02019-02-21 12:37:55 +080022 /* Vboot work buffer only needs to be available when verified boot
23 * starts in bootblock. */
Jeremy Compostella0c8e5412023-11-27 15:05:29 -080024 VBOOT2_WORK(., VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE)
Aaron Durbin75c51d92015-09-29 16:31:20 -050025#endif
Bill XIEc79e96b2019-08-22 20:28:36 +080026#if CONFIG(TPM_MEASURED_BOOT)
Sergii Dmytruk2710df72022-11-10 00:40:51 +020027 /* Vboot measured boot TPM log measurements.
Frans Hendriksd42154a2020-11-13 11:57:23 +010028 * Needs to be transferred until CBMEM is available */
Sergii Dmytruk2710df72022-11-10 00:40:51 +020029 TPM_LOG(., 2K)
Arthur Heymans3c613042019-04-21 23:59:47 +020030#endif
Andrey Petrovee9e4ae2016-02-08 17:17:05 -080031 /* Stack for CAR stages. Since it persists across all stages that
32 * use CAR it can be reused. The chipset/SoC is expected to provide
33 * the stack size. */
Julius Werner82d16b12020-12-30 15:51:10 -080034 REGION(car_stack, ., CONFIG_DCACHE_BSP_STACK_SIZE, 4)
Aaron Durbindd6fa932015-09-24 12:18:07 -050035 /* The pre-ram cbmem console as well as the timestamp region are fixed
Arthur Heymans4cc9b6c2018-12-28 17:53:36 +010036 * in size. Therefore place them above the car global section so that
Frans Hendriksd42154a2020-11-13 11:57:23 +010037 * multiple stages (romstage and verstage) have a consistent
38 * link address of these shared objects. */
Kyösti Mälkki513a1a82018-06-03 12:29:50 +030039 PRERAM_CBMEM_CONSOLE(., CONFIG_PRERAM_CBMEM_CONSOLE_SIZE)
Julius Wernercd49cce2019-03-05 16:53:33 -080040#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060041 . = ALIGN(32);
42 /* Page directory pointer table resides here. There are 4 8-byte entries
43 * totalling 32 bytes that need to be 32-byte aligned. The reason the
44 * pdpt are not colocated with the rest of the page tables is to reduce
45 * fragmentation of the CAR space that persists across stages. */
Julius Werner82d16b12020-12-30 15:51:10 -080046 REGION(pdpt, ., 32, 32)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -060047#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
Jeremy Compostella052fb7c2023-08-18 14:25:22 -070058 . = ALIGN(CONFIG_CBFS_CACHE_ALIGN);
59 CBFS_CACHE(., CONFIG_PRERAM_CBFS_CACHE_SIZE)
60
Kyösti Mälkkif88208e2019-01-31 08:29:32 +020061 /* Reserve sizeof(struct ehci_dbg_info). */
Julius Werner82d16b12020-12-30 15:51:10 -080062 REGION(car_ehci_dbg_info, ., 80, 1)
Kyösti Mälkki3dd23a52019-08-22 15:06:50 +030063
Kyösti Mälkki910490f2019-08-22 12:56:22 +030064 /* _bss and _ebss provide symbols to per-stage
Aaron Durbindd6fa932015-09-24 12:18:07 -050065 * variables that are not shared like the timestamp and the pre-ram
66 * cbmem console. This is useful for clearing this area on a per-stage
Arthur Heymansfdb8b132019-11-28 14:00:01 +010067 * basis when more than one stage uses cache-as-ram. */
Kyösti Mälkki910490f2019-08-22 12:56:22 +030068
Jeremy Compostellab7832de2023-08-30 15:42:09 -070069#if ENV_SEPARATE_DATA_AND_BSS
Kyösti Mälkki910490f2019-08-22 12:56:22 +030070 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
71 _bss = .;
Kyösti Mälkkia165c072019-08-22 09:44:44 +030072 /* Allow global uninitialized variables for stages without CAR teardown. */
Aaron Durbin76ab2b72018-10-30 12:15:10 -060073 *(.bss)
74 *(.bss.*)
Arthur Heymans8406fb42024-04-05 09:00:06 +020075 *(.lbss)
76 *(.lbss.*)
Aaron Durbin76ab2b72018-10-30 12:15:10 -060077 *(.sbss)
78 *(.sbss.*)
Aaron Durbin956c4f22015-09-05 13:31:14 -050079 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
Kyösti Mälkki910490f2019-08-22 12:56:22 +030080 _ebss = .;
Julius Werner82d16b12020-12-30 15:51:10 -080081 RECORD_SIZE(bss)
Arthur Heymans9efb0c02020-11-30 14:03:51 +010082#endif
Andrey Petrovdd56de92016-02-25 17:22:17 -080083
Arthur Heymansa2bc2542021-05-29 08:10:49 +020084#if ENV_SEPARATE_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
Harshit Sharmaa6ebe082020-07-20 00:21:05 -070085 _shadow_size = (_ebss - _car_region_start) >> 3;
86 REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE)
87#endif
Aaron Durbin956c4f22015-09-05 13:31:14 -050088}
Arthur Heymans7a5c3692021-01-04 12:49:39 +010089
Jeremy Compostellab7832de2023-08-30 15:42:09 -070090#if ENV_SEPARATE_DATA_AND_BSS
91/* This symbol defines the load address of the Cache-As-RAM .data
92 * section. It should be right at the end of the .text section (_etext)
93 * and ARCH_POINTER_ALIGN_SIZE aligned. */
94_data_load = _etext;
95
96_bogus = ASSERT(_etext == ALIGN(_etext, ARCH_POINTER_ALIGN_SIZE), "Cache-As-RAM load address is improperly defined.");
97
98.data ALIGN(ARCH_POINTER_ALIGN_SIZE) : AT (_data_load) {
99 _data = .;
100 *(.data);
101 *(.data.*);
Arthur Heymans8406fb42024-04-05 09:00:06 +0200102 *(.ldata);
103 *(.ldata.*);
Jeremy Compostellab7832de2023-08-30 15:42:09 -0700104 *(.sdata);
105 *(.sdata.*);
106 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
107 _edata = .;
108 RECORD_SIZE(data)
109} : data_segment
110#endif
111
112_car_unallocated_start = .;
113_car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start)
114 - CONFIG_FSP_T_RESERVED_SIZE;
115
Arthur Heymans7a5c3692021-01-04 12:49:39 +0100116. = _car_region_start;
117.car.fspm_rc_heap . (NOLOAD) : {
Arthur Heymans0201d982024-02-18 11:45:30 +0100118 . += CONFIG_FSP_M_RC_HEAP_SIZE;
Arthur Heymans7a5c3692021-01-04 12:49:39 +0100119}
120
Kyösti Mälkkied318f22019-01-11 21:07:36 +0200121. = _car_region_end;
122.car.mrc_var . (NOLOAD) : {
123 . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE;
124}
Arthur Heymans97896892021-01-04 12:22:57 +0100125.car.fspt_reserved . (NOLOAD) : {
126 . += CONFIG_FSP_T_RESERVED_SIZE;
127}
128
Kyösti Mälkkied318f22019-01-11 21:07:36 +0200129#if ENV_BOOTBLOCK
130_car_mtrr_end = .;
131_car_mtrr_start = _car_region_start;
132
133_car_mtrr_size = _car_mtrr_end - _car_mtrr_start;
134_car_mtrr_sz_log2 = 1 << LOG2CEIL(_car_mtrr_size);
135_car_mtrr_mask = ~(MAX(4096, _car_mtrr_sz_log2) - 1);
136
137#if !CONFIG(NO_XIP_EARLY_STAGES)
138_xip_program_sz_log2 = 1 << LOG2CEIL(_ebootblock - _bootblock);
139_xip_mtrr_mask = ~(MAX(4096, _xip_program_sz_log2) - 1);
140#endif
141
142_rom_mtrr_mask = ~(CACHE_ROM_SIZE - 1);
143_rom_mtrr_base = _rom_mtrr_mask;
144#endif
Aaron Durbin956c4f22015-09-05 13:31:14 -0500145
Jeremy Compostellab7832de2023-08-30 15:42:09 -0700146#if ENV_SEPARATE_DATA_AND_BSS
147_bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) + SIZEOF(.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
148#else
Aaron Durbindd6fa932015-09-24 12:18:07 -0500149_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 -0700150#endif
Julius Wernercd49cce2019-03-05 16:53:33 -0800151#if CONFIG(PAGING_IN_CACHE_AS_RAM)
Aaron Durbin0f35af8f2018-04-18 01:00:27 -0600152_bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned");
153#endif
Patrick Rudolphd72d52a2018-11-12 19:26:54 +0100154_bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured");
Arthur Heymansa2bc2542021-05-29 08:10:49 +0200155#if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_SEPARATE_ROMSTAGE || ENV_SEPARATE_VERSTAGE)
Arthur Heymansc27628e2019-11-05 00:46:01 +0100156_bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !");
157_bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!");
158#endif