1 /* SPDX-License-Identifier: GPL-2.0-only */
12 #if defined(__TIMELESS__)
13 #define ENV_TIMELESS 1
15 #define ENV_TIMELESS 0
18 /* Useful helpers to tell whether the code is executing in bootblock,
19 * romstage, ramstage or SMM.
22 #if defined(__DECOMPRESSOR__)
23 #define ENV_DECOMPRESSOR 1
24 #define ENV_BOOTBLOCK 0
25 #define ENV_ROMSTAGE 0
26 #define ENV_RAMSTAGE 0
28 #define ENV_SEPARATE_VERSTAGE 0
31 #define ENV_LIBAGESA 0
32 #define ENV_STRING "decompressor"
34 #elif defined(__BOOTBLOCK__)
35 #define ENV_DECOMPRESSOR 0
36 #define ENV_BOOTBLOCK 1
37 #define ENV_ROMSTAGE 0
38 #define ENV_RAMSTAGE 0
40 #define ENV_SEPARATE_VERSTAGE 0
43 #define ENV_LIBAGESA 0
44 #define ENV_STRING "bootblock"
46 #elif defined(__ROMSTAGE__)
47 #define ENV_DECOMPRESSOR 0
48 #define ENV_BOOTBLOCK 0
49 #define ENV_ROMSTAGE 1
50 #define ENV_RAMSTAGE 0
52 #define ENV_SEPARATE_VERSTAGE 0
55 #define ENV_LIBAGESA 0
56 #define ENV_STRING "romstage"
58 #elif defined(__SMM__)
59 #define ENV_DECOMPRESSOR 0
60 #define ENV_BOOTBLOCK 0
61 #define ENV_ROMSTAGE 0
62 #define ENV_RAMSTAGE 0
64 #define ENV_SEPARATE_VERSTAGE 0
67 #define ENV_LIBAGESA 0
68 #define ENV_STRING "smm"
71 * NOTE: "verstage" code may either run as a separate stage or linked into the
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).
78 #elif defined(__VERSTAGE__)
79 #define ENV_DECOMPRESSOR 0
80 #define ENV_BOOTBLOCK 0
81 #define ENV_ROMSTAGE 0
82 #define ENV_RAMSTAGE 0
84 #define ENV_SEPARATE_VERSTAGE 1
87 #define ENV_LIBAGESA 0
88 #if CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)
89 #define ENV_STRING "verstage-before-bootblock"
91 #define ENV_STRING "verstage"
94 #elif defined(__RAMSTAGE__)
95 #define ENV_DECOMPRESSOR 0
96 #define ENV_BOOTBLOCK 0
97 #define ENV_ROMSTAGE 0
98 #define ENV_RAMSTAGE 1
100 #define ENV_SEPARATE_VERSTAGE 0
101 #define ENV_RMODULE 0
102 #define ENV_POSTCAR 0
103 #define ENV_LIBAGESA 0
104 #define ENV_STRING "ramstage"
106 #elif defined(__RMODULE__)
107 #define ENV_DECOMPRESSOR 0
108 #define ENV_BOOTBLOCK 0
109 #define ENV_ROMSTAGE 0
110 #define ENV_RAMSTAGE 0
112 #define ENV_SEPARATE_VERSTAGE 0
113 #define ENV_RMODULE 1
114 #define ENV_POSTCAR 0
115 #define ENV_LIBAGESA 0
116 #define ENV_STRING "rmodule"
118 #elif defined(__POSTCAR__)
119 #define ENV_DECOMPRESSOR 0
120 #define ENV_BOOTBLOCK 0
121 #define ENV_ROMSTAGE 0
122 #define ENV_RAMSTAGE 0
124 #define ENV_SEPARATE_VERSTAGE 0
125 #define ENV_RMODULE 0
126 #define ENV_POSTCAR 1
127 #define ENV_LIBAGESA 0
128 #define ENV_STRING "postcar"
130 #elif defined(__LIBAGESA__)
131 #define ENV_DECOMPRESSOR 0
132 #define ENV_BOOTBLOCK 0
133 #define ENV_ROMSTAGE 0
134 #define ENV_RAMSTAGE 0
136 #define ENV_SEPARATE_VERSTAGE 0
137 #define ENV_RMODULE 0
138 #define ENV_POSTCAR 0
139 #define ENV_LIBAGESA 1
140 #define ENV_STRING "libagesa"
144 * Default case of nothing set for random blob generation using
145 * create_class_compiler that isn't bound to a stage.
147 #define ENV_DECOMPRESSOR 0
148 #define ENV_BOOTBLOCK 0
149 #define ENV_ROMSTAGE 0
150 #define ENV_RAMSTAGE 0
152 #define ENV_SEPARATE_VERSTAGE 0
153 #define ENV_RMODULE 0
154 #define ENV_POSTCAR 0
155 #define ENV_LIBAGESA 0
156 #define ENV_STRING "UNKNOWN"
159 /* Define helpers about the current architecture, based on toolchain.inc. */
161 #if defined(__ARCH_arm__)
164 #if __COREBOOT_ARM_ARCH__ == 4
167 #elif __COREBOOT_ARM_ARCH__ == 7
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
193 #elif defined(__ARCH_arm64__)
198 #if __COREBOOT_ARM_ARCH__ == 8
208 #elif defined(__ARCH_riscv__)
219 #elif defined(__ARCH_x86_32__)
230 #elif defined(__ARCH_x86_64__)
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
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
263 #define ENV_ROMSTAGE_OR_BEFORE \
264 (ENV_DECOMPRESSOR || ENV_BOOTBLOCK || ENV_ROMSTAGE || \
265 (ENV_SEPARATE_VERSTAGE && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE)))
268 /* Indicates memory layout is determined with arch/x86/car.ld. */
269 #define ENV_CACHE_AS_RAM (ENV_ROMSTAGE_OR_BEFORE && !CONFIG(RESET_VECTOR_IN_RAM))
270 /* No .data sections with execute-in-place from ROM. */
271 #define ENV_HAS_DATA_SECTION !ENV_CACHE_AS_RAM
273 /* Both .data and .bss, sometimes SRAM not DRAM. */
274 #define ENV_HAS_DATA_SECTION 1
275 #define ENV_CACHE_AS_RAM 0
278 /* Currently rmodules, ramstage and smm have heap. */
279 #define ENV_HAS_HEAP_SECTION (ENV_RMODULE || ENV_RAMSTAGE || ENV_SMM)
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
285 #define ENV_USER_SPACE 0
288 /* Define the first stage to run */
289 #if CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)
290 #define ENV_INITIAL_STAGE ENV_SEPARATE_VERSTAGE
292 #define ENV_INITIAL_STAGE ENV_BOOTBLOCK
295 #define ENV_CREATES_CBMEM ENV_ROMSTAGE
296 #define ENV_HAS_CBMEM (ENV_ROMSTAGE | ENV_POSTCAR | ENV_RAMSTAGE)
297 #define ENV_RAMINIT ENV_ROMSTAGE
300 #define ENV_HAS_SPINLOCKS !ENV_ROMSTAGE_OR_BEFORE
302 #define ENV_HAS_SPINLOCKS 1
304 #define ENV_HAS_SPINLOCKS 0
307 /* When set <arch/smp/spinlock.h> is included for the spinlock implementation. */
308 #define ENV_SUPPORTS_SMP (CONFIG(SMP) && ENV_HAS_SPINLOCKS)
310 #if ENV_X86 && CONFIG(COOP_MULTITASKING) && (ENV_RAMSTAGE || ENV_ROMSTAGE)
311 /* TODO: Enable in all x86 stages */
312 #define ENV_SUPPORTS_COOP 1
314 #define ENV_SUPPORTS_COOP 0
318 * For pre-DRAM stages and post-CAR always build with simple device model, ie.
319 * PCI, PNP and CPU functions operate without use of devicetree. The reason
320 * post-CAR utilizes __SIMPLE_DEVICE__ is for simplicity. Currently there's
321 * no known requirement that devicetree would be needed during that stage.
323 * For ramstage individual source file may define __SIMPLE_DEVICE__
324 * before including any header files to force that particular source
325 * be built with simple device model.
329 #define __SIMPLE_DEVICE__
332 #endif /* _RULES_H */