Patch set updated for coreboot: c9cdcbc cbmem: [NOTFORMERGE]  CBMEM_INIT_HOOK() API

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Tue Dec 30 20:41:24 CET 2014


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7878

-gerrit

commit c9cdcbc4268f5b0f9e20cb2e13aeea740d3682a1
Author: Julius Werner <jwerner at chromium.org>
Date:   Mon Dec 1 18:08:03 2014 -0800

    cbmem: [NOTFORMERGE]  CBMEM_INIT_HOOK() API
    
    Squashed two changes from chromium.git.
    
    cbmem: Unify random on-CBMEM-init tasks under common CBMEM_INIT_HOOK() API
    
    There are several use cases for performing a certain task when CBMEM is
    first set up (usually to migrate some data into it that was previously
    kept in BSS/SRAM/hammerspace), and unfortunately we handle each of them
    differently: timestamp migration is called explicitly from
    cbmem_initialize(), certain x86-chipset-specific tasks use the
    CAR_MIGRATION() macro to register a hook, and the CBMEM console is
    migrated through a direct call from romstage (on non-x86 and SandyBridge
    boards).
    
    This patch decouples the CAR_MIGRATION() hook mechanism from
    cache-as-RAM and rechristens it to CBMEM_INIT_HOOK(), which is a clearer
    description of what it really does. All of the above use cases are
    ported to this new, consistent model, allowing us to have one less line
    of boilerplate in non-CAR romstages.
    
    BRANCH=None
    BUG=None
    TEST=Built and booted on Nyan_Blaze and Falco with and without
    CONFIG_CBMEM_CONSOLE. Confirmed that 'cbmem -c' shows the full log after
    boot (and the resume log after S3 resume on Falco). Compiled for Parrot,
    Stout and Lumpy.
    
    Original-Change-Id: I1681b372664f5a1f15c3733cbd32b9b11f55f8ea
    Signed-off-by: Julius Werner <jwerner at chromium.org>
    Reviewed-on: https://chromium-review.googlesource.com/232612
    Reviewed-by: Aaron Durbin <adurbin at chromium.org>
    
    cbmem: Extend hooks to ramstage, fix timestamp synching
    
    Commit 7dd5bbd71 (cbmem: Unify random on-CBMEM-init tasks under common
    CBMEM_INIT_HOOK() API) inadvertently broke ramstage timestamps since
    timestamp_sync() was no longer called there. Oops.
    
    This patch fixes the issue by extending the CBMEM_INIT_HOOK() mechanism
    to the cbmem_initialize() call in ramstage. The macro is split into
    explicit ROMSTAGE_/RAMSTAGE_ versions to make the behavior as clear as
    possible and prevent surprises (although just using a single macro and
    relying on the Makefiles to link an object into all appropriate stages
    would also work).
    
    This allows us to get rid of the explicit cbmemc_reinit() in ramstage
    (which I somehow accounted for in the last patch without realizing that
    timestamps work exactly the same way...), and replace the older and less
    flexible cbmem_arch_init() mechanism.
    
    Also added a size assertion for the pre-RAM CBMEM console to memlayout
    that could prevent a very unlikely buffer overflow I just noticed.
    
    BRANCH=None
    BUG=None
    TEST=Booted on Pinky and Falco, confirmed that ramstage timestamps once
    again show up. Compile-tested for Rambi and Samus.
    
    Original-Change-Id: If907266c3f20dc3d599b5c968ea5b39fe5c00e9c
    Signed-off-by: Julius Werner <jwerner at chromium.org>
    Reviewed-on: https://chromium-review.googlesource.com/233533
    Reviewed-by: Aaron Durbin <adurbin at chromium.org>
    
    Change-Id: I1be89bafacfe85cba63426e2d91f5d8d4caa1800
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 3rdparty                                       |   2 +-
 src/arch/arm/include/arch/early_variables.h    |   1 -
 src/arch/arm64/include/arch/early_variables.h  |   1 -
 src/arch/x86/boot/cbmem.c                      |   7 +-
 src/arch/x86/boot/gdt.c                        |   3 +-
 src/arch/x86/include/arch/early_variables.h    |   7 --
 src/arch/x86/init/romstage.ld                  |   9 +-
 src/cpu/x86/car.c                              |  12 ---
 src/drivers/usb/ehci_debug.c                   |   2 +-
 src/include/cbmem.h                            |  19 +++-
 src/include/cpu/x86/gdt.h                      |   3 -
 src/lib/Makefile.inc                           |   3 +-
 src/lib/cbmem_common.c                         |  59 +++++++++++++
 src/lib/cbmem_console.c                        |   4 +-
 src/lib/cbmem_info.c                           |  45 ----------
 src/lib/ramstage.ld                            | 117 +++++++++++++++++++++++++
 src/lib/rmodule.ld                             |   3 +
 src/lib/romstage.ld                            |  62 +++++++++++++
 src/lib/timestamp.c                            |   2 +-
 src/soc/intel/baytrail/romstage/romstage.c     |   2 +-
 src/soc/intel/broadwell/romstage/power_state.c |   2 +-
 21 files changed, 275 insertions(+), 90 deletions(-)

