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 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 30 | #define ENV_STRING "bootblock" |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 31 | |
Patrick Georgi | 815f4bf | 2015-04-28 22:43:31 +0200 | [diff] [blame] | 32 | #elif defined(__ROMSTAGE__) |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 33 | #define ENV_BOOTBLOCK 0 |
| 34 | #define ENV_ROMSTAGE 1 |
| 35 | #define ENV_RAMSTAGE 0 |
| 36 | #define ENV_SMM 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 37 | #define ENV_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 38 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 39 | #define ENV_POSTCAR 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 40 | #define ENV_STRING "romstage" |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 41 | |
| 42 | #elif defined(__SMM__) |
| 43 | #define ENV_BOOTBLOCK 0 |
| 44 | #define ENV_ROMSTAGE 0 |
| 45 | #define ENV_RAMSTAGE 0 |
| 46 | #define ENV_SMM 1 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 47 | #define ENV_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 48 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 49 | #define ENV_POSTCAR 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 50 | #define ENV_STRING "smm" |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 51 | |
| 52 | #elif defined(__VERSTAGE__) |
| 53 | #define ENV_BOOTBLOCK 0 |
| 54 | #define ENV_ROMSTAGE 0 |
| 55 | #define ENV_RAMSTAGE 0 |
| 56 | #define ENV_SMM 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 57 | #define ENV_VERSTAGE 1 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 58 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 59 | #define ENV_POSTCAR 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 60 | #define ENV_STRING "verstage" |
Furquan Shaikh | abde3b5 | 2014-08-26 15:39:51 -0700 | [diff] [blame] | 61 | |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 62 | #elif defined(__RAMSTAGE__) |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 63 | #define ENV_BOOTBLOCK 0 |
| 64 | #define ENV_ROMSTAGE 0 |
| 65 | #define ENV_RAMSTAGE 1 |
| 66 | #define ENV_SMM 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 67 | #define ENV_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 68 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 69 | #define ENV_POSTCAR 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 70 | #define ENV_STRING "ramstage" |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 71 | |
| 72 | #elif defined(__RMODULE__) |
| 73 | #define ENV_BOOTBLOCK 0 |
| 74 | #define ENV_ROMSTAGE 0 |
| 75 | #define ENV_RAMSTAGE 0 |
| 76 | #define ENV_SMM 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 77 | #define ENV_VERSTAGE 0 |
| 78 | #define ENV_RMODULE 1 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 79 | #define ENV_POSTCAR 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 80 | #define ENV_STRING "rmodule" |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 81 | |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 82 | #elif defined(__POSTCAR__) |
| 83 | #define ENV_BOOTBLOCK 0 |
| 84 | #define ENV_ROMSTAGE 0 |
| 85 | #define ENV_RAMSTAGE 0 |
| 86 | #define ENV_SMM 0 |
| 87 | #define ENV_VERSTAGE 0 |
| 88 | #define ENV_RMODULE 0 |
| 89 | #define ENV_POSTCAR 1 |
| 90 | #define ENV_STRING "postcar" |
| 91 | |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 92 | #else |
| 93 | /* |
| 94 | * Default case of nothing set for random blob generation using |
| 95 | * create_class_compiler that isn't bound to a stage. Also AGESA |
| 96 | * apparently builds things compeletely separate from coreboot's |
| 97 | * build infrastructure -- hardcoding its own rules. |
| 98 | */ |
| 99 | #define ENV_BOOTBLOCK 0 |
| 100 | #define ENV_ROMSTAGE 0 |
| 101 | #define ENV_RAMSTAGE 0 |
| 102 | #define ENV_SMM 0 |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame] | 103 | #define ENV_VERSTAGE 0 |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 104 | #define ENV_RMODULE 0 |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 105 | #define ENV_POSTCAR 0 |
Ben Gardner | aa5f5b1 | 2015-11-19 10:48:47 -0600 | [diff] [blame] | 106 | #define ENV_STRING "UNKNOWN" |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 107 | #endif |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 108 | |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 109 | /* For pre-DRAM stages and post-CAR always build with simple device model, ie. |
| 110 | * PCI, PNP and CPU functions operate without use of devicetree. The reason |
| 111 | * post-CAR utilizes __SIMPLE_DEVICE__ is for simplicity. Currently there's |
| 112 | * 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] | 113 | * |
| 114 | * For ramstage individual source file may define __SIMPLE_DEVICE__ |
| 115 | * before including any header files to force that particular source |
| 116 | * be built with simple device model. |
| 117 | */ |
| 118 | |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 119 | #if defined(__PRE_RAM__) || ENV_SMM || ENV_POSTCAR |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 120 | #define __SIMPLE_DEVICE__ |
| 121 | #endif |
| 122 | |
Julius Werner | d3634c1 | 2015-11-13 13:28:41 -0800 | [diff] [blame] | 123 | /* Define helpers about the current architecture, based on toolchain.inc. */ |
| 124 | |
| 125 | #if defined(__ARCH_arm__) |
| 126 | #define ENV_ARM 1 |
| 127 | #define ENV_ARM64 0 |
| 128 | #if __COREBOOT_ARM_ARCH__ == 4 |
| 129 | #define ENV_ARMV4 1 |
| 130 | #define ENV_ARMV7 0 |
| 131 | #elif __COREBOOT_ARM_ARCH__ == 7 |
| 132 | #define ENV_ARMV4 0 |
| 133 | #define ENV_ARMV7 1 |
| 134 | #else |
| 135 | #define ENV_ARMV4 0 |
| 136 | #define ENV_ARMV7 0 |
| 137 | #endif |
| 138 | #define ENV_ARMV8 0 |
| 139 | #define ENV_MIPS 0 |
| 140 | #define ENV_RISCV 0 |
| 141 | #define ENV_X86 0 |
| 142 | #define ENV_X86_32 0 |
| 143 | #define ENV_X86_64 0 |
| 144 | |
| 145 | #elif defined(__ARCH_arm64__) |
| 146 | #define ENV_ARM 0 |
| 147 | #define ENV_ARM64 1 |
| 148 | #define ENV_ARMV4 0 |
| 149 | #define ENV_ARMV7 0 |
| 150 | #if __COREBOOT_ARM_ARCH__ == 8 |
| 151 | #define ENV_ARMV8 1 |
| 152 | #else |
| 153 | #define ENV_ARMV8 0 |
| 154 | #endif |
| 155 | #define ENV_MIPS 0 |
| 156 | #define ENV_RISCV 0 |
| 157 | #define ENV_X86 0 |
| 158 | #define ENV_X86_32 0 |
| 159 | #define ENV_X86_64 0 |
| 160 | |
| 161 | #elif defined(__ARCH_mips__) |
| 162 | #define ENV_ARM 0 |
| 163 | #define ENV_ARM64 0 |
| 164 | #define ENV_ARMV4 0 |
| 165 | #define ENV_ARMV7 0 |
| 166 | #define ENV_ARMV8 0 |
| 167 | #define ENV_MIPS 1 |
| 168 | #define ENV_RISCV 0 |
| 169 | #define ENV_X86 0 |
| 170 | #define ENV_X86_32 0 |
| 171 | #define ENV_X86_64 0 |
| 172 | |
| 173 | #elif defined(__ARCH_riscv__) |
| 174 | #define ENV_ARM 0 |
| 175 | #define ENV_ARM64 0 |
| 176 | #define ENV_ARMV4 0 |
| 177 | #define ENV_ARMV7 0 |
| 178 | #define ENV_ARMV8 0 |
| 179 | #define ENV_MIPS 0 |
| 180 | #define ENV_RISCV 1 |
| 181 | #define ENV_X86 0 |
| 182 | #define ENV_X86_32 0 |
| 183 | #define ENV_X86_64 0 |
| 184 | |
| 185 | #elif defined(__ARCH_x86_32__) |
| 186 | #define ENV_ARM 0 |
| 187 | #define ENV_ARM64 0 |
| 188 | #define ENV_ARMV4 0 |
| 189 | #define ENV_ARMV7 0 |
| 190 | #define ENV_ARMV8 0 |
| 191 | #define ENV_MIPS 0 |
| 192 | #define ENV_RISCV 0 |
| 193 | #define ENV_X86 1 |
| 194 | #define ENV_X86_32 1 |
| 195 | #define ENV_X86_64 0 |
| 196 | |
| 197 | #elif defined(__ARCH_x86_64__) |
| 198 | #define ENV_ARM 0 |
| 199 | #define ENV_ARM64 0 |
| 200 | #define ENV_ARMV4 0 |
| 201 | #define ENV_ARMV7 0 |
| 202 | #define ENV_ARMV8 0 |
| 203 | #define ENV_MIPS 0 |
| 204 | #define ENV_RISCV 0 |
| 205 | #define ENV_X86 1 |
| 206 | #define ENV_X86_32 0 |
| 207 | #define ENV_X86_64 1 |
| 208 | |
| 209 | #else |
| 210 | #define ENV_ARM 0 |
| 211 | #define ENV_ARM64 0 |
| 212 | #define ENV_ARMV4 0 |
| 213 | #define ENV_ARMV7 0 |
| 214 | #define ENV_ARMV8 0 |
| 215 | #define ENV_MIPS 0 |
| 216 | #define ENV_RISCV 0 |
| 217 | #define ENV_X86 0 |
| 218 | #define ENV_X86_32 0 |
| 219 | #define ENV_X86_64 0 |
| 220 | |
| 221 | #endif |
| 222 | |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 223 | #endif /* _RULES_H */ |