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. */ |
Joel Kitching | 0097f55 | 2019-02-21 12:36:55 +0800 | [diff] [blame] | 20 | VBOOT2_WORK(., 12K) |
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 | |
Kyösti Mälkki | f88208e | 2019-01-31 08:29:32 +0200 | [diff] [blame] | 54 | /* Reserve sizeof(struct ehci_dbg_info). */ |
Julius Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 55 | REGION(car_ehci_dbg_info, ., 80, 1) |
Kyösti Mälkki | 3dd23a5 | 2019-08-22 15:06:50 +0300 | [diff] [blame] | 56 | |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 57 | /* _bss and _ebss provide symbols to per-stage |
Aaron Durbin | dd6fa93 | 2015-09-24 12:18:07 -0500 | [diff] [blame] | 58 | * 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 Heymans | fdb8b13 | 2019-11-28 14:00:01 +0100 | [diff] [blame] | 60 | * basis when more than one stage uses cache-as-ram. */ |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 61 | |
Arthur Heymans | 9efb0c0 | 2020-11-30 14:03:51 +0100 | [diff] [blame] | 62 | #if ENV_SEPARATE_BSS |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 63 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 64 | _bss = .; |
Kyösti Mälkki | a165c07 | 2019-08-22 09:44:44 +0300 | [diff] [blame] | 65 | /* Allow global uninitialized variables for stages without CAR teardown. */ |
Aaron Durbin | 76ab2b7 | 2018-10-30 12:15:10 -0600 | [diff] [blame] | 66 | *(.bss) |
| 67 | *(.bss.*) |
| 68 | *(.sbss) |
| 69 | *(.sbss.*) |
Jeremy Compostella | 50139d0 | 2022-12-01 15:07:51 -0700 | [diff] [blame] | 70 | /* '*_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 Compostella | 765e5df | 2022-12-01 15:45:51 -0700 | [diff] [blame] | 76 | #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 Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 83 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 84 | _ebss = .; |
Julius Werner | 82d16b1 | 2020-12-30 15:51:10 -0800 | [diff] [blame] | 85 | RECORD_SIZE(bss) |
Arthur Heymans | 9efb0c0 | 2020-11-30 14:03:51 +0100 | [diff] [blame] | 86 | #endif |
Andrey Petrov | dd56de9 | 2016-02-25 17:22:17 -0800 | [diff] [blame] | 87 | |
Harshit Sharma | a6ebe08 | 2020-07-20 00:21:05 -0700 | [diff] [blame] | 88 | #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 Heymans | 9789689 | 2021-01-04 12:22:57 +0100 | [diff] [blame] | 93 | _car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start) |
| 94 | - CONFIG_FSP_T_RESERVED_SIZE; |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 95 | } |
Arthur Heymans | 7a5c369 | 2021-01-04 12:49:39 +0100 | [diff] [blame] | 96 | |
| 97 | . = _car_region_start; |
| 98 | .car.fspm_rc_heap . (NOLOAD) : { |
| 99 | . += CONFIG_FSP_M_RC_HEAP_SIZE; |
| 100 | } |
| 101 | |
Kyösti Mälkki | ed318f2 | 2019-01-11 21:07:36 +0200 | [diff] [blame] | 102 | . = _car_region_end; |
| 103 | .car.mrc_var . (NOLOAD) : { |
| 104 | . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE; |
| 105 | } |
Arthur Heymans | 9789689 | 2021-01-04 12:22:57 +0100 | [diff] [blame] | 106 | .car.fspt_reserved . (NOLOAD) : { |
| 107 | . += CONFIG_FSP_T_RESERVED_SIZE; |
| 108 | } |
| 109 | |
Kyösti Mälkki | ed318f2 | 2019-01-11 21:07:36 +0200 | [diff] [blame] | 110 | #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 Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 126 | |
| 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 Heymans | cd259cb | 2022-05-16 13:20:18 +0200 | [diff] [blame] | 134 | *(.data) |
| 135 | *(.data.*) |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 136 | } |
| 137 | |
Aaron Durbin | dd6fa93 | 2015-09-24 12:18:07 -0500 | [diff] [blame] | 138 | _bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full"); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 139 | #if CONFIG(PAGING_IN_CACHE_AS_RAM) |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 140 | _bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned"); |
| 141 | #endif |
Patrick Rudolph | d72d52a | 2018-11-12 19:26:54 +0100 | [diff] [blame] | 142 | _bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured"); |
Arthur Heymans | c3ca8ed | 2023-05-08 17:04:45 +0200 | [diff] [blame] | 143 | #if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_ROMSTAGE || ENV_SEPARATE_VERSTAGE) |
Arthur Heymans | c27628e | 2019-11-05 00:46:01 +0100 | [diff] [blame] | 144 | _bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !"); |
| 145 | _bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!"); |
| 146 | #endif |