diff --git a/3rdparty b/3rdparty
index 9f68e20..a8b0c52 160000
--- a/3rdparty
+++ b/3rdparty
@@ -1 +1 @@
-Subproject commit 9f68e20e5ef4b6681fb18bdb4022471bc6810788
+Subproject commit a8b0c52850495c30dfa1cd8cc2c679a6ba4e18ac
diff --git a/src/arch/arm/include/arch/early_variables.h b/src/arch/arm/include/arch/early_variables.h
index 539b572..6145703 100644
--- a/src/arch/arm/include/arch/early_variables.h
+++ b/src/arch/arm/include/arch/early_variables.h
@@ -22,7 +22,6 @@
 
 #define CAR_GLOBAL
 
-#define CAR_MIGRATE(migrate_fn_)
 static inline void *car_get_var_ptr(void *var) { return var; }
 #define car_get_var(var) (var)
 #define car_set_var(var, val) do { (var) = (val); } while (0)
diff --git a/src/arch/arm64/include/arch/early_variables.h b/src/arch/arm64/include/arch/early_variables.h
index 539b572..6145703 100644
--- a/src/arch/arm64/include/arch/early_variables.h
+++ b/src/arch/arm64/include/arch/early_variables.h
@@ -22,7 +22,6 @@
 
 #define CAR_GLOBAL
 
-#define CAR_MIGRATE(migrate_fn_)
 static inline void *car_get_var_ptr(void *var) { return var; }
 #define car_get_var(var) (var)
 #define car_set_var(var, val) do { (var) = (val); } while (0)
diff --git a/src/arch/x86/boot/cbmem.c b/src/arch/x86/boot/cbmem.c
index 49dd02b..7ff0925 100644
--- a/src/arch/x86/boot/cbmem.c
+++ b/src/arch/x86/boot/cbmem.c
@@ -58,12 +58,7 @@ void cbmem_arch_init(void)
 	/* Migrate car.global_data. */
 	car_migrate_variables();
 
-#if !defined(__PRE_RAM__)
-	/* Relocate CBMEM console. */
-	cbmemc_reinit();
-
-	move_gdt();
-#endif
+	cbmem_run_init_hooks();
 }
 
 /* Something went wrong, our high memory area got wiped */
