Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/38736 )
Change subject: lib/imd_cbmem.c: Add a helper function to indicate that cbmem is ready ......................................................................
lib/imd_cbmem.c: Add a helper function to indicate that cbmem is ready
This can be used in romstage in particular to know if dram is ready.
Change-Id: I0231ab9c0b78a69faa762e0a97378bf0b50eebaf Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/include/cbmem.h M src/lib/imd_cbmem.c 2 files changed, 19 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/36/38736/1
diff --git a/src/include/cbmem.h b/src/include/cbmem.h index cf79f41..a68d65f 100644 --- a/src/include/cbmem.h +++ b/src/include/cbmem.h @@ -81,6 +81,9 @@ */ void *cbmem_top_chipset(void);
+/* Returns 1 if cbmem is initialized, 0 otherwise */ +int cbmem_ready(void); + /* Add a cbmem entry of a given size and id. These return NULL on failure. The * add function performs a find first and do not check against the original * size. */ diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c index 5be7dc4..864d73e 100644 --- a/src/lib/imd_cbmem.c +++ b/src/lib/imd_cbmem.c @@ -44,6 +44,22 @@ dead_code(); }
+static int cbmem_initialized; + +static void set_cbmem_ready(int unused) +{ + cbmem_initialized = 1; +} + +ROMSTAGE_CBMEM_INIT_HOOK(set_cbmem_ready); +POSTCAR_CBMEM_INIT_HOOK(set_cbmem_ready); +RAMSTAGE_CBMEM_INIT_HOOK(set_cbmem_ready); + +int cbmem_ready(void) +{ + return cbmem_initialized; +} + static inline const struct cbmem_entry *imd_to_cbmem(const struct imd_entry *e) { return (const struct cbmem_entry *)e;