diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2015-01-07 04:48:43 +0200 |
---|---|---|
committer | Marc Jones <marc.jones@se-eng.com> | 2015-06-09 17:22:17 +0200 |
commit | 4fbac465246d3cdfc91d4331be5a567f8783cc6f (patch) | |
tree | 4dc46d3e1f135d4fcc88e2ccd105d593d1b12177 /src/include | |
parent | a8bda437d1f409c7e357a51e2b0f4d91bef31107 (diff) |
cbmem: Unify CBMEM init tasks with CBMEM_INIT_HOOK() API
Squashed and adjusted two changes from chromium.git. Covers
CBMEM init for ROMTAGE and RAMSTAGE.
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@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232612
Reviewed-by: Aaron Durbin <adurbin@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@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233533
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Change-Id: I1be89bafacfe85cba63426e2d91f5d8d4caa1800
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Reviewed-on: http://review.coreboot.org/7878
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/cbmem.h | 22 | ||||
-rw-r--r-- | src/include/console/cbmem_console.h | 6 | ||||
-rw-r--r-- | src/include/cpu/x86/gdt.h | 3 | ||||
-rw-r--r-- | src/include/symbols.h | 4 | ||||
-rw-r--r-- | src/include/timestamp.h | 2 |
5 files changed, 26 insertions, 11 deletions
diff --git a/src/include/cbmem.h b/src/include/cbmem.h index 7afe960116..55b04b4106 100644 --- a/src/include/cbmem.h +++ b/src/include/cbmem.h @@ -22,6 +22,7 @@ #define _CBMEM_H_ #include <cbmem_id.h> +#include <rules.h> #if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) && \ ! IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE) @@ -112,6 +113,7 @@ void *cbmem_add(u32 id, u64 size); /* Find a cbmem entry of a given id. These return NULL on failure. */ void *cbmem_find(u32 id); +typedef void (* const cbmem_init_hook_t)(void); void cbmem_run_init_hooks(void); void cbmem_fail_resume(void); @@ -122,6 +124,26 @@ void cbmem_add_bootmem(void); void cbmem_list(void); #endif /* __PRE_RAM__ */ +#if ENV_RAMSTAGE +#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_; +#elif ENV_ROMSTAGE +#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_; +#else +#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_ ## _unused2_ __attribute__((unused)) = init_fn_; +#endif /* ENV_RAMSTAGE */ + + /* These are for compatibility with old boards only. Any new chipset and board * must implement cbmem_top() for both romstage and ramstage to support * early features like COLLECT_TIMESTAMPS and CBMEM_CONSOLE. diff --git a/src/include/console/cbmem_console.h b/src/include/console/cbmem_console.h index e9ec66ee9e..06013f2a22 100644 --- a/src/include/console/cbmem_console.h +++ b/src/include/console/cbmem_console.h @@ -25,12 +25,6 @@ void cbmemc_init(void); void cbmemc_tx_byte(unsigned char data); -#if CONFIG_CONSOLE_CBMEM -void cbmemc_reinit(void); -#else -static inline void cbmemc_reinit(void) {} -#endif - #define __CBMEM_CONSOLE_ENABLE__ CONFIG_CONSOLE_CBMEM && \ (ENV_RAMSTAGE || (IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) && \ (ENV_ROMSTAGE || (ENV_BOOTBLOCK && CONFIG_BOOTBLOCK_CONSOLE)))) diff --git a/src/include/cpu/x86/gdt.h b/src/include/cpu/x86/gdt.h index 8525a3cd44..a96b0e4083 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/include/symbols.h b/src/include/symbols.h index 4a47de1f41..9102e82952 100644 --- a/src/include/symbols.h +++ b/src/include/symbols.h @@ -33,6 +33,10 @@ extern u8 _epreram_cbmem_console[]; #define _preram_cbmem_console_size \ (_epreram_cbmem_console - _preram_cbmem_console) +extern u8 _cbmem_init_hooks[]; +extern u8 _ecbmem_init_hooks[]; +#define _cbmem_init_hooks_size (_ecbmem_init_hooks - _cbmem_init_hooks) + extern u8 _stack[]; extern u8 _estack[]; #define _stack_size (_estack - _stack) diff --git a/src/include/timestamp.h b/src/include/timestamp.h index d9afeea0c1..a248ea45cd 100644 --- a/src/include/timestamp.h +++ b/src/include/timestamp.h @@ -92,12 +92,10 @@ enum timestamp_id { void timestamp_init(uint64_t base); void timestamp_add(enum timestamp_id id, uint64_t ts_time); void timestamp_add_now(enum timestamp_id id); -void timestamp_reinit(void); #else #define timestamp_init(base) #define timestamp_add(id, time) #define timestamp_add_now(id) -#define timestamp_reinit() #endif /* Implemented by the architecture code */ |