diff --git a/src/arch/x86/boot/gdt.c b/src/arch/x86/boot/gdt.c
index 7b64af7..b4cfbee 100644
--- a/src/arch/x86/boot/gdt.c
+++ b/src/arch/x86/boot/gdt.c
@@ -32,7 +32,7 @@ struct gdtarg {
 /* Copy GDT to new location and reload it.
  * FIXME: We only do this for BSP CPU.
  */
-void move_gdt(void)
+static void move_gdt(void)
 {
 	void *newgdt;
 	u16 num_gdt_bytes = (u32)&gdt_end - (u32)&gdt;
@@ -55,3 +55,4 @@ void move_gdt(void)
 	__asm__ __volatile__ ("lgdt %0\n\t" : : "m" (gdtarg));
 	printk(BIOS_DEBUG, "ok\n");
 }
+RAMSTAGE_CBMEM_INIT_HOOK(move_gdt)
diff --git a/src/arch/x86/include/arch/early_variables.h b/src/arch/x86/include/arch/early_variables.h
index f76c048..2685175 100644
--- a/src/arch/x86/include/arch/early_variables.h
+++ b/src/arch/x86/include/arch/early_variables.h
@@ -29,12 +29,6 @@ asm(".previous");
 #endif
 
 #if defined(__PRE_RAM__)
-#define CAR_MIGRATE_ATTR __attribute__ ((used,section (".car.migrate")))
-
-/* Call migrate_fn_() when CAR globals are migrated. */
-#define CAR_MIGRATE(migrate_fn_) \
-	static void (* const migrate_fn_ ## _ptr)(void) CAR_MIGRATE_ATTR = \
-	migrate_fn_;
 
 /* Get the correct pointer for the CAR global variable. */
 void *car_get_var_ptr(void *var);
@@ -46,7 +40,6 @@ void *car_get_var_ptr(void *var);
 	do { car_get_var(var) = (val); } while(0)
 
 #else
-#define CAR_MIGRATE(migrate_fn_)
 static inline void *car_get_var_ptr(void *var) { return var; }
 #define car_get_var(var) (var)
 #define car_set_var(var, val) do { (var) = (val); } while (0)
diff --git a/src/arch/x86/init/romstage.ld b/src/arch/x86/init/romstage.ld
index 99bcc8e..3ade87f 100644
--- a/src/arch/x86/init/romstage.ld
+++ b/src/arch/x86/init/romstage.ld
@@ -31,15 +31,14 @@ SECTIONS
 		_rom = .;
 		*(.rom.text);
 		*(.rom.data);
+		. = ALIGN(4);
+		_cbmem_init_hooks = .;
+		KEEP(*(.rodata.cbmem_init_hooks));
+		_ecbmem_init_hooks = .;
 		*(.rodata);
 		*(.rodata.*);
 		*(.rom.data.*);
 		. = ALIGN(16);
-		_car_migrate_start = .;
-		*(.car.migrate);
-		LONG(0);
-		_car_migrate_end = .;
-		. = ALIGN(16);
 		_erom = .;
 	}
 
diff --git a/src/cpu/x86/car.c b/src/cpu/x86/car.c
index c9cc6d6..eb3b5fc 100644
--- a/src/cpu/x86/car.c
+++ b/src/cpu/x86/car.c
@@ -23,10 +23,6 @@
 #include <cbmem.h>
 #include <arch/early_variables.h>
 
-typedef void (* const car_migration_func_t)(void);
-
-extern car_migration_func_t _car_migrate_start;
-
 extern char _car_data_start[];
 extern char _car_data_end[];
 
@@ -76,7 +72,6 @@ void *car_get_var_ptr(void *var)
 static void do_car_migrate_variables(void)
 {
 	void *migrated_base;
-	car_migration_func_t *migrate_func;
 	size_t car_data_size = &_car_data_end[0] - &_car_data_start[0];
 
 	/* Check if already migrated. */
@@ -94,13 +89,6 @@ static void do_car_migrate_variables(void)
 
 	/* Mark that the data has been moved. */
 	car_migrated = ~0;
-
-	/* Call all the migration functions. */
-	migrate_func = &_car_migrate_start;
-	while (*migrate_func != NULL) {
-		(*migrate_func)();
-		migrate_func++;
-	}
 }
 
 void car_migrate_variables(void)
diff --git a/src/drivers/usb/ehci_debug.c b/src/drivers/usb/ehci_debug.c
index 83c23a3..f89ea2f 100644
--- a/src/drivers/usb/ehci_debug.c
+++ b/src/drivers/usb/ehci_debug.c
@@ -683,7 +683,7 @@ static void migrate_ehci_debug(void)
 	memcpy(dbg_info_cbmem, dbg_info, sizeof(*dbg_info));
 	car_set_var(glob_dbg_info_p, dbg_info_cbmem);
 }
-CAR_MIGRATE(migrate_ehci_debug);
+ROMSTAGE_CBMEM_INIT_HOOK(migrate_ehci_debug);
 #endif
 
 int dbgp_ep_is_active(struct dbgp_pipe *pipe)
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index ea81fd0..316a780 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -182,13 +182,30 @@ void *cbmem_find(u32 id);
 void cbmem_arch_init(void);
 void cbmem_fail_resume(void);
 
