Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 2 | |
Kyösti Mälkki | ed318f2 | 2019-01-11 21:07:36 +0200 | [diff] [blame] | 3 | /* CACHE_ROM_SIZE defined here. */ |
| 4 | #include <cpu/x86/mtrr.h> |
Arthur Heymans | 28de28d | 2022-05-15 21:46:44 +0200 | [diff] [blame] | 5 | #include <memlayout.h> |
Kyösti Mälkki | ed318f2 | 2019-01-11 21:07:36 +0200 | [diff] [blame] | 6 | |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 7 | /* This file is included inside a SECTIONS block */ |
| 8 | . = CONFIG_DCACHE_RAM_BASE; |
| 9 | .car.data . (NOLOAD) : { |
Andrey Petrov | dd56de9 | 2016-02-25 17:22:17 -0800 | [diff] [blame] | 10 | _car_region_start = . ; |
Arthur Heymans | 7a5c369 | 2021-01-04 12:49:39 +0100 | [diff] [blame] | 11 | . += CONFIG_FSP_M_RC_HEAP_SIZE; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 12 | #if CONFIG(PAGING_IN_CACHE_AS_RAM) |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 13 | /* Page table pre-allocation. CONFIG_DCACHE_RAM_BASE should be 4KiB |
| 14 | * aligned when using this option. */ |
Julius Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 15 | REGION(pagetables, ., 4K * CONFIG_NUM_CAR_PAGE_TABLE_PAGES, 4K) |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 16 | #endif |
Frans Hendriks | d42154a | 2020-11-13 11:57:23 +0100 | [diff] [blame] | 17 | #if CONFIG(VBOOT_STARTS_IN_BOOTBLOCK) |
Joel Kitching | d6f71d0 | 2019-02-21 12:37:55 +0800 | [diff] [blame] | 18 | /* Vboot work buffer only needs to be available when verified boot |
| 19 | * starts in bootblock. */ |
Jeremy Compostella | 0c8e541 | 2023-11-27 15:05:29 -0800 | [diff] [blame^] | 20 | VBOOT2_WORK(., VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE) |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 21 | #endif |
Bill XIE | c79e96b | 2019-08-22 20:28:36 +0800 | [diff] [blame] | 22 | #if CONFIG(TPM_MEASURED_BOOT) |
Sergii Dmytruk | 2710df7 | 2022-11-10 00:40:51 +0200 | [diff] [blame] | 23 | /* Vboot measured boot TPM log measurements. |
Frans Hendriks | d42154a | 2020-11-13 11:57:23 +0100 | [diff] [blame] | 24 | * Needs to be transferred until CBMEM is available */ |
Sergii Dmytruk | 2710df7 | 2022-11-10 00:40:51 +0200 | [diff] [blame] | 25 | TPM_LOG(., 2K) |
Arthur Heymans | 3c61304 | 2019-04-21 23:59:47 +0200 | [diff] [blame] | 26 | #endif |
Andrey Petrov | ee9e4ae | 2016-02-08 17:17:05 -0800 | [diff] [blame] | 27 | /* 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 Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 30 | REGION(car_stack, ., CONFIG_DCACHE_BSP_STACK_SIZE, 4) |
Aaron Durbin | dd6fa93 | 2015-09-24 12:18:07 -0500 | [diff] [blame] | 31 | /* The pre-ram cbmem console as well as the timestamp region are fixed |
Arthur Heymans | 4cc9b6c | 2018-12-28 17:53:36 +0100 | [diff] [blame] | 32 | * in size. Therefore place them above the car global section so that |
Frans Hendriks | d42154a | 2020-11-13 11:57:23 +0100 | [diff] [blame] | 33 | * multiple stages (romstage and verstage) have a consistent |
| 34 | * link address of these shared objects. */ |
Kyösti Mälkki | 513a1a8 | 2018-06-03 12:29:50 +0300 | [diff] [blame] | 35 | PRERAM_CBMEM_CONSOLE(., CONFIG_PRERAM_CBMEM_CONSOLE_SIZE) |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 36 | #if CONFIG(PAGING_IN_CACHE_AS_RAM) |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 37 | . = 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 Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 42 | REGION(pdpt, ., 32, 32) |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 43 | #endif |
Kyösti Mälkki | 3dd23a5 | 2019-08-22 15:06:50 +0300 | [diff] [blame] | 44 | |
Furquan Shaikh | 549080b | 2018-05-17 23:30:28 -0700 | [diff] [blame] | 45 | TIMESTAMP(., 0x200) |
Julius Werner | 7fc9286 | 2019-11-18 13:01:06 -0800 | [diff] [blame] | 46 | |
Julius Werner | baf27db | 2019-10-02 17:28:56 -0700 | [diff] [blame] | 47 | #if !CONFIG(NO_CBFS_MCACHE) |
| 48 | CBFS_MCACHE(., CONFIG_CBFS_MCACHE_SIZE) |
| 49 | #endif |
Julius Werner | 7fc9286 | 2019-11-18 13:01:06 -0800 | [diff] [blame] | 50 | #if !CONFIG(NO_FMAP_CACHE) |
Julius Werner | cefe89e | 2019-11-06 19:29:44 -0800 | [diff] [blame] | 51 | FMAP_CACHE(., FMAP_SIZE) |
Julius Werner | 7fc9286 | 2019-11-18 13:01:06 -0800 | [diff] [blame] | 52 | #endif |
Kyösti Mälkki | 3dd23a5 | 2019-08-22 15:06:50 +0300 | [diff] [blame] | 53 | |
Jeremy Compostella | 052fb7c | 2023-08-18 14:25:22 -0700 | [diff] [blame] | 54 | . = ALIGN(CONFIG_CBFS_CACHE_ALIGN); |
| 55 | CBFS_CACHE(., CONFIG_PRERAM_CBFS_CACHE_SIZE) |
| 56 | |
Kyösti Mälkki | f88208e | 2019-01-31 08:29:32 +0200 | [diff] [blame] | 57 | /* Reserve sizeof(struct ehci_dbg_info). */ |
Julius Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 58 | REGION(car_ehci_dbg_info, ., 80, 1) |
Kyösti Mälkki | 3dd23a5 | 2019-08-22 15:06:50 +0300 | [diff] [blame] | 59 | |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 60 | /* _bss and _ebss provide symbols to per-stage |
Aaron Durbin | dd6fa93 | 2015-09-24 12:18:07 -0500 | [diff] [blame] | 61 | * 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 Heymans | fdb8b13 | 2019-11-28 14:00:01 +0100 | [diff] [blame] | 63 | * basis when more than one stage uses cache-as-ram. */ |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 64 | |
Jeremy Compostella | b7832de | 2023-08-30 15:42:09 -0700 | [diff] [blame] | 65 | #if ENV_SEPARATE_DATA_AND_BSS |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 66 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 67 | _bss = .; |
Kyösti Mälkki | a165c07 | 2019-08-22 09:44:44 +0300 | [diff] [blame] | 68 | /* Allow global uninitialized variables for stages without CAR teardown. */ |
Aaron Durbin | 76ab2b7 | 2018-10-30 12:15:10 -0600 | [diff] [blame] | 69 | *(.bss) |
| 70 | *(.bss.*) |
| 71 | *(.sbss) |
| 72 | *(.sbss.*) |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 73 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 74 | _ebss = .; |
Julius Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 75 | RECORD_SIZE(bss) |
Arthur Heymans | 9efb0c0 | 2020-11-30 14:03:51 +0100 | [diff] [blame] | 76 | #endif |
Andrey Petrov | dd56de9 | 2016-02-25 17:22:17 -0800 | [diff] [blame] | 77 | |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame] | 78 | #if ENV_SEPARATE_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE) |
Harshit Sharma | a6ebe08 | 2020-07-20 00:21:05 -0700 | [diff] [blame] | 79 | _shadow_size = (_ebss - _car_region_start) >> 3; |
| 80 | REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE) |
| 81 | #endif |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 82 | } |
Arthur Heymans | 7a5c369 | 2021-01-04 12:49:39 +0100 | [diff] [blame] | 83 | |
Jeremy Compostella | b7832de | 2023-08-30 15:42:09 -0700 | [diff] [blame] | 84 | #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 Heymans | 7a5c369 | 2021-01-04 12:49:39 +0100 | [diff] [blame] | 108 | . = _car_region_start; |
| 109 | .car.fspm_rc_heap . (NOLOAD) : { |
| 110 | . += CONFIG_FSP_M_RC_HEAP_SIZE; |
| 111 | } |
| 112 | |
Kyösti Mälkki | ed318f2 | 2019-01-11 21:07:36 +0200 | [diff] [blame] | 113 | . = _car_region_end; |
| 114 | .car.mrc_var . (NOLOAD) : { |
| 115 | . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE; |
| 116 | } |
Arthur Heymans | 9789689 | 2021-01-04 12:22:57 +0100 | [diff] [blame] | 117 | .car.fspt_reserved . (NOLOAD) : { |
| 118 | . += CONFIG_FSP_T_RESERVED_SIZE; |
| 119 | } |
| 120 | |
Kyösti Mälkki | ed318f2 | 2019-01-11 21:07:36 +0200 | [diff] [blame] | 121 | #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 Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 137 | |
Jeremy Compostella | b7832de | 2023-08-30 15:42:09 -0700 | [diff] [blame] | 138 | #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 Durbin | dd6fa93 | 2015-09-24 12:18:07 -0500 | [diff] [blame] | 141 | _bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full"); |
Jeremy Compostella | b7832de | 2023-08-30 15:42:09 -0700 | [diff] [blame] | 142 | #endif |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 143 | #if CONFIG(PAGING_IN_CACHE_AS_RAM) |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 144 | _bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned"); |
| 145 | #endif |
Patrick Rudolph | d72d52a | 2018-11-12 19:26:54 +0100 | [diff] [blame] | 146 | _bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured"); |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame] | 147 | #if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_SEPARATE_ROMSTAGE || ENV_SEPARATE_VERSTAGE) |
Arthur Heymans | c27628e | 2019-11-05 00:46:01 +0100 | [diff] [blame] | 148 | _bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !"); |
| 149 | _bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!"); |
| 150 | #endif |