From 42e6856436e6ee1f9b8ae1039ac5a0921e001377 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Tue, 9 Jun 2015 13:55:51 -0500 Subject: stage_cache: use cbmem init hooks Instead of having the chipset code make the approrpiate calls at the appropriate places use the cbmem init hooks to take the appropriate action. That way no chipset code needs to be changed in order to support the external stage cache. Change-Id: If74e6155ae86646bde02b2e1b550ade92b8ba9bb Signed-off-by: Aaron Durbin Reviewed-on: http://review.coreboot.org/10481 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/lib/cbmem_stage_cache.c | 5 ----- src/lib/ext_stage_cache.c | 17 ++++++++++------- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cbmem_stage_cache.c b/src/lib/cbmem_stage_cache.c index b9ee14e7be..4a114438bb 100644 --- a/src/lib/cbmem_stage_cache.c +++ b/src/lib/cbmem_stage_cache.c @@ -22,11 +22,6 @@ #include #include - -/* Provide empty implementations by default. */ -void __attribute__((weak)) stage_cache_create_empty(void) {} -void __attribute__((weak)) stage_cache_recover(void) {} - /* Stage cache uses cbmem. */ void stage_cache_add(int stage_id, struct prog *stage) { diff --git a/src/lib/ext_stage_cache.c b/src/lib/ext_stage_cache.c index 379b9fcffa..4e588f1c01 100644 --- a/src/lib/ext_stage_cache.c +++ b/src/lib/ext_stage_cache.c @@ -33,7 +33,7 @@ static inline struct imd *imd_get(void) return car_get_var_ptr(&imd_stage_cache); } -void stage_cache_create_empty(void) +static void stage_cache_create_empty(void) { struct imd *imd; void *base; @@ -49,7 +49,7 @@ void stage_cache_create_empty(void) printk(BIOS_DEBUG, "Could not limit stage cache size.\n"); } -void stage_cache_recover(void) +static void stage_cache_recover(void) { struct imd *imd; void *base; @@ -120,10 +120,13 @@ void stage_cache_load_stage(int stage_id, struct prog *stage) prog_set_entry(stage, (void *)(uintptr_t)meta->entry_addr, NULL); } -#if ENV_RAMSTAGE -static void recover_sc(void *unused) +static void stage_cache_setup(int is_recovery) { - stage_cache_recover(); + if (is_recovery) + stage_cache_recover(); + else + stage_cache_create_empty(); } -BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, recover_sc, NULL); -#endif + +ROMSTAGE_CBMEM_INIT_HOOK(stage_cache_setup) +RAMSTAGE_CBMEM_INIT_HOOK(stage_cache_setup) -- cgit v1.2.3