+typedef void (* const cbmem_init_hook_t)(void);
+void cbmem_run_init_hooks(void);
+
 #ifndef __PRE_RAM__
 /* Ramstage only functions. */
 /* Add the cbmem memory used to the memory map at boot. */
 void cbmem_add_bootmem(void);
 void cbmem_list(void);
 void cbmem_print_entry(int n, u32 id, u64 start, u64 size);
-#endif /* __PRE_RAM__ */
+#endif
+
+#ifndef __PRE_RAM__
+#define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \
+	init_fn_ ## _unused_ __attribute__((unused)) = init_fn_;
+#define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) \
+	static cbmem_init_hook_t init_fn_ ## _ptr_ __attribute__((used, \
+	section(".rodata.cbmem_init_hooks"))) = init_fn_;
+#else /* __PRE_RAM__ */
+#define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) \
+	static cbmem_init_hook_t init_fn_ ## _ptr_ __attribute__((used, \
+	section(".rodata.cbmem_init_hooks"))) = init_fn_;
+#define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \
+	init_fn_ ## _unused_ __attribute__((unused)) = init_fn_;
+#endif /* !__PRE_RAM__ */
 
 /* These are for compatibility with old boards only. Any new chipset and board
  * must implement cbmem_top() for both romstage and ramstage to support
diff --git a/src/include/cpu/x86/gdt.h b/src/include/cpu/x86/gdt.h
index 260b158..43a80fe 100644
--- a/src/include/cpu/x86/gdt.h
+++ b/src/include/cpu/x86/gdt.h
@@ -28,7 +28,4 @@ extern char _secondary_gdt_addr[];
 extern char _secondary_start[];
 extern char _secondary_start_end[];
 
-/* Defined in src/arch/x86/boot/gdt.c */
-void move_gdt(void);
-
 #endif /* CPU_X86_GDT */
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 5a5ccc2..c6a30a3 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -76,7 +76,8 @@ ramstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
 
 ramstage-y += dynamic_cbmem.c
 romstage-y += dynamic_cbmem.c
-ramstage-y += cbmem_info.c
+romstage-y += cbmem_common.c
+ramstage-y += cbmem_common.c
 
 ramstage-y += hexdump.c
 romstage-y += hexdump.c
diff --git a/src/lib/cbmem_common.c b/src/lib/cbmem_common.c
new file mode 100644
index 0000000..935f759
--- /dev/null
+++ b/src/lib/cbmem_common.c
@@ -0,0 +1,59 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied wacbmem_entryanty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+#include <console/console.h>
+#include <cbmem.h>
+#include <stdlib.h>
+
+static const struct cbmem_id_to_name cbmem_ids[] = { CBMEM_ID_TO_NAME_TABLE };
+
+void cbmem_print_entry(int n, u32 id, u64 base, u64 size)
+{
+	int i;
+	const char *name;
+
+	name = NULL;
+	for (i = 0; i < ARRAY_SIZE(cbmem_ids); i++) {
+		if (cbmem_ids[i].id == id) {
+			name = cbmem_ids[i].name;
+			break;
+		}
+	}
+
+	if (name == NULL)
+		printk(BIOS_DEBUG, "%08x ", id);
+	else
+		printk(BIOS_DEBUG, "%s", name);
+	printk(BIOS_DEBUG, "%2d. ", n);
+	printk(BIOS_DEBUG, "%08llx ", base);
+	printk(BIOS_DEBUG, "%08llx\n", size);
+}
+
+#endif	/* !__PRE_RAM__ */
+
+extern cbmem_init_hook_t _cbmem_init_hooks;
+extern cbmem_init_hook_t _ecbmem_init_hooks;
+
+void cbmem_run_init_hooks(void)
+{
+	cbmem_init_hook_t *init_hook_ptr = &_cbmem_init_hooks;
+	while (init_hook_ptr != &_ecbmem_init_hooks) {
+		(*init_hook_ptr)();
+		init_hook_ptr++;
+	}
+}
diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c
index 3988084..2799895 100644
--- a/src/lib/cbmem_console.c
+++ b/src/lib/cbmem_console.c
@@ -232,5 +232,5 @@ void cbmemc_reinit(void)
 	init_console_ptr(cbm_cons_p,
 		CONFIG_CONSOLE_CBMEM_BUFFER_SIZE, flags);
 }
