Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 13 | */ |
| 14 | |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 15 | #ifndef _RULES_H |
| 16 | #define _RULES_H |
| 17 | |
| 18 | /* Useful helpers to tell whether the code is executing in bootblock, |
| 19 | * romstage, ramstage or SMM. |
| 20 | */ |
| 21 | |
Patrick Georgi | 56b8309 | 2015-04-02 19:44:19 +0200 | [diff] [blame] | 22 | #if defined(__BOOTBLOCK__) |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 23 | #define ENV_BOOTBLOCK 1 |
| 24 | #define ENV_ROMSTAGE 0 |
| 25 | #define ENV_RAMSTAGE 0 |
| 26 | #define ENV_SMM 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 27 | #define ENV_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 28 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 29 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 30 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 31 | #define ENV_STRING "bootblock" |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 32 | |
Patrick Georgi | 815f4bf | 2015-04-28 22:43:31 +0200 | [diff] [blame] | 33 | #elif defined(__ROMSTAGE__) |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 34 | #define ENV_BOOTBLOCK 0 |
| 35 | #define ENV_ROMSTAGE 1 |
| 36 | #define ENV_RAMSTAGE 0 |
| 37 | #define ENV_SMM 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 38 | #define ENV_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 39 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 40 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 41 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 42 | #define ENV_STRING "romstage" |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 43 | |
| 44 | #elif defined(__SMM__) |
| 45 | #define ENV_BOOTBLOCK 0 |
| 46 | #define ENV_ROMSTAGE 0 |
| 47 | #define ENV_RAMSTAGE 0 |
| 48 | #define ENV_SMM 1 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 49 | #define ENV_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 50 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 51 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 52 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 53 | #define ENV_STRING "smm" |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 54 | |
| 55 | #elif defined(__VERSTAGE__) |
| 56 | #define ENV_BOOTBLOCK 0 |
| 57 | #define ENV_ROMSTAGE 0 |
| 58 | #define ENV_RAMSTAGE 0 |
| 59 | #define ENV_SMM 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 60 | #define ENV_VERSTAGE 1 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 61 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 62 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 63 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 64 | #define ENV_STRING "verstage" |
Furquan Shaikh | abde3b5 | 2014-08-26 15:39:51 -0700 | [diff] [blame] | 65 | |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 66 | #elif defined(__RAMSTAGE__) |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 67 | #define ENV_BOOTBLOCK 0 |
| 68 | #define ENV_ROMSTAGE 0 |
| 69 | #define ENV_RAMSTAGE 1 |
| 70 | #define ENV_SMM 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 71 | #define ENV_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 72 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 73 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 74 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 75 | #define ENV_STRING "ramstage" |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 76 | |
| 77 | #elif defined(__RMODULE__) |
| 78 | #define ENV_BOOTBLOCK 0 |
| 79 | #define ENV_ROMSTAGE 0 |
| 80 | #define ENV_RAMSTAGE 0 |
| 81 | #define ENV_SMM 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 82 | #define ENV_VERSTAGE 0 |
| 83 | #define ENV_RMODULE 1 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 84 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 85 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 86 | #define ENV_STRING "rmodule" |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 87 | |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 88 | #elif defined(__POSTCAR__) |
| 89 | #define ENV_BOOTBLOCK 0 |
| 90 | #define ENV_ROMSTAGE 0 |
| 91 | #define ENV_RAMSTAGE 0 |
| 92 | #define ENV_SMM 0 |
| 93 | #define ENV_VERSTAGE 0 |
| 94 | #define ENV_RMODULE 0 |
| 95 | #define ENV_POSTCAR 1 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 96 | #define ENV_LIBAGESA 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 97 | #define ENV_STRING "postcar" |
| 98 | |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 99 | #elif defined(__LIBAGESA__) |
| 100 | #define ENV_BOOTBLOCK 0 |
| 101 | #define ENV_ROMSTAGE 0 |
| 102 | #define ENV_RAMSTAGE 0 |
| 103 | #define ENV_SMM 0 |
| 104 | #define ENV_VERSTAGE 0 |
| 105 | #define ENV_RMODULE 0 |
| 106 | #define ENV_POSTCAR 0 |
| 107 | #define ENV_LIBAGESA 1 |
| 108 | #define ENV_STRING "libagesa" |
| 109 | |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 110 | #else |
| 111 | /* |
| 112 | * Default case of nothing set for random blob generation using |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 113 | * create_class_compiler that isn't bound to a stage. |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 114 | */ |
| 115 | #define ENV_BOOTBLOCK 0 |
| 116 | #define ENV_ROMSTAGE 0 |
| 117 | #define ENV_RAMSTAGE 0 |
| 118 | #define ENV_SMM 0 |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 119 | #define ENV_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 120 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 121 | #define ENV_POSTCAR 0 |
Kyösti Mälkki | a405a58 | 2017-03-02 13:01:58 +0200 | [diff] [blame] | 122 | #define ENV_LIBAGESA 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 123 | #define ENV_STRING "UNKNOWN" |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 124 | #endif |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 125 | |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 126 | /* For pre-DRAM stages and post-CAR always build with simple device model, ie. |
| 127 | * PCI, PNP and CPU functions operate without use of devicetree. The reason |
| 128 | * post-CAR utilizes __SIMPLE_DEVICE__ is for simplicity. Currently there's |
| 129 | * no known requirement that devicetree would be needed during that stage. |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 130 | * |
| 131 | * For ramstage individual source file may define __SIMPLE_DEVICE__ |
| 132 | * before including any header files to force that particular source |
| 133 | * be built with simple device model. |
| 134 | */ |
| 135 | |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 136 | #if defined(__PRE_RAM__) || ENV_SMM || ENV_POSTCAR |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 137 | #define __SIMPLE_DEVICE__ |
| 138 | #endif |
| 139 | |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 140 | /* Define helpers about the current architecture, based on toolchain.inc. */ |
| 141 | |
| 142 | #if defined(__ARCH_arm__) |
| 143 | #define ENV_ARM 1 |
| 144 | #define ENV_ARM64 0 |
| 145 | #if __COREBOOT_ARM_ARCH__ == 4 |
| 146 | #define ENV_ARMV4 1 |
| 147 | #define ENV_ARMV7 0 |
| 148 | #elif __COREBOOT_ARM_ARCH__ == 7 |
| 149 | #define ENV_ARMV4 0 |
| 150 | #define ENV_ARMV7 1 |
Hakim Giydan | 43e5b57 | 2016-09-08 10:13:59 -0700 | [diff] [blame] | 151 | #if defined(__COREBOOT_ARM_V7_A__) |
| 152 | #define ENV_ARMV7_A 1 |
| 153 | #define ENV_ARMV7_M 0 |
| 154 | #define ENV_ARMV7_R 0 |
| 155 | #elif defined(__COREBOOT_ARM_V7_M__) |
| 156 | #define ENV_ARMV7_A 0 |
| 157 | #define ENV_ARMV7_M 1 |
| 158 | #define ENV_ARMV7_R 0 |
| 159 | #elif defined(__COREBOOT_ARM_V7_R__) |
| 160 | #define ENV_ARMV7_A 0 |
| 161 | #define ENV_ARMV7_M 0 |
| 162 | #define ENV_ARMV7_R 1 |
| 163 | #endif |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 164 | #else |
| 165 | #define ENV_ARMV4 0 |
| 166 | #define ENV_ARMV7 0 |
| 167 | #endif |
| 168 | #define ENV_ARMV8 0 |
| 169 | #define ENV_MIPS 0 |
| 170 | #define ENV_RISCV 0 |
| 171 | #define ENV_X86 0 |
| 172 | #define ENV_X86_32 0 |
| 173 | #define ENV_X86_64 0 |
| 174 | |
| 175 | #elif defined(__ARCH_arm64__) |
| 176 | #define ENV_ARM 0 |
| 177 | #define ENV_ARM64 1 |
| 178 | #define ENV_ARMV4 0 |
| 179 | #define ENV_ARMV7 0 |
| 180 | #if __COREBOOT_ARM_ARCH__ == 8 |
| 181 | #define ENV_ARMV8 1 |
| 182 | #else |
| 183 | #define ENV_ARMV8 0 |
| 184 | #endif |
| 185 | #define ENV_MIPS 0 |
| 186 | #define ENV_RISCV 0 |
| 187 | #define ENV_X86 0 |
| 188 | #define ENV_X86_32 0 |
| 189 | #define ENV_X86_64 0 |
| 190 | |
| 191 | #elif defined(__ARCH_mips__) |
| 192 | #define ENV_ARM 0 |
| 193 | #define ENV_ARM64 0 |
| 194 | #define ENV_ARMV4 0 |
| 195 | #define ENV_ARMV7 0 |
| 196 | #define ENV_ARMV8 0 |
| 197 | #define ENV_MIPS 1 |
| 198 | #define ENV_RISCV 0 |
| 199 | #define ENV_X86 0 |
| 200 | #define ENV_X86_32 0 |
| 201 | #define ENV_X86_64 0 |
| 202 | |
| 203 | #elif defined(__ARCH_riscv__) |
| 204 | #define ENV_ARM 0 |
| 205 | #define ENV_ARM64 0 |
| 206 | #define ENV_ARMV4 0 |
| 207 | #define ENV_ARMV7 0 |
| 208 | #define ENV_ARMV8 0 |
| 209 | #define ENV_MIPS 0 |
| 210 | #define ENV_RISCV 1 |
| 211 | #define ENV_X86 0 |
| 212 | #define ENV_X86_32 0 |
| 213 | #define ENV_X86_64 0 |
| 214 | |
| 215 | #elif defined(__ARCH_x86_32__) |
| 216 | #define ENV_ARM 0 |
| 217 | #define ENV_ARM64 0 |
| 218 | #define ENV_ARMV4 0 |
| 219 | #define ENV_ARMV7 0 |
| 220 | #define ENV_ARMV8 0 |
| 221 | #define ENV_MIPS 0 |
| 222 | #define ENV_RISCV 0 |
| 223 | #define ENV_X86 1 |
| 224 | #define ENV_X86_32 1 |
| 225 | #define ENV_X86_64 0 |
| 226 | |
| 227 | #elif defined(__ARCH_x86_64__) |
| 228 | #define ENV_ARM 0 |
| 229 | #define ENV_ARM64 0 |
| 230 | #define ENV_ARMV4 0 |
| 231 | #define ENV_ARMV7 0 |
| 232 | #define ENV_ARMV8 0 |
| 233 | #define ENV_MIPS 0 |
| 234 | #define ENV_RISCV 0 |
| 235 | #define ENV_X86 1 |
| 236 | #define ENV_X86_32 0 |
| 237 | #define ENV_X86_64 1 |
| 238 | |
| 239 | #else |
| 240 | #define ENV_ARM 0 |
| 241 | #define ENV_ARM64 0 |
| 242 | #define ENV_ARMV4 0 |
| 243 | #define ENV_ARMV7 0 |
| 244 | #define ENV_ARMV8 0 |
| 245 | #define ENV_MIPS 0 |
| 246 | #define ENV_RISCV 0 |
| 247 | #define ENV_X86 0 |
| 248 | #define ENV_X86_32 0 |
| 249 | #define ENV_X86_64 0 |
| 250 | |
| 251 | #endif |
| 252 | |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 253 | #endif /* _RULES_H */ |