blob: 607d7fc0dd0a570f541b80cc369854395a264b75 [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.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010016 * Foundation, Inc.
Kyösti Mälkkief844012013-06-25 23:17:43 +030017 */
18
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020019#ifndef _RULES_H
20#define _RULES_H
21
22/* Useful helpers to tell whether the code is executing in bootblock,
23 * romstage, ramstage or SMM.
24 */
25
Patrick Georgi56b83092015-04-02 19:44:19 +020026#if defined(__BOOTBLOCK__)
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020027#define ENV_BOOTBLOCK 1
28#define ENV_ROMSTAGE 0
29#define ENV_RAMSTAGE 0
30#define ENV_SMM 0
Furquan Shaikhabde3b52014-08-26 15:39:51 -070031#define ENV_SECMON 0
Patrick Georgicc8171f2015-04-28 22:26:23 +020032#define ENV_VERSTAGE 0
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020033
Patrick Georgi815f4bf2015-04-28 22:43:31 +020034#elif defined(__ROMSTAGE__)
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020035#define ENV_BOOTBLOCK 0
36#define ENV_ROMSTAGE 1
37#define ENV_RAMSTAGE 0
38#define ENV_SMM 0
Furquan Shaikhabde3b52014-08-26 15:39:51 -070039#define ENV_SECMON 0
Patrick Georgicc8171f2015-04-28 22:26:23 +020040#define ENV_VERSTAGE 0
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020041
42#elif defined(__SMM__)
43#define ENV_BOOTBLOCK 0
44#define ENV_ROMSTAGE 0
45#define ENV_RAMSTAGE 0
46#define ENV_SMM 1
Furquan Shaikhabde3b52014-08-26 15:39:51 -070047#define ENV_SECMON 0
Patrick Georgicc8171f2015-04-28 22:26:23 +020048#define ENV_VERSTAGE 0
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020049
Furquan Shaikhabde3b52014-08-26 15:39:51 -070050#elif defined(__SECMON__)
51#define ENV_BOOTBLOCK 0
52#define ENV_ROMSTAGE 0
53#define ENV_RAMSTAGE 0
54#define ENV_SMM 0
55#define ENV_SECMON 1
Patrick Georgicc8171f2015-04-28 22:26:23 +020056#define ENV_VERSTAGE 0
57
58#elif defined(__VERSTAGE__)
59#define ENV_BOOTBLOCK 0
60#define ENV_ROMSTAGE 0
61#define ENV_RAMSTAGE 0
62#define ENV_SMM 0
63#define ENV_SECMON 0
64#define ENV_VERSTAGE 1
Furquan Shaikhabde3b52014-08-26 15:39:51 -070065
Aaron Durbincd96c5c2015-09-04 16:28:15 -050066#elif defined(__RAMSTAGE__)
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020067#define ENV_BOOTBLOCK 0
68#define ENV_ROMSTAGE 0
69#define ENV_RAMSTAGE 1
70#define ENV_SMM 0
Furquan Shaikhabde3b52014-08-26 15:39:51 -070071#define ENV_SECMON 0
Patrick Georgicc8171f2015-04-28 22:26:23 +020072#define ENV_VERSTAGE 0
Aaron Durbincd96c5c2015-09-04 16:28:15 -050073
74#else
75/*
76 * Default case of nothing set for random blob generation using
77 * create_class_compiler that isn't bound to a stage. Also AGESA
78 * apparently builds things compeletely separate from coreboot's
79 * build infrastructure -- hardcoding its own rules.
80 */
81#define ENV_BOOTBLOCK 0
82#define ENV_ROMSTAGE 0
83#define ENV_RAMSTAGE 0
84#define ENV_SMM 0
85#define ENV_SECMON 0
86#define ENV_VERSTAGE 0
Kyösti Mälkkie8792be2014-02-26 15:19:04 +020087#endif
Kyösti Mälkkief844012013-06-25 23:17:43 +030088
89/* For romstage and ramstage always build with simple device model, ie.
90 * PCI, PNP and CPU functions operate without use of devicetree.
91 *
92 * For ramstage individual source file may define __SIMPLE_DEVICE__
93 * before including any header files to force that particular source
94 * be built with simple device model.
95 */
96
97#if defined(__PRE_RAM__) || defined(__SMM__)
98#define __SIMPLE_DEVICE__
99#endif
100
Kyösti Mälkkie8792be2014-02-26 15:19:04 +0200101#endif /* _RULES_H */