[coreboot-gerrit] Patch set updated for coreboot: f4e3325 boot state: schedule static callbacks

Aaron Durbin (adurbin@google.com) gerrit at coreboot.org
Fri Apr 26 00:23:57 CEST 2013


Aaron Durbin (adurbin at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3133

-gerrit

commit f4e3325928297dd309c2e7e1f9b99ed2a7f4c169
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Wed Apr 24 16:12:52 2013 -0500

    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 at chromium.org>
---
 src/arch/armv7/coreboot_ram.ld |  3 +++
 src/arch/x86/coreboot_ram.ld   |  3 +++
 src/include/bootstate.h        | 21 +++++++++++++++++++++
 src/lib/hardwaremain.c         | 20 ++++++++++++++++++++
 src/lib/rmodule.ld             |  4 ++++
 5 files changed, 51 insertions(+)

diff --git a/src/arch/armv7/coreboot_ram.ld b/src/arch/armv7/coreboot_ram.ld
index c2ead7a..487f610 100644
--- a/src/arch/armv7/coreboot_ram.ld
+++ b/src/arch/armv7/coreboot_ram.ld
@@ -61,6 +61,9 @@ SECTIONS
 		cpu_drivers = . ;
 		*(.rodata.cpu_driver)
 		ecpu_drivers = . ;
+		_bs_init_begin = .;
+		*(.bs_init)
+		_bs_init_end = .;
 		*(.rodata)
 		*(.rodata.*)
 		/* kevinh/Ispiri - Added an align, because the objcopy tool
diff --git a/src/arch/x86/coreboot_ram.ld b/src/arch/x86/coreboot_ram.ld
index 2dd51d5..ea32837 100644
--- a/src/arch/x86/coreboot_ram.ld
+++ b/src/arch/x86/coreboot_ram.ld
@@ -64,6 +64,9 @@ SECTIONS
 		cpu_drivers = . ;
 		*(.rodata.cpu_driver)
 		ecpu_drivers = . ;
+		_bs_init_begin = .;
+		*(.bs_init)
+		_bs_init_end = .;
 
 		*(.rodata)
 		*(.rodata.*)
diff --git a/src/include/bootstate.h b/src/include/bootstate.h
index f36a795..86d1dd8 100644
--- a/src/include/bootstate.h
+++ b/src/include/bootstate.h
@@ -132,4 +132,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__ ((section (".bs_init")))
+
+#define BOOT_STATE_INIT_ENTRIES(name_) \
+	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 */
diff --git a/src/lib/hardwaremain.c b/src/lib/hardwaremain.c
index 17b63b5..2d6e76a 100644
--- a/src/lib/hardwaremain.c
+++ b/src/lib/hardwaremain.c
@@ -285,6 +285,23 @@ int boot_state_sched_on_exit(struct boot_state_callback *bscb,
 	return boot_state_sched_callback(state, bscb, BS_ON_EXIT);
 }
 
+static void boot_state_schedule_static_entries(void)
+{
+	extern struct boot_state_init_entry _bs_init_begin;
+	extern struct boot_state_init_entry _bs_init_end;
+	struct boot_state_init_entry *cur;
+
+	cur = &_bs_init_begin;
+
+	while (cur != &_bs_init_end) {
+		if (cur->when == BS_ON_ENTRY)
+			boot_state_sched_on_entry(&cur->bscb, cur->state);
+		else
+			boot_state_sched_on_exit(&cur->bscb, cur->state);
+		cur++;
+	}
+}
+
 void hardwaremain(int boot_complete)
 {
 	timestamp_stash(TS_START_RAMSTAGE);
@@ -310,6 +327,9 @@ void hardwaremain(int boot_complete)
 		hard_reset();
 	}
 
+	/* Schedule the static boot state entries. */
+	boot_state_schedule_static_entries();
+
 	/* FIXME: Is there a better way to handle this? */
 	init_timer();
 
diff --git a/src/lib/rmodule.ld b/src/lib/rmodule.ld
index 41d6357..43c0718 100644
--- a/src/lib/rmodule.ld
+++ b/src/lib/rmodule.ld
@@ -61,6 +61,10 @@ SECTIONS
 		cpu_drivers = . ;
 		*(.rodata.cpu_driver)
 		ecpu_drivers = . ;
+		_bs_init_begin = .;
+		*(.bs_init)
+		_bs_init_end = .;
+
 		. = ALIGN(4);
 
 		*(.rodata);



More information about the coreboot-gerrit mailing list