diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/cbmem_common.c | 22 | ||||
-rw-r--r-- | src/lib/cbmem_console.c | 7 | ||||
-rw-r--r-- | src/lib/ramstage.ld | 3 | ||||
-rw-r--r-- | src/lib/rmodule.ld | 3 | ||||
-rw-r--r-- | src/lib/romstage.ld | 4 | ||||
-rw-r--r-- | src/lib/timestamp.c | 7 |
6 files changed, 27 insertions, 19 deletions
diff --git a/src/lib/cbmem_common.c b/src/lib/cbmem_common.c index e9beb5fe6a..496bafa986 100644 --- a/src/lib/cbmem_common.c +++ b/src/lib/cbmem_common.c @@ -20,30 +20,28 @@ #include <cbmem.h> #include <bootstate.h> #include <rules.h> +#include <symbols.h> #if IS_ENABLED(CONFIG_ARCH_X86) && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) #include <arch/acpi.h> #endif -/* FIXME: Remove after CBMEM_INIT_HOOKS. */ -#include <console/cbmem_console.h> -#include <timestamp.h> - - -/* FIXME: Replace with CBMEM_INIT_HOOKS API. */ -#if !IS_ENABLED(CONFIG_ARCH_X86) void cbmem_run_init_hooks(void) { - /* Relocate CBMEM console. */ - cbmemc_reinit(); + cbmem_init_hook_t *init_hook_ptr = (cbmem_init_hook_t*) &_cbmem_init_hooks; + cbmem_init_hook_t *einit_hook_ptr = (cbmem_init_hook_t*) &_ecbmem_init_hooks; - /* Relocate timestamps stash. */ - timestamp_reinit(); + if (_cbmem_init_hooks_size == 0) + return; + + while (init_hook_ptr != einit_hook_ptr) { + (*init_hook_ptr)(); + init_hook_ptr++; + } } void __attribute__((weak)) cbmem_fail_resume(void) { } -#endif #if ENV_RAMSTAGE && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) static void init_cbmem_post_device(void *unused) diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c index e9607f3a35..48664543fc 100644 --- a/src/lib/cbmem_console.c +++ b/src/lib/cbmem_console.c @@ -208,7 +208,7 @@ static void copy_console_buffer(struct cbmem_console *old_cons_p, new_cons_p->buffer_cursor = cursor; } -void cbmemc_reinit(void) +static void cbmemc_reinit(void) { struct cbmem_console *cbm_cons_p; const size_t size = CONFIG_CONSOLE_CBMEM_BUFFER_SIZE; @@ -233,6 +233,8 @@ void cbmemc_reinit(void) init_console_ptr(cbm_cons_p, size, flags); } +ROMSTAGE_CBMEM_INIT_HOOK(cbmemc_reinit) +RAMSTAGE_CBMEM_INIT_HOOK(cbmemc_reinit) #if IS_ENABLED(CONFIG_CONSOLE_CBMEM_DUMP_TO_UART) void cbmem_dump_console(void) @@ -249,6 +251,3 @@ void cbmem_dump_console(void) uart_tx_byte(0, cbm_cons_p->buffer_body[cursor]); } #endif - -/* Call cbmemc_reinit() at CAR migration time. */ -CAR_MIGRATE(cbmemc_reinit) diff --git a/src/lib/ramstage.ld b/src/lib/ramstage.ld index 30b18a7bea..402f495714 100644 --- a/src/lib/ramstage.ld +++ b/src/lib/ramstage.ld @@ -64,6 +64,9 @@ LONG(0); LONG(0); _bs_init_end = .; + _cbmem_init_hooks = .; + KEEP(*(.rodata.cbmem_init_hooks)); + _ecbmem_init_hooks = .; *(.rodata) *(.rodata.*) diff --git a/src/lib/rmodule.ld b/src/lib/rmodule.ld index 70a2d3df8e..0e9c8804e8 100644 --- a/src/lib/rmodule.ld +++ b/src/lib/rmodule.ld @@ -55,6 +55,9 @@ SECTIONS LONG(0); LONG(0); _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 index 34e76c0c48..7d552a76b1 100644 --- a/src/lib/romstage.ld +++ b/src/lib/romstage.ld @@ -29,6 +29,10 @@ } : to_load .data . : { + . = ALIGN(8); + _cbmem_init_hooks = .; + KEEP(*(.rodata.cbmem_init_hooks)); + _ecbmem_init_hooks = .; *(.rodata); *(.rodata.*); *(.data); diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c index 8c82649863..3b886b62c6 100644 --- a/src/lib/timestamp.c +++ b/src/lib/timestamp.c @@ -157,7 +157,7 @@ void timestamp_init(uint64_t base) #endif } -void timestamp_reinit(void) +static void timestamp_reinit(void) { if (!timestamp_should_run()) return; @@ -172,8 +172,9 @@ void timestamp_reinit(void) timestamp_do_sync(); } -/* Call timestamp_reinit at CAR migration time. */ -CAR_MIGRATE(timestamp_reinit) +/* Call timestamp_reinit CBMEM init hooks. */ +ROMSTAGE_CBMEM_INIT_HOOK(timestamp_reinit) +RAMSTAGE_CBMEM_INIT_HOOK(timestamp_reinit) /* Provide default timestamp implementation using monotonic timer. */ uint64_t __attribute__((weak)) timestamp_get(void) |