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. |
| 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 Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 16 | * Foundation, Inc. |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 17 | */ |
| 18 | |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 19 | #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 Georgi | 56b8309 | 2015-04-02 19:44:19 +0200 | [diff] [blame] | 26 | #if defined(__BOOTBLOCK__) |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 27 | #define ENV_BOOTBLOCK 1 |
| 28 | #define ENV_ROMSTAGE 0 |
| 29 | #define ENV_RAMSTAGE 0 |
| 30 | #define ENV_SMM 0 |
Furquan Shaikh | abde3b5 | 2014-08-26 15:39:51 -0700 | [diff] [blame] | 31 | #define ENV_SECMON 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 32 | #define ENV_VERSTAGE 0 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 33 | |
Patrick Georgi | 815f4bf | 2015-04-28 22:43:31 +0200 | [diff] [blame] | 34 | #elif defined(__ROMSTAGE__) |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 35 | #define ENV_BOOTBLOCK 0 |
| 36 | #define ENV_ROMSTAGE 1 |
| 37 | #define ENV_RAMSTAGE 0 |
| 38 | #define ENV_SMM 0 |
Furquan Shaikh | abde3b5 | 2014-08-26 15:39:51 -0700 | [diff] [blame] | 39 | #define ENV_SECMON 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 40 | #define ENV_VERSTAGE 0 |
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 |
Furquan Shaikh | abde3b5 | 2014-08-26 15:39:51 -0700 | [diff] [blame] | 47 | #define ENV_SECMON 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 48 | #define ENV_VERSTAGE 0 |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 49 | |
Furquan Shaikh | abde3b5 | 2014-08-26 15:39:51 -0700 | [diff] [blame] | 50 | #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 Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 56 | #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 Shaikh | abde3b5 | 2014-08-26 15:39:51 -0700 | [diff] [blame] | 65 | |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame^] | 66 | #elif defined(__RAMSTAGE__) |
Kyösti Mälkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 67 | #define ENV_BOOTBLOCK 0 |
| 68 | #define ENV_ROMSTAGE 0 |
| 69 | #define ENV_RAMSTAGE 1 |
| 70 | #define ENV_SMM 0 |
Furquan Shaikh | abde3b5 | 2014-08-26 15:39:51 -0700 | [diff] [blame] | 71 | #define ENV_SECMON 0 |
Patrick Georgi | cc8171f | 2015-04-28 22:26:23 +0200 | [diff] [blame] | 72 | #define ENV_VERSTAGE 0 |
Aaron Durbin | cd96c5c | 2015-09-04 16:28:15 -0500 | [diff] [blame^] | 73 | |
| 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älkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 87 | #endif |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 88 | |
| 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älkki | e8792be | 2014-02-26 15:19:04 +0200 | [diff] [blame] | 101 | #endif /* _RULES_H */ |