CBMEM: Change declarations for initialization hooks
There are efforts to have bootflows that do not follow a traditional bootblock-romstage-postcar-ramstage model. As part of that CBMEM initialisation hooks will need to move from romstage to bootblock. The interface towards platforms and drivers will change to use one of CBMEM_CREATION_HOOK() or CBMEM_READY_HOOK(). Former will only be called in the first stage with CBMEM available. Change-Id: Ie24bf4e818ca69f539196c3a814f3c52d4103d7e Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/63375 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
committed by
Arthur Heymans
parent
20a87c0bed
commit
fa3bc049f5
@@ -32,7 +32,7 @@ static void switch_to_postram_cache(int unused)
|
||||
mem_pool_init(&cbfs_cache, _postram_cbfs_cache, REGION_SIZE(postram_cbfs_cache),
|
||||
CONFIG_CBFS_CACHE_ALIGN);
|
||||
}
|
||||
ROMSTAGE_CBMEM_INIT_HOOK(switch_to_postram_cache);
|
||||
CBMEM_CREATION_HOOK(switch_to_postram_cache);
|
||||
|
||||
enum cb_err _cbfs_boot_lookup(const char *name, bool force_ro,
|
||||
union cbfs_mdata *mdata, struct region_device *rdev)
|
||||
@@ -693,5 +693,5 @@ static void cbfs_mcache_migrate(int unused)
|
||||
mcache_to_cbmem(vboot_get_cbfs_boot_device(), CBMEM_ID_CBFS_RW_MCACHE);
|
||||
mcache_to_cbmem(cbfs_get_boot_device(true), CBMEM_ID_CBFS_RO_MCACHE);
|
||||
}
|
||||
ROMSTAGE_CBMEM_INIT_HOOK(cbfs_mcache_migrate)
|
||||
CBMEM_CREATION_HOOK(cbfs_mcache_migrate);
|
||||
#endif
|
||||
|
@@ -167,12 +167,10 @@ static void cbmemc_reinit(int is_recovery)
|
||||
copy_console_buffer(previous_cons_p);
|
||||
}
|
||||
|
||||
/* Run the romstage hook early so that the console region is one of the earliest created, and
|
||||
/* Run this hook early so that the console region is one of the earliest created, and
|
||||
therefore more likely to stay in the same place even across different boot modes where some
|
||||
other regions may sometimes not get created (e.g. RW_MCACHE in vboot recovery mode). */
|
||||
ROMSTAGE_CBMEM_INIT_HOOK_EARLY(cbmemc_reinit)
|
||||
RAMSTAGE_CBMEM_INIT_HOOK(cbmemc_reinit)
|
||||
POSTCAR_CBMEM_INIT_HOOK(cbmemc_reinit)
|
||||
CBMEM_READY_HOOK_EARLY(cbmemc_reinit);
|
||||
|
||||
#if CONFIG(CONSOLE_CBMEM_DUMP_TO_UART)
|
||||
void cbmem_dump_console_to_uart(void)
|
||||
|
@@ -158,6 +158,4 @@ static void stage_cache_setup(int is_recovery)
|
||||
stage_cache_create_empty();
|
||||
}
|
||||
|
||||
ROMSTAGE_CBMEM_INIT_HOOK(stage_cache_setup)
|
||||
RAMSTAGE_CBMEM_INIT_HOOK(stage_cache_setup)
|
||||
POSTCAR_CBMEM_INIT_HOOK(stage_cache_setup)
|
||||
CBMEM_READY_HOOK(stage_cache_setup);
|
||||
|
@@ -315,13 +315,11 @@ static void fmap_add_cbmem_cache(void)
|
||||
|
||||
static void fmap_setup_cbmem_cache(int unused)
|
||||
{
|
||||
if (ENV_ROMSTAGE)
|
||||
if (ENV_CREATES_CBMEM)
|
||||
fmap_add_cbmem_cache();
|
||||
|
||||
/* Finally advertise the cache for the current stage */
|
||||
fmap_register_cbmem_cache();
|
||||
}
|
||||
|
||||
ROMSTAGE_CBMEM_INIT_HOOK(fmap_setup_cbmem_cache)
|
||||
RAMSTAGE_CBMEM_INIT_HOOK(fmap_setup_cbmem_cache)
|
||||
POSTCAR_CBMEM_INIT_HOOK(fmap_setup_cbmem_cache)
|
||||
CBMEM_READY_HOOK(fmap_setup_cbmem_cache);
|
||||
|
@@ -17,7 +17,7 @@ static struct imd imd;
|
||||
|
||||
void *cbmem_top(void)
|
||||
{
|
||||
if (ENV_ROMSTAGE) {
|
||||
if (ENV_CREATES_CBMEM) {
|
||||
static void *top;
|
||||
if (top)
|
||||
return top;
|
||||
@@ -49,9 +49,8 @@ void cbmem_initialize_empty(void)
|
||||
|
||||
static void cbmem_top_init_once(void)
|
||||
{
|
||||
/* Call one-time hook on expected cbmem init during boot. This sequence
|
||||
assumes first init call is in romstage. */
|
||||
if (!ENV_ROMSTAGE)
|
||||
/* Call one-time hook on expected cbmem init during boot. */
|
||||
if (!ENV_CREATES_CBMEM)
|
||||
return;
|
||||
|
||||
/* The test is only effective on X86 and when address hits UC memory. */
|
||||
@@ -106,7 +105,7 @@ int cbmem_initialize_id_size(u32 id, u64 size)
|
||||
* if the imd area was recovered in romstage then S3 resume path
|
||||
* is being taken.
|
||||
*/
|
||||
if (ENV_ROMSTAGE)
|
||||
if (ENV_CREATES_CBMEM)
|
||||
imd_lockdown(&imd);
|
||||
|
||||
/* Add the specified range first */
|
||||
@@ -206,8 +205,7 @@ void cbmem_get_region(void **baseptr, size_t *size)
|
||||
imd_region_used(&imd, baseptr, size);
|
||||
}
|
||||
|
||||
#if ENV_PAYLOAD_LOADER || (CONFIG(EARLY_CBMEM_LIST) \
|
||||
&& (ENV_POSTCAR || ENV_ROMSTAGE))
|
||||
#if ENV_PAYLOAD_LOADER || (CONFIG(EARLY_CBMEM_LIST) && ENV_HAS_CBMEM)
|
||||
/*
|
||||
* -fdata-sections doesn't work so well on read only strings. They all
|
||||
* get put in the same section even though those strings may never be
|
||||
|
@@ -24,7 +24,7 @@
|
||||
*(.text);
|
||||
*(.text.*);
|
||||
|
||||
#if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR
|
||||
#if ENV_HAS_CBMEM
|
||||
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
|
||||
_cbmem_init_hooks = .;
|
||||
KEEP(*(.rodata.cbmem_init_hooks_early));
|
||||
|
@@ -215,7 +215,7 @@ static void timestamp_reinit(int is_recovery)
|
||||
|
||||
/* First time into romstage we make a clean new table. For platforms that travel
|
||||
through this path on resume, ARCH_X86 S3, timestamps are also reset. */
|
||||
if (ENV_ROMSTAGE) {
|
||||
if (ENV_CREATES_CBMEM) {
|
||||
ts_cbmem_table = timestamp_alloc_cbmem_table();
|
||||
} else {
|
||||
/* Find existing table in cbmem. */
|
||||
@@ -228,7 +228,7 @@ static void timestamp_reinit(int is_recovery)
|
||||
return;
|
||||
}
|
||||
|
||||
if (ENV_ROMSTAGE)
|
||||
if (ENV_CREATES_CBMEM)
|
||||
timestamp_sync_cache_to_cbmem(ts_cbmem_table);
|
||||
|
||||
/* Seed the timestamp tick frequency in ENV_PAYLOAD_LOADER. */
|
||||
@@ -279,9 +279,7 @@ uint32_t get_us_since_boot(void)
|
||||
return (timestamp_get() - ts->base_time) / ts->tick_freq_mhz;
|
||||
}
|
||||
|
||||
ROMSTAGE_CBMEM_INIT_HOOK(timestamp_reinit)
|
||||
POSTCAR_CBMEM_INIT_HOOK(timestamp_reinit)
|
||||
RAMSTAGE_CBMEM_INIT_HOOK(timestamp_reinit)
|
||||
CBMEM_READY_HOOK(timestamp_reinit);
|
||||
|
||||
/* Provide default timestamp implementation using monotonic timer. */
|
||||
uint64_t __weak timestamp_get(void)
|
||||
|
Reference in New Issue
Block a user