summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2023-02-01 11:11:13 +0100
committerPaul Fagerburg <pfagerburg@chromium.org>2023-02-04 01:42:31 +0000
commit9ce7935b490830a709c62e271bf269801520ec29 (patch)
tree2d99f286e8edd0bb5f4aa645c084539fe4b0eda6
parent897d63a840cdfe1bc67c515a05eece2e8464c553 (diff)
include/bootstate.h: Fail compilation on invalid bootstate hooks
No BS_ON_EXIT hooks are run on BS_PAYLOAD_BOOT or BS_OS_RESUME, so don't allow these hooks. Change-Id: I318165f0bd510aed3138d3612dd3e264901aba96 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/72708 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Benjamin Doron <benjamin.doron00@gmail.com> Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
-rw-r--r--src/include/bootstate.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/include/bootstate.h b/src/include/bootstate.h
index 87ed0c8425..a1743a81ab 100644
--- a/src/include/bootstate.h
+++ b/src/include/bootstate.h
@@ -188,7 +188,11 @@ struct boot_state_init_entry {
}; \
static struct boot_state_init_entry * \
bsie_ ## func_ ##_## state_ ##_## when_ BOOT_STATE_INIT_ATTR = \
- &func_ ##_## state_ ##_## when_;
+ &func_ ##_## state_ ##_## when_; \
+ _Static_assert(!(state_ == BS_PAYLOAD_BOOT && when_ == BS_ON_EXIT), \
+ "Invalid bootstate hook"); \
+ _Static_assert(!(state_ == BS_OS_RESUME && when_ == BS_ON_EXIT), \
+ "Invalid bootstate hook");
/* Hook per arch when coreboot is exiting to payload or ACPI OS resume. It's
* the very last thing done before the transition. */