Angel Pons | 32859fc | 2020-04-02 23:48:27 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 2 | |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 3 | #ifndef _RULES_H |
| 4 | #define _RULES_H |
| 5 | |
Jakub Czapiga | 084ad93 | 2021-03-25 13:10:31 +0100 | [diff] [blame] | 6 | #if defined(__TEST__) |
| 7 | #define ENV_TEST 1 |
| 8 | #else |
| 9 | #define ENV_TEST 0 |
| 10 | #endif |
| 11 | |
Angel Pons | 4645197 | 2020-06-08 15:52:03 +0200 | [diff] [blame] | 12 | #if defined(__TIMELESS__) |
| 13 | #define ENV_TIMELESS 1 |
| 14 | #else |
| 15 | #define ENV_TIMELESS 0 |
| 16 | #endif |
| 17 | |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 18 | /* Useful helpers to tell whether the code is executing in bootblock, |
| 19 | * romstage, ramstage or SMM. |
| 20 | */ |
| 21 | |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 22 | #if defined(__DECOMPRESSOR__) |
| 23 | #define ENV_DECOMPRESSOR 1 |
| 24 | #define ENV_BOOTBLOCK 0 |
| 25 | #define ENV_ROMSTAGE 0 |
| 26 | #define ENV_RAMSTAGE 0 |
| 27 | #define ENV_SMM 0 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 28 | #define ENV_SEPARATE_VERSTAGE 0 |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 29 | #define ENV_RMODULE 0 |
| 30 | #define ENV_POSTCAR 0 |
| 31 | #define ENV_LIBAGESA 0 |
| 32 | #define ENV_STRING "decompressor" |
| 33 | |
| 34 | #elif defined(__BOOTBLOCK__) |
| 35 | #define ENV_DECOMPRESSOR 0 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 36 | #define ENV_BOOTBLOCK 1 |
| 37 | #define ENV_ROMSTAGE 0 |
| 38 | #define ENV_RAMSTAGE 0 |
| 39 | #define ENV_SMM 0 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 40 | #define ENV_SEPARATE_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 41 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 42 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 43 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 44 | #define ENV_STRING "bootblock" |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 45 | |
Patrick Georgi | 815f4bf | 2015-04-28 22:43:31 +0200 | [diff] [blame] | 46 | #elif defined(__ROMSTAGE__) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 47 | #define ENV_DECOMPRESSOR 0 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 48 | #define ENV_BOOTBLOCK 0 |
| 49 | #define ENV_ROMSTAGE 1 |
| 50 | #define ENV_RAMSTAGE 0 |
| 51 | #define ENV_SMM 0 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 52 | #define ENV_SEPARATE_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 53 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 54 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 55 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 56 | #define ENV_STRING "romstage" |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 57 | |
| 58 | #elif defined(__SMM__) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 59 | #define ENV_DECOMPRESSOR 0 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 60 | #define ENV_BOOTBLOCK 0 |
| 61 | #define ENV_ROMSTAGE 0 |
| 62 | #define ENV_RAMSTAGE 0 |
| 63 | #define ENV_SMM 1 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 64 | #define ENV_SEPARATE_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 65 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 66 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 67 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 68 | #define ENV_STRING "smm" |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 69 | |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 70 | /* |
| 71 | * NOTE: "verstage" code may either run as a separate stage or linked into the |
Martin Roth | 0639bff | 2020-11-09 13:13:27 -0700 | [diff] [blame] | 72 | * bootblock/romstage, depending on the setting of the VBOOT_SEPARATE_VERSTAGE |
| 73 | * kconfig option. The ENV_SEPARATE_VERSTAGE macro will only return true for |
| 74 | * "verstage" code when CONFIG(VBOOT_SEPARATE_VERSTAGE) is true, otherwise that |
| 75 | * code will have ENV_BOOTBLOCK or ENV_ROMSTAGE set (depending on the |
| 76 | * "VBOOT_STARTS_IN_"... kconfig options). |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 77 | */ |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 78 | #elif defined(__VERSTAGE__) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 79 | #define ENV_DECOMPRESSOR 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 80 | #define ENV_BOOTBLOCK 0 |
| 81 | #define ENV_ROMSTAGE 0 |
| 82 | #define ENV_RAMSTAGE 0 |
| 83 | #define ENV_SMM 0 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 84 | #define ENV_SEPARATE_VERSTAGE 1 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 85 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 86 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 87 | #define ENV_LIBAGESA 0 |
Kangheui Won | 4b5c8b5 | 2020-10-07 14:29:38 +1100 | [diff] [blame] | 88 | #if CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) |
| 89 | #define ENV_STRING "verstage-before-bootblock" |
| 90 | #else |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 91 | #define ENV_STRING "verstage" |
Kangheui Won | 4b5c8b5 | 2020-10-07 14:29:38 +1100 | [diff] [blame] | 92 | #endif |
Furquan Shaikh | abde3b5 | 2014-08-26 15:39:51 -0700 | [diff] [blame] | 93 | |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 94 | #elif defined(__RAMSTAGE__) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 95 | #define ENV_DECOMPRESSOR 0 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 96 | #define ENV_BOOTBLOCK 0 |
| 97 | #define ENV_ROMSTAGE 0 |
| 98 | #define ENV_RAMSTAGE 1 |
| 99 | #define ENV_SMM 0 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 100 | #define ENV_SEPARATE_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 101 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 102 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 103 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 104 | #define ENV_STRING "ramstage" |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 105 | |
| 106 | #elif defined(__RMODULE__) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 107 | #define ENV_DECOMPRESSOR 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 108 | #define ENV_BOOTBLOCK 0 |
| 109 | #define ENV_ROMSTAGE 0 |
| 110 | #define ENV_RAMSTAGE 0 |
| 111 | #define ENV_SMM 0 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 112 | #define ENV_SEPARATE_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 113 | #define ENV_RMODULE 1 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 114 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 115 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 116 | #define ENV_STRING "rmodule" |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 117 | |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 118 | #elif defined(__POSTCAR__) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 119 | #define ENV_DECOMPRESSOR 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 120 | #define ENV_BOOTBLOCK 0 |
| 121 | #define ENV_ROMSTAGE 0 |
| 122 | #define ENV_RAMSTAGE 0 |
| 123 | #define ENV_SMM 0 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 124 | #define ENV_SEPARATE_VERSTAGE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 125 | #define ENV_RMODULE 0 |
| 126 | #define ENV_POSTCAR 1 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 127 | #define ENV_LIBAGESA 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 128 | #define ENV_STRING "postcar" |
| 129 | |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 130 | #elif defined(__LIBAGESA__) |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 131 | #define ENV_DECOMPRESSOR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 132 | #define ENV_BOOTBLOCK 0 |
| 133 | #define ENV_ROMSTAGE 0 |
| 134 | #define ENV_RAMSTAGE 0 |
| 135 | #define ENV_SMM 0 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 136 | #define ENV_SEPARATE_VERSTAGE 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 137 | #define ENV_RMODULE 0 |
| 138 | #define ENV_POSTCAR 0 |
| 139 | #define ENV_LIBAGESA 1 |
| 140 | #define ENV_STRING "libagesa" |
| 141 | |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 142 | #else |
| 143 | /* |
| 144 | * Default case of nothing set for random blob generation using |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 145 | * create_class_compiler that isn't bound to a stage. |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 146 | */ |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 147 | #define ENV_DECOMPRESSOR 0 |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 148 | #define ENV_BOOTBLOCK 0 |
| 149 | #define ENV_ROMSTAGE 0 |
| 150 | #define ENV_RAMSTAGE 0 |
| 151 | #define ENV_SMM 0 |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 152 | #define ENV_SEPARATE_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 153 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 154 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 155 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 156 | #define ENV_STRING "UNKNOWN" |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 157 | #endif |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 158 | |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 159 | /* Define helpers about the current architecture, based on toolchain.inc. */ |
| 160 | |
| 161 | #if defined(__ARCH_arm__) |
| 162 | #define ENV_ARM 1 |
| 163 | #define ENV_ARM64 0 |
| 164 | #if __COREBOOT_ARM_ARCH__ == 4 |
| 165 | #define ENV_ARMV4 1 |
| 166 | #define ENV_ARMV7 0 |
| 167 | #elif __COREBOOT_ARM_ARCH__ == 7 |
| 168 | #define ENV_ARMV4 0 |
| 169 | #define ENV_ARMV7 1 |
Hakim Giydan | 43e5b57 | 2016-09-08 10:13:59 -0700 | [diff] [blame] | 170 | #if defined(__COREBOOT_ARM_V7_A__) |
| 171 | #define ENV_ARMV7_A 1 |
| 172 | #define ENV_ARMV7_M 0 |
| 173 | #define ENV_ARMV7_R 0 |
| 174 | #elif defined(__COREBOOT_ARM_V7_M__) |
| 175 | #define ENV_ARMV7_A 0 |
| 176 | #define ENV_ARMV7_M 1 |
| 177 | #define ENV_ARMV7_R 0 |
| 178 | #elif defined(__COREBOOT_ARM_V7_R__) |
| 179 | #define ENV_ARMV7_A 0 |
| 180 | #define ENV_ARMV7_M 0 |
| 181 | #define ENV_ARMV7_R 1 |
| 182 | #endif |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 183 | #else |
| 184 | #define ENV_ARMV4 0 |
| 185 | #define ENV_ARMV7 0 |
| 186 | #endif |
| 187 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 188 | #define ENV_RISCV 0 |
| 189 | #define ENV_X86 0 |
| 190 | #define ENV_X86_32 0 |
| 191 | #define ENV_X86_64 0 |
| 192 | |
| 193 | #elif defined(__ARCH_arm64__) |
| 194 | #define ENV_ARM 0 |
| 195 | #define ENV_ARM64 1 |
| 196 | #define ENV_ARMV4 0 |
| 197 | #define ENV_ARMV7 0 |
| 198 | #if __COREBOOT_ARM_ARCH__ == 8 |
| 199 | #define ENV_ARMV8 1 |
| 200 | #else |
| 201 | #define ENV_ARMV8 0 |
| 202 | #endif |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 203 | #define ENV_RISCV 0 |
| 204 | #define ENV_X86 0 |
| 205 | #define ENV_X86_32 0 |
| 206 | #define ENV_X86_64 0 |
| 207 | |
| 208 | #elif defined(__ARCH_riscv__) |
| 209 | #define ENV_ARM 0 |
| 210 | #define ENV_ARM64 0 |
| 211 | #define ENV_ARMV4 0 |
| 212 | #define ENV_ARMV7 0 |
| 213 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 214 | #define ENV_RISCV 1 |
| 215 | #define ENV_X86 0 |
| 216 | #define ENV_X86_32 0 |
| 217 | #define ENV_X86_64 0 |
| 218 | |
| 219 | #elif defined(__ARCH_x86_32__) |
| 220 | #define ENV_ARM 0 |
| 221 | #define ENV_ARM64 0 |
| 222 | #define ENV_ARMV4 0 |
| 223 | #define ENV_ARMV7 0 |
| 224 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 225 | #define ENV_RISCV 0 |
| 226 | #define ENV_X86 1 |
| 227 | #define ENV_X86_32 1 |
| 228 | #define ENV_X86_64 0 |
| 229 | |
| 230 | #elif defined(__ARCH_x86_64__) |
| 231 | #define ENV_ARM 0 |
| 232 | #define ENV_ARM64 0 |
| 233 | #define ENV_ARMV4 0 |
| 234 | #define ENV_ARMV7 0 |
| 235 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 236 | #define ENV_RISCV 0 |
| 237 | #define ENV_X86 1 |
| 238 | #define ENV_X86_32 0 |
| 239 | #define ENV_X86_64 1 |
| 240 | |
| 241 | #else |
| 242 | #define ENV_ARM 0 |
| 243 | #define ENV_ARM64 0 |
| 244 | #define ENV_ARMV4 0 |
| 245 | #define ENV_ARMV7 0 |
| 246 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 247 | #define ENV_RISCV 0 |
| 248 | #define ENV_X86 0 |
| 249 | #define ENV_X86_32 0 |
| 250 | #define ENV_X86_64 0 |
| 251 | |
| 252 | #endif |
| 253 | |
Subrata Banik | 6302203 | 2019-05-11 20:12:20 +0530 | [diff] [blame] | 254 | #if CONFIG(RAMPAYLOAD) |
| 255 | /* ENV_PAYLOAD_LOADER is set to ENV_POSTCAR when CONFIG_RAMPAYLOAD is enabled */ |
| 256 | #define ENV_PAYLOAD_LOADER ENV_POSTCAR |
| 257 | #else |
Ronald G. Minnich | 4249348 | 2019-05-09 17:09:25 +0000 | [diff] [blame] | 258 | /* ENV_PAYLOAD_LOADER is set when you are in a stage that loads the payload. |
| 259 | * For now, that is the ramstage. */ |
| 260 | #define ENV_PAYLOAD_LOADER ENV_RAMSTAGE |
Subrata Banik | 6302203 | 2019-05-11 20:12:20 +0530 | [diff] [blame] | 261 | #endif |
Ronald G. Minnich | 4249348 | 2019-05-09 17:09:25 +0000 | [diff] [blame] | 262 | |
Kyösti Mälkki | 21160a7 | 2019-08-17 17:29:36 +0300 | [diff] [blame] | 263 | #define ENV_ROMSTAGE_OR_BEFORE \ |
Kyösti Mälkki | f704b54 | 2019-09-14 14:59:38 +0300 | [diff] [blame] | 264 | (ENV_DECOMPRESSOR || ENV_BOOTBLOCK || ENV_ROMSTAGE || \ |
Martin Roth | b9c2ecf | 2020-06-10 20:35:35 -0600 | [diff] [blame] | 265 | (ENV_SEPARATE_VERSTAGE && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE))) |
Kyösti Mälkki | 21160a7 | 2019-08-17 17:29:36 +0300 | [diff] [blame] | 266 | |
Kyösti Mälkki | 7336f97 | 2020-06-08 06:05:03 +0300 | [diff] [blame] | 267 | #if ENV_X86 |
Kyösti Mälkki | 21160a7 | 2019-08-17 17:29:36 +0300 | [diff] [blame] | 268 | /* Indicates memory layout is determined with arch/x86/car.ld. */ |
Martin Roth | 8418fd4 | 2019-04-22 16:26:23 -0600 | [diff] [blame] | 269 | #define ENV_CACHE_AS_RAM (ENV_ROMSTAGE_OR_BEFORE && !CONFIG(RESET_VECTOR_IN_RAM)) |
Kyösti Mälkki | f2cc52b | 2019-08-21 07:15:38 +0300 | [diff] [blame] | 270 | /* No .data sections with execute-in-place from ROM. */ |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 271 | #define ENV_HAS_DATA_SECTION !ENV_CACHE_AS_RAM |
Kyösti Mälkki | f2cc52b | 2019-08-21 07:15:38 +0300 | [diff] [blame] | 272 | #else |
| 273 | /* Both .data and .bss, sometimes SRAM not DRAM. */ |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 274 | #define ENV_HAS_DATA_SECTION 1 |
Kyösti Mälkki | f2cc52b | 2019-08-21 07:15:38 +0300 | [diff] [blame] | 275 | #define ENV_CACHE_AS_RAM 0 |
| 276 | #endif |
| 277 | |
| 278 | /* Currently rmodules, ramstage and smm have heap. */ |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 279 | #define ENV_HAS_HEAP_SECTION (ENV_RMODULE || ENV_RAMSTAGE || ENV_SMM) |
Kyösti Mälkki | f2cc52b | 2019-08-21 07:15:38 +0300 | [diff] [blame] | 280 | |
Martin Roth | 44d5347 | 2020-07-23 18:27:58 -0600 | [diff] [blame] | 281 | /* Set USER_SPACE in the makefile for the rare code that runs in userspace */ |
| 282 | #if defined(__USER_SPACE__) |
| 283 | #define ENV_USER_SPACE 1 |
| 284 | #else |
| 285 | #define ENV_USER_SPACE 0 |
| 286 | #endif |
| 287 | |
Martin Roth | 1594e8f | 2020-07-15 13:57:54 -0600 | [diff] [blame] | 288 | /* Define the first stage to run */ |
| 289 | #if CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) |
| 290 | #define ENV_INITIAL_STAGE ENV_SEPARATE_VERSTAGE |
| 291 | #else |
| 292 | #define ENV_INITIAL_STAGE ENV_BOOTBLOCK |
| 293 | #endif |
| 294 | |
Kyösti Mälkki | fa3bc04 | 2022-03-31 07:40:10 +0300 | [diff] [blame] | 295 | #define ENV_CREATES_CBMEM ENV_ROMSTAGE |
| 296 | #define ENV_HAS_CBMEM (ENV_ROMSTAGE | ENV_POSTCAR | ENV_RAMSTAGE) |
| 297 | |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 298 | #if ENV_X86 |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 299 | #define ENV_HAS_SPINLOCKS !ENV_ROMSTAGE_OR_BEFORE |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 300 | #elif ENV_RISCV |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 301 | #define ENV_HAS_SPINLOCKS 1 |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 302 | #else |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 303 | #define ENV_HAS_SPINLOCKS 0 |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 304 | #endif |
| 305 | |
| 306 | /* When set <arch/smp/spinlock.h> is included for the spinlock implementation. */ |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 307 | #define ENV_SUPPORTS_SMP (CONFIG(SMP) && ENV_HAS_SPINLOCKS) |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 308 | |
Raul E Rangel | d8f07c1 | 2021-11-22 13:43:49 -0700 | [diff] [blame] | 309 | #if ENV_X86 && CONFIG(COOP_MULTITASKING) && (ENV_RAMSTAGE || ENV_ROMSTAGE) |
| 310 | /* TODO: Enable in all x86 stages */ |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 311 | #define ENV_SUPPORTS_COOP 1 |
Raul E Rangel | d8f07c1 | 2021-11-22 13:43:49 -0700 | [diff] [blame] | 312 | #else |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 313 | #define ENV_SUPPORTS_COOP 0 |
Raul E Rangel | d8f07c1 | 2021-11-22 13:43:49 -0700 | [diff] [blame] | 314 | #endif |
| 315 | |
Patrick Rudolph | a626d27 | 2018-04-18 10:13:32 +0200 | [diff] [blame] | 316 | /** |
| 317 | * For pre-DRAM stages and post-CAR always build with simple device model, ie. |
| 318 | * PCI, PNP and CPU functions operate without use of devicetree. The reason |
| 319 | * post-CAR utilizes __SIMPLE_DEVICE__ is for simplicity. Currently there's |
| 320 | * no known requirement that devicetree would be needed during that stage. |
| 321 | * |
| 322 | * For ramstage individual source file may define __SIMPLE_DEVICE__ |
| 323 | * before including any header files to force that particular source |
| 324 | * be built with simple device model. |
Patrick Rudolph | a626d27 | 2018-04-18 10:13:32 +0200 | [diff] [blame] | 325 | */ |
| 326 | |
Kyösti Mälkki | 21160a7 | 2019-08-17 17:29:36 +0300 | [diff] [blame] | 327 | #if !ENV_RAMSTAGE |
Patrick Rudolph | a626d27 | 2018-04-18 10:13:32 +0200 | [diff] [blame] | 328 | #define __SIMPLE_DEVICE__ |
| 329 | #endif |
| 330 | |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 331 | #endif /* _RULES_H */ |