summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2022-04-06 10:53:17 +0300
committerKyösti Mälkki <kyosti.malkki@gmail.com>2022-04-26 05:51:08 +0000
commit845f232502e32c1e6b1b092f21225f3cb49d5d1a (patch)
tree51a528cec4cbc388a8f87878e52bcf61ef8eecbc /src/lib
parentf4b8538701de06fca1b91a8d47c3ebd6947e8f51 (diff)
FMAP: Refactor CBMEM hook
Change-Id: Ib1257c57c64322c8c3dccdf1a754afb9b54ce7f8 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/63395 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/fmap.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/fmap.c b/src/lib/fmap.c
index 251125522e..4d197db5ff 100644
--- a/src/lib/fmap.c
+++ b/src/lib/fmap.c
@@ -273,7 +273,7 @@ ssize_t fmap_overwrite_area(const char *name, const void *buffer, size_t size)
return rdev_writeat(&rdev, buffer, 0, size);
}
-static void fmap_register_cbmem_cache(int unused)
+static void fmap_register_cbmem_cache(void)
{
const struct cbmem_entry *e;
@@ -290,7 +290,7 @@ static void fmap_register_cbmem_cache(int unused)
* The main reason to copy the FMAP into CBMEM is to make it available to the
* OS on every architecture. As side effect use the CBMEM copy as cache.
*/
-static void fmap_setup_cbmem_cache(int unused)
+static void fmap_add_cbmem_cache(void)
{
struct region_device fmrd;
@@ -311,11 +311,17 @@ static void fmap_setup_cbmem_cache(int unused)
cbmem_entry_remove(cbmem_entry_find(CBMEM_ID_FMAP));
return;
}
+}
+
+static void fmap_setup_cbmem_cache(int unused)
+{
+ if (ENV_ROMSTAGE)
+ fmap_add_cbmem_cache();
/* Finally advertise the cache for the current stage */
- fmap_register_cbmem_cache(unused);
+ fmap_register_cbmem_cache();
}
ROMSTAGE_CBMEM_INIT_HOOK(fmap_setup_cbmem_cache)
-RAMSTAGE_CBMEM_INIT_HOOK(fmap_register_cbmem_cache)
-POSTCAR_CBMEM_INIT_HOOK(fmap_register_cbmem_cache)
+RAMSTAGE_CBMEM_INIT_HOOK(fmap_setup_cbmem_cache)
+POSTCAR_CBMEM_INIT_HOOK(fmap_setup_cbmem_cache)