-/* Call cbmemc_reinit() at CAR migration time. */
-CAR_MIGRATE(cbmemc_reinit)
+ROMSTAGE_CBMEM_INIT_HOOK(cbmemc_reinit)
+RAMSTAGE_CBMEM_INIT_HOOK(cbmemc_reinit)
diff --git a/src/lib/cbmem_info.c b/src/lib/cbmem_info.c
deleted file mode 100644
index 7b1168d..0000000
--- a/src/lib/cbmem_info.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Google, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied wacbmem_entryanty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-#include <console/console.h>
-#include <cbmem.h>
-#include <stdlib.h>
-
-static const struct cbmem_id_to_name cbmem_ids[] = { CBMEM_ID_TO_NAME_TABLE };
-
-void cbmem_print_entry(int n, u32 id, u64 base, u64 size)
-{
-	int i;
-	const char *name;
-
-	name = NULL;
-	for (i = 0; i < ARRAY_SIZE(cbmem_ids); i++) {
-		if (cbmem_ids[i].id == id) {
-			name = cbmem_ids[i].name;
-			break;
-		}
-	}
-
-	if (name == NULL)
-		printk(BIOS_DEBUG, "%08x ", id);
-	else
-		printk(BIOS_DEBUG, "%s", name);
-	printk(BIOS_DEBUG, "%2d. ", n);
-	printk(BIOS_DEBUG, "%08llx ", base);
-	printk(BIOS_DEBUG, "%08llx\n", size);
-}
diff --git a/src/lib/ramstage.ld b/src/lib/ramstage.ld
new file mode 100644
index 0000000..732c8e9
--- /dev/null
+++ b/src/lib/ramstage.ld
@@ -0,0 +1,117 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2014 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* This file is included inside a SECTIONS block */
+
+/* First we place the code and read only data (typically const declared).
+ * This could theoretically be placed in rom.
+ */
+.text : {
+	_program = .;
+	_ramstage = .;
+	_text = .;
+	*(.text._start);
+	*(.text.stage_entry);
+	*(.text);
+	*(.text.*);
+	. = ALIGN(16);
+	_etext = .;
+} : to_load
+
+#ifdef CONFIG_COVERAGE
+.ctors : {
+	. = ALIGN(0x100);
+	__CTOR_LIST__ = .;
+	KEEP(*(.ctors));
+	LONG(0);
+	LONG(0);
+	__CTOR_END__ = .;
+}
+#endif
+
+/* TODO: align data sections to cache lines? (is that really useful?) */
+.rodata : {
+	_rodata = .;
+	. = ALIGN(8);
+
+	/* If any changes are made to the driver start/symbols or the
+	 * section names the equivalent changes need to made to
+	 * rmodule.ld. */
+	console_drivers = .;
+	KEEP(*(.rodata.console_drivers));
+	econsole_drivers = . ;
+	. = ALIGN(8);
+	pci_drivers = . ;
+	KEEP(*(.rodata.pci_driver));
+	epci_drivers = . ;
+	cpu_drivers = . ;
+	KEEP(*(.rodata.cpu_driver));
+	ecpu_drivers = . ;
+	_bs_init_begin = .;
+	KEEP(*(.bs_init));
+	_bs_init_end = .;
+	_cbmem_init_hooks = .;
+	KEEP(*(.rodata.cbmem_init_hooks));
+	_ecbmem_init_hooks = .;
+
+	*(.rodata)
+	*(.rodata.*)
+	/* kevinh/Ispiri - Added an align, because the objcopy tool
+	 * incorrectly converts sections that are not long word aligned.
+	 */
+	 . = ALIGN(8);
+
+	_erodata = .;
+}
+
+.data : {
+	/* Move to different cache line to avoid false sharing with .rodata. */
+	. = ALIGN(64);	/* May not be actual line size, not that important. */
+	_data = .;
+	*(.data)
+	*(.data.*)
+	_edata = .;
+}
+
+.bss . : {
+	_bss = .;
+	*(.bss)
+	*(.bss.*)
+	*(.sbss)
+	*(.sbss.*)
+	_ebss = .;
+}
+
+.heap . : {
+	_heap = .;
+	/* Reserve CONFIG_HEAP_SIZE bytes for the heap */
+	. += CONFIG_HEAP_SIZE ;
+	. = ALIGN(4);
+	_eheap = .;
+	_eramstage = .;
+	_eprogram = .;
+}
+
+/* Discard the sections we don't need/want */
+
+/DISCARD/ : {
+	*(.comment)
+	*(.note)
+	*(.note.*)
+}
diff --git a/src/lib/rmodule.ld b/src/lib/rmodule.ld
index f3e7cba..ad2c852 100644
--- a/src/lib/rmodule.ld
+++ b/src/lib/rmodule.ld
@@ -48,6 +48,9 @@ SECTIONS
 		_bs_init_begin = .;
 		*(.bs_init)
 		_bs_init_end = .;
