1 /* SPDX-License-Identifier: GPL-2.0-only */
6 #if defined(__TIMELESS__)
12 /* Useful helpers to tell whether the code is executing in bootblock,
13 * romstage, ramstage or SMM.
16 #if defined(__DECOMPRESSOR__)
17 #define ENV_DECOMPRESSOR 1
18 #define ENV_BOOTBLOCK 0
19 #define ENV_ROMSTAGE 0
20 #define ENV_RAMSTAGE 0
22 #define ENV_SEPARATE_VERSTAGE 0
25 #define ENV_LIBAGESA 0
26 #define ENV_STRING "decompressor"
28 #elif defined(__BOOTBLOCK__)
29 #define ENV_DECOMPRESSOR 0
30 #define ENV_BOOTBLOCK 1
31 #define ENV_ROMSTAGE 0
32 #define ENV_RAMSTAGE 0
34 #define ENV_SEPARATE_VERSTAGE 0
37 #define ENV_LIBAGESA 0
38 #define ENV_STRING "bootblock"
40 #elif defined(__ROMSTAGE__)
41 #define ENV_DECOMPRESSOR 0
42 #define ENV_BOOTBLOCK 0
43 #define ENV_ROMSTAGE 1
44 #define ENV_RAMSTAGE 0
46 #define ENV_SEPARATE_VERSTAGE 0
49 #define ENV_LIBAGESA 0
50 #define ENV_STRING "romstage"
52 #elif defined(__SMM__)
53 #define ENV_DECOMPRESSOR 0
54 #define ENV_BOOTBLOCK 0
55 #define ENV_ROMSTAGE 0
56 #define ENV_RAMSTAGE 0
58 #define ENV_SEPARATE_VERSTAGE 0
61 #define ENV_LIBAGESA 0
62 #define ENV_STRING "smm"
65 * NOTE: "verstage" code may either run as a separate stage or linked into the
66 * bootblock/romstage, depending on the setting of CONFIG_SEPARATE_VERSTAGE. The
67 * ENV_SEPARATE_VERSTAGE macro will only return true for "verstage" code when
68 * CONFIG_SEPARATE_VERSTAGE=y, otherwise that code will have ENV_BOOTBLOCK or
69 * ENV_ROMSTAGE set (depending on the CONFIG_VBOOT_STARTS_IN_... options).
71 #elif defined(__VERSTAGE__)
72 #define ENV_DECOMPRESSOR 0
73 #define ENV_BOOTBLOCK 0
74 #define ENV_ROMSTAGE 0
75 #define ENV_RAMSTAGE 0
77 #define ENV_SEPARATE_VERSTAGE 1
80 #define ENV_LIBAGESA 0
81 #define ENV_STRING "verstage"
83 #elif defined(__RAMSTAGE__)
84 #define ENV_DECOMPRESSOR 0
85 #define ENV_BOOTBLOCK 0
86 #define ENV_ROMSTAGE 0
87 #define ENV_RAMSTAGE 1
89 #define ENV_SEPARATE_VERSTAGE 0
92 #define ENV_LIBAGESA 0
93 #define ENV_STRING "ramstage"
95 #elif defined(__RMODULE__)
96 #define ENV_DECOMPRESSOR 0
97 #define ENV_BOOTBLOCK 0
98 #define ENV_ROMSTAGE 0
99 #define ENV_RAMSTAGE 0
101 #define ENV_SEPARATE_VERSTAGE 0
102 #define ENV_RMODULE 1
103 #define ENV_POSTCAR 0
104 #define ENV_LIBAGESA 0
105 #define ENV_STRING "rmodule"
107 #elif defined(__POSTCAR__)
108 #define ENV_DECOMPRESSOR 0
109 #define ENV_BOOTBLOCK 0
110 #define ENV_ROMSTAGE 0
111 #define ENV_RAMSTAGE 0
113 #define ENV_SEPARATE_VERSTAGE 0
114 #define ENV_RMODULE 0
115 #define ENV_POSTCAR 1
116 #define ENV_LIBAGESA 0
117 #define ENV_STRING "postcar"
119 #elif defined(__LIBAGESA__)
120 #define ENV_DECOMPRESSOR 0
121 #define ENV_BOOTBLOCK 0
122 #define ENV_ROMSTAGE 0
123 #define ENV_RAMSTAGE 0
125 #define ENV_SEPARATE_VERSTAGE 0
126 #define ENV_RMODULE 0
127 #define ENV_POSTCAR 0
128 #define ENV_LIBAGESA 1
129 #define ENV_STRING "libagesa"
133 * Default case of nothing set for random blob generation using
134 * create_class_compiler that isn't bound to a stage.
136 #define ENV_DECOMPRESSOR 0
137 #define ENV_BOOTBLOCK 0
138 #define ENV_ROMSTAGE 0
139 #define ENV_RAMSTAGE 0
141 #define ENV_SEPARATE_VERSTAGE 0
142 #define ENV_RMODULE 0
143 #define ENV_POSTCAR 0
144 #define ENV_LIBAGESA 0
145 #define ENV_STRING "UNKNOWN"
148 /* Define helpers about the current architecture, based on toolchain.inc. */
150 #if defined(__ARCH_arm__)
153 #if __COREBOOT_ARM_ARCH__ == 4
156 #elif __COREBOOT_ARM_ARCH__ == 7
159 #if defined(__COREBOOT_ARM_V7_A__)
160 #define ENV_ARMV7_A 1
161 #define ENV_ARMV7_M 0
162 #define ENV_ARMV7_R 0
163 #elif defined(__COREBOOT_ARM_V7_M__)
164 #define ENV_ARMV7_A 0
165 #define ENV_ARMV7_M 1
166 #define ENV_ARMV7_R 0
167 #elif defined(__COREBOOT_ARM_V7_R__)
168 #define ENV_ARMV7_A 0
169 #define ENV_ARMV7_M 0
170 #define ENV_ARMV7_R 1
182 #elif defined(__ARCH_arm64__)
187 #if __COREBOOT_ARM_ARCH__ == 8
197 #elif defined(__ARCH_riscv__)
208 #elif defined(__ARCH_x86_32__)
219 #elif defined(__ARCH_x86_64__)
243 #if CONFIG(RAMPAYLOAD)
244 /* ENV_PAYLOAD_LOADER is set to ENV_POSTCAR when CONFIG_RAMPAYLOAD is enabled */
245 #define ENV_PAYLOAD_LOADER ENV_POSTCAR
247 /* ENV_PAYLOAD_LOADER is set when you are in a stage that loads the payload.
248 * For now, that is the ramstage. */
249 #define ENV_PAYLOAD_LOADER ENV_RAMSTAGE
252 #define ENV_ROMSTAGE_OR_BEFORE \
253 (ENV_DECOMPRESSOR || ENV_BOOTBLOCK || ENV_ROMSTAGE || \
254 (ENV_SEPARATE_VERSTAGE && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE)))
257 /* Indicates memory layout is determined with arch/x86/car.ld. */
258 #define ENV_CACHE_AS_RAM (ENV_ROMSTAGE_OR_BEFORE && !CONFIG(RESET_VECTOR_IN_RAM))
259 /* No .data sections with execute-in-place from ROM. */
260 #define ENV_STAGE_HAS_DATA_SECTION !ENV_CACHE_AS_RAM
262 /* Both .data and .bss, sometimes SRAM not DRAM. */
263 #define ENV_STAGE_HAS_DATA_SECTION 1
264 #define ENV_CACHE_AS_RAM 0
267 /* Currently rmodules, ramstage and smm have heap. */
268 #define ENV_STAGE_HAS_HEAP_SECTION (ENV_RMODULE || ENV_RAMSTAGE || ENV_SMM)
270 /* Set USER_SPACE in the makefile for the rare code that runs in userspace */
271 #if defined(__USER_SPACE__)
272 #define ENV_USER_SPACE 1
274 #define ENV_USER_SPACE 0
278 * For pre-DRAM stages and post-CAR always build with simple device model, ie.
279 * PCI, PNP and CPU functions operate without use of devicetree. The reason
280 * post-CAR utilizes __SIMPLE_DEVICE__ is for simplicity. Currently there's
281 * no known requirement that devicetree would be needed during that stage.
283 * For ramstage individual source file may define __SIMPLE_DEVICE__
284 * before including any header files to force that particular source
285 * be built with simple device model.
289 #define __SIMPLE_DEVICE__
292 #endif /* _RULES_H */