diff options
Diffstat (limited to 'src/lib/imd_cbmem.c')
-rw-r--r-- | src/lib/imd_cbmem.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c index ba00c2e9db..5713c2c328 100644 --- a/src/lib/imd_cbmem.c +++ b/src/lib/imd_cbmem.c @@ -109,12 +109,31 @@ void cbmem_initialize_empty(void) cbmem_initialize_empty_id_size(0, 0); } +void __attribute__((weak)) cbmem_top_init(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 for early cbmem init and + ramstage for late cbmem init. */ + if (IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) && !ENV_ROMSTAGE) + return; + if (IS_ENABLED(CONFIG_LATE_CBMEM_INIT) && !ENV_RAMSTAGE) + return; + + cbmem_top_init(); +} + void cbmem_initialize_empty_id_size(u32 id, u64 size) { struct imd *imd; struct imd imd_backing; const int no_recovery = 0; + cbmem_top_init_once(); + imd = imd_init_backing(&imd_backing); imd_handle_init(imd, cbmem_top()); @@ -145,6 +164,8 @@ int cbmem_initialize_id_size(u32 id, u64 size) struct imd imd_backing; const int recovery = 1; + cbmem_top_init_once(); + imd = imd_init_backing(&imd_backing); imd_handle_init(imd, cbmem_top()); |