+		_cbmem_init_hooks = .;
+		KEEP(*(.rodata.cbmem_init_hooks));
+		_ecbmem_init_hooks = .;
 
 		. = ALIGN(8);
 
diff --git a/src/lib/romstage.ld b/src/lib/romstage.ld
new file mode 100644
index 0000000..bbad333
--- /dev/null
+++ b/src/lib/romstage.ld
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2014 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* This file is included inside a SECTIONS block */
+
+.text . : {
+	_program = .;
+	_romstage = .;
+	*(.text._start);
+	*(.text.stage_entry);
+	*(.text);
+	*(.text.*);
+} : to_load
+
+.data . : {
+	. = ALIGN(8);
+	_cbmem_init_hooks = .;
+	KEEP(*(.rodata.cbmem_init_hooks));
+	_ecbmem_init_hooks = .;
+	*(.rodata);
+	*(.rodata.*);
+	*(.data);
+	*(.data.*);
+	. = ALIGN(8);
+}
+
+.bss . : {
+	. = ALIGN(8);
+	_bss = .;
+	*(.bss)
+	*(.bss.*)
+	*(.sbss)
+	*(.sbss.*)
+	_ebss = .;
+	_eromstage = .;
+	_eprogram = .;
+}
+
+/* Discard the sections we don't need/want */
+/DISCARD/ : {
+	*(.comment)
+	*(.note)
+	*(.comment.*)
+	*(.note.*)
+	*(.eh_frame);
+}
diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c
index f0ee48d..f757252 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -164,4 +164,4 @@ void timestamp_reinit(void)
 }
 
 /* Call timestamp_reinit at CAR migration time. */
-CAR_MIGRATE(timestamp_reinit)
+ROMSTAGE_CBMEM_INIT_HOOK(timestamp_reinit)
diff --git a/src/soc/intel/baytrail/romstage/romstage.c b/src/soc/intel/baytrail/romstage/romstage.c
index b69b532..63e7bf4 100644
--- a/src/soc/intel/baytrail/romstage/romstage.c
+++ b/src/soc/intel/baytrail/romstage/romstage.c
@@ -178,7 +178,7 @@ static void migrate_power_state(void)
 	}
 	memcpy(ps_cbmem, ps_car, sizeof(*ps_cbmem));
 }
-CAR_MIGRATE(migrate_power_state);
+ROMSTAGE_CBMEM_INIT_HOOK(migrate_power_state)
 
 static struct chipset_power_state *fill_power_state(void)
 {
diff --git a/src/soc/intel/broadwell/romstage/power_state.c b/src/soc/intel/broadwell/romstage/power_state.c
index 6e333c1..5871ad9 100644
--- a/src/soc/intel/broadwell/romstage/power_state.c
+++ b/src/soc/intel/broadwell/romstage/power_state.c
@@ -50,7 +50,7 @@ static void migrate_power_state(void)
 	}
 	memcpy(ps_cbmem, ps_car, sizeof(*ps_cbmem));
 }
-CAR_MIGRATE(migrate_power_state);
+ROMSTAGE_CBMEM_INIT_HOOK(migrate_power_state)
 
 /* Return 0, 3, or 5 to indicate the previous sleep state. */
 static int prev_sleep_state(struct chipset_power_state *ps)



More information about the coreboot-gerrit mailing list