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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 25 | #define ENV_SEPARATE_ROMSTAGE 0 |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 37 | #define ENV_SEPARATE_ROMSTAGE 0 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 49 | #define ENV_SEPARATE_ROMSTAGE 1 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 61 | #define ENV_SEPARATE_ROMSTAGE 0 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 75 | * code will have ENV_BOOTBLOCK or ENV_SEPARATE_ROMSTAGE set (depending on the |
Martin Roth | 0639bff | 2020-11-09 13:13:27 -0700 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 81 | #define ENV_SEPARATE_ROMSTAGE 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 97 | #define ENV_SEPARATE_ROMSTAGE 0 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 109 | #define ENV_SEPARATE_ROMSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 121 | #define ENV_SEPARATE_ROMSTAGE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 133 | #define ENV_SEPARATE_ROMSTAGE 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 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 |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 149 | #define ENV_SEPARATE_ROMSTAGE 0 |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 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 |
Patrick Rudolph | 5e5c1da | 2021-11-30 13:56:07 +0100 | [diff] [blame] | 167 | #define ENV_ARCH "armv4" |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 168 | #elif __COREBOOT_ARM_ARCH__ == 7 |
| 169 | #define ENV_ARMV4 0 |
| 170 | #define ENV_ARMV7 1 |
Patrick Rudolph | 5e5c1da | 2021-11-30 13:56:07 +0100 | [diff] [blame] | 171 | #define ENV_ARCH "armv7" |
Hakim Giydan | 43e5b57 | 2016-09-08 10:13:59 -0700 | [diff] [blame] | 172 | #if defined(__COREBOOT_ARM_V7_A__) |
| 173 | #define ENV_ARMV7_A 1 |
| 174 | #define ENV_ARMV7_M 0 |
| 175 | #define ENV_ARMV7_R 0 |
| 176 | #elif defined(__COREBOOT_ARM_V7_M__) |
| 177 | #define ENV_ARMV7_A 0 |
| 178 | #define ENV_ARMV7_M 1 |
| 179 | #define ENV_ARMV7_R 0 |
| 180 | #elif defined(__COREBOOT_ARM_V7_R__) |
| 181 | #define ENV_ARMV7_A 0 |
| 182 | #define ENV_ARMV7_M 0 |
| 183 | #define ENV_ARMV7_R 1 |
| 184 | #endif |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 185 | #else |
| 186 | #define ENV_ARMV4 0 |
| 187 | #define ENV_ARMV7 0 |
| 188 | #endif |
| 189 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 190 | #define ENV_RISCV 0 |
| 191 | #define ENV_X86 0 |
| 192 | #define ENV_X86_32 0 |
| 193 | #define ENV_X86_64 0 |
| 194 | |
| 195 | #elif defined(__ARCH_arm64__) |
| 196 | #define ENV_ARM 0 |
| 197 | #define ENV_ARM64 1 |
| 198 | #define ENV_ARMV4 0 |
| 199 | #define ENV_ARMV7 0 |
| 200 | #if __COREBOOT_ARM_ARCH__ == 8 |
| 201 | #define ENV_ARMV8 1 |
| 202 | #else |
| 203 | #define ENV_ARMV8 0 |
| 204 | #endif |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 205 | #define ENV_RISCV 0 |
| 206 | #define ENV_X86 0 |
| 207 | #define ENV_X86_32 0 |
| 208 | #define ENV_X86_64 0 |
Patrick Rudolph | 5e5c1da | 2021-11-30 13:56:07 +0100 | [diff] [blame] | 209 | #define ENV_ARCH "aarch64" |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 210 | |
| 211 | #elif defined(__ARCH_riscv__) |
| 212 | #define ENV_ARM 0 |
| 213 | #define ENV_ARM64 0 |
| 214 | #define ENV_ARMV4 0 |
| 215 | #define ENV_ARMV7 0 |
| 216 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 217 | #define ENV_RISCV 1 |
| 218 | #define ENV_X86 0 |
| 219 | #define ENV_X86_32 0 |
| 220 | #define ENV_X86_64 0 |
Patrick Rudolph | 5e5c1da | 2021-11-30 13:56:07 +0100 | [diff] [blame] | 221 | #define ENV_ARCH "riscv" |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 222 | |
| 223 | #elif defined(__ARCH_x86_32__) |
| 224 | #define ENV_ARM 0 |
| 225 | #define ENV_ARM64 0 |
| 226 | #define ENV_ARMV4 0 |
| 227 | #define ENV_ARMV7 0 |
| 228 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 229 | #define ENV_RISCV 0 |
| 230 | #define ENV_X86 1 |
| 231 | #define ENV_X86_32 1 |
| 232 | #define ENV_X86_64 0 |
Patrick Rudolph | 5e5c1da | 2021-11-30 13:56:07 +0100 | [diff] [blame] | 233 | #define ENV_ARCH "x86_32" |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 234 | |
| 235 | #elif defined(__ARCH_x86_64__) |
| 236 | #define ENV_ARM 0 |
| 237 | #define ENV_ARM64 0 |
| 238 | #define ENV_ARMV4 0 |
| 239 | #define ENV_ARMV7 0 |
| 240 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 241 | #define ENV_RISCV 0 |
| 242 | #define ENV_X86 1 |
| 243 | #define ENV_X86_32 0 |
| 244 | #define ENV_X86_64 1 |
Patrick Rudolph | 5e5c1da | 2021-11-30 13:56:07 +0100 | [diff] [blame] | 245 | #define ENV_ARCH "x86_64" |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 246 | |
| 247 | #else |
| 248 | #define ENV_ARM 0 |
| 249 | #define ENV_ARM64 0 |
| 250 | #define ENV_ARMV4 0 |
| 251 | #define ENV_ARMV7 0 |
| 252 | #define ENV_ARMV8 0 |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 253 | #define ENV_RISCV 0 |
| 254 | #define ENV_X86 0 |
| 255 | #define ENV_X86_32 0 |
| 256 | #define ENV_X86_64 0 |
Patrick Rudolph | 5e5c1da | 2021-11-30 13:56:07 +0100 | [diff] [blame] | 257 | #define ENV_ARCH "unknown" |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 258 | |
| 259 | #endif |
| 260 | |
Subrata Banik | 6302203 | 2019-05-11 20:12:20 +0530 | [diff] [blame] | 261 | #if CONFIG(RAMPAYLOAD) |
| 262 | /* ENV_PAYLOAD_LOADER is set to ENV_POSTCAR when CONFIG_RAMPAYLOAD is enabled */ |
| 263 | #define ENV_PAYLOAD_LOADER ENV_POSTCAR |
| 264 | #else |
Ronald G. Minnich | 4249348 | 2019-05-09 17:09:25 +0000 | [diff] [blame] | 265 | /* ENV_PAYLOAD_LOADER is set when you are in a stage that loads the payload. |
| 266 | * For now, that is the ramstage. */ |
| 267 | #define ENV_PAYLOAD_LOADER ENV_RAMSTAGE |
Subrata Banik | 6302203 | 2019-05-11 20:12:20 +0530 | [diff] [blame] | 268 | #endif |
Ronald G. Minnich | 4249348 | 2019-05-09 17:09:25 +0000 | [diff] [blame] | 269 | |
Kyösti Mälkki | 21160a7 | 2019-08-17 17:29:36 +0300 | [diff] [blame] | 270 | #define ENV_ROMSTAGE_OR_BEFORE \ |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 271 | (ENV_DECOMPRESSOR || ENV_BOOTBLOCK || ENV_SEPARATE_ROMSTAGE || \ |
Martin Roth | b9c2ecf | 2020-06-10 20:35:35 -0600 | [diff] [blame] | 272 | (ENV_SEPARATE_VERSTAGE && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE))) |
Kyösti Mälkki | 21160a7 | 2019-08-17 17:29:36 +0300 | [diff] [blame] | 273 | |
Kyösti Mälkki | 7336f97 | 2020-06-08 06:05:03 +0300 | [diff] [blame] | 274 | #if ENV_X86 |
Kyösti Mälkki | 21160a7 | 2019-08-17 17:29:36 +0300 | [diff] [blame] | 275 | /* Indicates memory layout is determined with arch/x86/car.ld. */ |
Martin Roth | 8418fd4 | 2019-04-22 16:26:23 -0600 | [diff] [blame] | 276 | #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] | 277 | #else |
Kyösti Mälkki | f2cc52b | 2019-08-21 07:15:38 +0300 | [diff] [blame] | 278 | #define ENV_CACHE_AS_RAM 0 |
| 279 | #endif |
| 280 | |
Jeremy Compostella | b7832de | 2023-08-30 15:42:09 -0700 | [diff] [blame] | 281 | /* Indicates if the stage uses the _data and _bss regions defined in |
| 282 | * arch/x86/car.ld */ |
| 283 | #define ENV_SEPARATE_DATA_AND_BSS (ENV_CACHE_AS_RAM && (ENV_BOOTBLOCK || !CONFIG(NO_XIP_EARLY_STAGES))) |
Arthur Heymans | 9efb0c0 | 2020-11-30 14:03:51 +0100 | [diff] [blame] | 284 | |
Kyösti Mälkki | f2cc52b | 2019-08-21 07:15:38 +0300 | [diff] [blame] | 285 | /* Currently rmodules, ramstage and smm have heap. */ |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 286 | #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] | 287 | |
Martin Roth | 44d5347 | 2020-07-23 18:27:58 -0600 | [diff] [blame] | 288 | /* Set USER_SPACE in the makefile for the rare code that runs in userspace */ |
| 289 | #if defined(__USER_SPACE__) |
| 290 | #define ENV_USER_SPACE 1 |
| 291 | #else |
| 292 | #define ENV_USER_SPACE 0 |
| 293 | #endif |
| 294 | |
Martin Roth | 1594e8f | 2020-07-15 13:57:54 -0600 | [diff] [blame] | 295 | /* Define the first stage to run */ |
| 296 | #if CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) |
| 297 | #define ENV_INITIAL_STAGE ENV_SEPARATE_VERSTAGE |
| 298 | #else |
| 299 | #define ENV_INITIAL_STAGE ENV_BOOTBLOCK |
| 300 | #endif |
| 301 | |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 302 | #define ENV_CREATES_CBMEM (ENV_SEPARATE_ROMSTAGE || (ENV_BOOTBLOCK && !CONFIG(SEPARATE_ROMSTAGE))) |
| 303 | #define ENV_HAS_CBMEM (ENV_CREATES_CBMEM || ENV_POSTCAR || ENV_RAMSTAGE) |
| 304 | #define ENV_RAMINIT (ENV_SEPARATE_ROMSTAGE || (ENV_BOOTBLOCK && !CONFIG(SEPARATE_ROMSTAGE))) |
Kyösti Mälkki | fa3bc04 | 2022-03-31 07:40:10 +0300 | [diff] [blame] | 305 | |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 306 | #if ENV_X86 |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 307 | #define ENV_HAS_SPINLOCKS !ENV_ROMSTAGE_OR_BEFORE |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 308 | #elif ENV_RISCV |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 309 | #define ENV_HAS_SPINLOCKS 1 |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 310 | #else |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 311 | #define ENV_HAS_SPINLOCKS 0 |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 312 | #endif |
| 313 | |
| 314 | /* When set <arch/smp/spinlock.h> is included for the spinlock implementation. */ |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 315 | #define ENV_SUPPORTS_SMP (CONFIG(SMP) && ENV_HAS_SPINLOCKS) |
Kyösti Mälkki | 04c3228 | 2021-11-10 03:10:58 +0200 | [diff] [blame] | 316 | |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame^] | 317 | #if ENV_X86 && CONFIG(COOP_MULTITASKING) && (ENV_RAMSTAGE || ENV_CREATES_CBMEM) |
Raul E Rangel | d8f07c1 | 2021-11-22 13:43:49 -0700 | [diff] [blame] | 318 | /* TODO: Enable in all x86 stages */ |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 319 | #define ENV_SUPPORTS_COOP 1 |
Raul E Rangel | d8f07c1 | 2021-11-22 13:43:49 -0700 | [diff] [blame] | 320 | #else |
Arthur Heymans | 6acc05e | 2022-05-12 18:01:13 +0200 | [diff] [blame] | 321 | #define ENV_SUPPORTS_COOP 0 |
Raul E Rangel | d8f07c1 | 2021-11-22 13:43:49 -0700 | [diff] [blame] | 322 | #endif |
| 323 | |
Patrick Rudolph | a626d27 | 2018-04-18 10:13:32 +0200 | [diff] [blame] | 324 | /** |
| 325 | * For pre-DRAM stages and post-CAR always build with simple device model, ie. |
| 326 | * PCI, PNP and CPU functions operate without use of devicetree. The reason |
| 327 | * post-CAR utilizes __SIMPLE_DEVICE__ is for simplicity. Currently there's |
| 328 | * no known requirement that devicetree would be needed during that stage. |
| 329 | * |
| 330 | * For ramstage individual source file may define __SIMPLE_DEVICE__ |
| 331 | * before including any header files to force that particular source |
| 332 | * be built with simple device model. |
Patrick Rudolph | a626d27 | 2018-04-18 10:13:32 +0200 | [diff] [blame] | 333 | */ |
| 334 | |
Kyösti Mälkki | 21160a7 | 2019-08-17 17:29:36 +0300 | [diff] [blame] | 335 | #if !ENV_RAMSTAGE |
Patrick Rudolph | a626d27 | 2018-04-18 10:13:32 +0200 | [diff] [blame] | 336 | #define __SIMPLE_DEVICE__ |
| 337 | #endif |
| 338 | |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 339 | #endif /* _RULES_H */ |