blob: 6a05ae949cdaa46347be0c6984b96eda9b149064 [file] [log] [blame]
Kyösti Mälkkief844012013-06-25 23:17:43 +03001/*
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älkkief844012013-06-25 23:17:43 +030013 */
14
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020015#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 Georgi56b83092015-04-02 19:44:19 +020022#if defined(__BOOTBLOCK__)
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020023#define ENV_BOOTBLOCK 1
24#define ENV_ROMSTAGE 0
25#define ENV_RAMSTAGE 0
26#define ENV_SMM 0
Patrick Georgicc8171f2015-04-28 22:26:23 +020027#define ENV_VERSTAGE 0
Aaron Durbindde76292015-09-05 12:59:26 -050028#define ENV_RMODULE 0
Ben Gardneraa5f5b12015-11-19 10:48:47 -060029#define ENV_STRING "bootblock"
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020030
Patrick Georgi815f4bf2015-04-28 22:43:31 +020031#elif defined(__ROMSTAGE__)
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020032#define ENV_BOOTBLOCK 0
33#define ENV_ROMSTAGE 1
34#define ENV_RAMSTAGE 0
35#define ENV_SMM 0
Patrick Georgicc8171f2015-04-28 22:26:23 +020036#define ENV_VERSTAGE 0
Aaron Durbindde76292015-09-05 12:59:26 -050037#define ENV_RMODULE 0
Ben Gardneraa5f5b12015-11-19 10:48:47 -060038#define ENV_STRING "romstage"
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020039
40#elif defined(__SMM__)
41#define ENV_BOOTBLOCK 0
42#define ENV_ROMSTAGE 0
43#define ENV_RAMSTAGE 0
44#define ENV_SMM 1
Patrick Georgicc8171f2015-04-28 22:26:23 +020045#define ENV_VERSTAGE 0
Aaron Durbindde76292015-09-05 12:59:26 -050046#define ENV_RMODULE 0
Ben Gardneraa5f5b12015-11-19 10:48:47 -060047#define ENV_STRING "smm"
Patrick Georgicc8171f2015-04-28 22:26:23 +020048
49#elif defined(__VERSTAGE__)
50#define ENV_BOOTBLOCK 0
51#define ENV_ROMSTAGE 0
52#define ENV_RAMSTAGE 0
53#define ENV_SMM 0
Patrick Georgicc8171f2015-04-28 22:26:23 +020054#define ENV_VERSTAGE 1
Aaron Durbindde76292015-09-05 12:59:26 -050055#define ENV_RMODULE 0
Ben Gardneraa5f5b12015-11-19 10:48:47 -060056#define ENV_STRING "verstage"
Furquan Shaikhabde3b52014-08-26 15:39:51 -070057
Aaron Durbincd96c5c2015-09-04 16:28:15 -050058#elif defined(__RAMSTAGE__)
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020059#define ENV_BOOTBLOCK 0
60#define ENV_ROMSTAGE 0
61#define ENV_RAMSTAGE 1
62#define ENV_SMM 0
Patrick Georgicc8171f2015-04-28 22:26:23 +020063#define ENV_VERSTAGE 0
Aaron Durbindde76292015-09-05 12:59:26 -050064#define ENV_RMODULE 0
Ben Gardneraa5f5b12015-11-19 10:48:47 -060065#define ENV_STRING "ramstage"
Aaron Durbindde76292015-09-05 12:59:26 -050066
67#elif defined(__RMODULE__)
68#define ENV_BOOTBLOCK 0
69#define ENV_ROMSTAGE 0
70#define ENV_RAMSTAGE 0
71#define ENV_SMM 0
Aaron Durbindde76292015-09-05 12:59:26 -050072#define ENV_VERSTAGE 0
73#define ENV_RMODULE 1
Ben Gardneraa5f5b12015-11-19 10:48:47 -060074#define ENV_STRING "rmodule"
Aaron Durbincd96c5c2015-09-04 16:28:15 -050075
76#else
77/*
78 * Default case of nothing set for random blob generation using
79 * create_class_compiler that isn't bound to a stage. Also AGESA
80 * apparently builds things compeletely separate from coreboot's
81 * build infrastructure -- hardcoding its own rules.
82 */
83#define ENV_BOOTBLOCK 0
84#define ENV_ROMSTAGE 0
85#define ENV_RAMSTAGE 0
86#define ENV_SMM 0
Aaron Durbincd96c5c2015-09-04 16:28:15 -050087#define ENV_VERSTAGE 0
Aaron Durbindde76292015-09-05 12:59:26 -050088#define ENV_RMODULE 0
Ben Gardneraa5f5b12015-11-19 10:48:47 -060089#define ENV_STRING "UNKNOWN"
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020090#endif
Kyösti Mälkkief844012013-06-25 23:17:43 +030091
92/* For romstage and ramstage always build with simple device model, ie.
93 * PCI, PNP and CPU functions operate without use of devicetree.
94 *
95 * For ramstage individual source file may define __SIMPLE_DEVICE__
96 * before including any header files to force that particular source
97 * be built with simple device model.
98 */
99
100#if defined(__PRE_RAM__) || defined(__SMM__)
101#define __SIMPLE_DEVICE__
102#endif
103
Julius Wernerd3634c12015-11-13 13:28:41 -0800104/* Define helpers about the current architecture, based on toolchain.inc. */
105
106#if defined(__ARCH_arm__)
107#define ENV_ARM 1
108#define ENV_ARM64 0
109#if __COREBOOT_ARM_ARCH__ == 4
110#define ENV_ARMV4 1
111#define ENV_ARMV7 0
112#elif __COREBOOT_ARM_ARCH__ == 7
113#define ENV_ARMV4 0
114#define ENV_ARMV7 1
115#else
116#define ENV_ARMV4 0
117#define ENV_ARMV7 0
118#endif
119#define ENV_ARMV8 0
120#define ENV_MIPS 0
121#define ENV_RISCV 0
122#define ENV_X86 0
123#define ENV_X86_32 0
124#define ENV_X86_64 0
125
126#elif defined(__ARCH_arm64__)
127#define ENV_ARM 0
128#define ENV_ARM64 1
129#define ENV_ARMV4 0
130#define ENV_ARMV7 0
131#if __COREBOOT_ARM_ARCH__ == 8
132#define ENV_ARMV8 1
133#else
134#define ENV_ARMV8 0
135#endif
136#define ENV_MIPS 0
137#define ENV_RISCV 0
138#define ENV_X86 0
139#define ENV_X86_32 0
140#define ENV_X86_64 0
141
142#elif defined(__ARCH_mips__)
143#define ENV_ARM 0
144#define ENV_ARM64 0
145#define ENV_ARMV4 0
146#define ENV_ARMV7 0
147#define ENV_ARMV8 0
148#define ENV_MIPS 1
149#define ENV_RISCV 0
150#define ENV_X86 0
151#define ENV_X86_32 0
152#define ENV_X86_64 0
153
154#elif defined(__ARCH_riscv__)
155#define ENV_ARM 0
156#define ENV_ARM64 0
157#define ENV_ARMV4 0
158#define ENV_ARMV7 0
159#define ENV_ARMV8 0
160#define ENV_MIPS 0
161#define ENV_RISCV 1
162#define ENV_X86 0
163#define ENV_X86_32 0
164#define ENV_X86_64 0
165
166#elif defined(__ARCH_x86_32__)
167#define ENV_ARM 0
168#define ENV_ARM64 0
169#define ENV_ARMV4 0
170#define ENV_ARMV7 0
171#define ENV_ARMV8 0
172#define ENV_MIPS 0
173#define ENV_RISCV 0
174#define ENV_X86 1
175#define ENV_X86_32 1
176#define ENV_X86_64 0
177
178#elif defined(__ARCH_x86_64__)
179#define ENV_ARM 0
180#define ENV_ARM64 0
181#define ENV_ARMV4 0
182#define ENV_ARMV7 0
183#define ENV_ARMV8 0
184#define ENV_MIPS 0
185#define ENV_RISCV 0
186#define ENV_X86 1
187#define ENV_X86_32 0
188#define ENV_X86_64 1
189
190#else
191#define ENV_ARM 0
192#define ENV_ARM64 0
193#define ENV_ARMV4 0
194#define ENV_ARMV7 0
195#define ENV_ARMV8 0
196#define ENV_MIPS 0
197#define ENV_RISCV 0
198#define ENV_X86 0
199#define ENV_X86_32 0
200#define ENV_X86_64 0
201
202#endif
203
Kyösti Mälkkie8792be2014-02-26 15:19:04 +0200204#endif /* _RULES_H */