summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2013-04-24 16:12:52 -0500
committerRonald G. Minnich <rminnich@gmail.com>2013-05-01 07:06:12 +0200
commita4feddf897023b37cfac2af529e787504849f985 (patch)
treef902d7de90ddd9c1358d04295aa1afad3dfa113c /src/include
parent7e35efa83cdd6240e4f9282cc4d2703c40d472d5 (diff)
downloadcoreboot-a4feddf897023b37cfac2af529e787504849f985.tar.xz
boot state: schedule static callbacks
Many of the boot state callbacks can be scheduled at compile time. Therefore, provide a way for a compilation unit to inform the boot state machine when its callbacks should be called. Each C module can export the callbacks and their scheduling requirements without changing the shared boot flow code. Change-Id: Ibc4cea4bd5ad45b2149c2d4aa91cbea652ed93ed Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/3133 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/bootstate.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/include/bootstate.h b/src/include/bootstate.h
index a2eacfbb70..f28c07f17c 100644
--- a/src/include/bootstate.h
+++ b/src/include/bootstate.h
@@ -158,4 +158,25 @@ int boot_state_sched_on_exit(struct boot_state_callback *bscb,
/* Entry into the boot state machine. */
void hardwaremain(int boot_complete);
+/* In order to schedule boot state callbacks at compile-time specify the
+ * entries in an array using the BOOT_STATE_INIT_ENTRIES and
+ * BOOT_STATE_INIT_ENTRY macros below. */
+struct boot_state_init_entry {
+ boot_state_t state;
+ boot_state_sequence_t when;
+ struct boot_state_callback bscb;
+};
+
+#define BOOT_STATE_INIT_ATTR __attribute__ ((used,section (".bs_init")))
+
+#define BOOT_STATE_INIT_ENTRIES(name_) \
+ static struct boot_state_init_entry name_[] BOOT_STATE_INIT_ATTR
+
+#define BOOT_STATE_INIT_ENTRY(state_, when_, func_, arg_) \
+ { \
+ .state = state_, \
+ .when = when_, \
+ .bscb = BOOT_STATE_CALLBACK_INIT(func_, arg_), \
+ }
+
#endif /* BOOTSTATE_H */