summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2017-08-01 10:27:10 -0600
committerAaron Durbin <adurbin@chromium.org>2017-08-04 04:29:57 +0000
commitdfdea2aa40ab5bebea580601f6cef70bec25e177 (patch)
tree23682d5d296c79f2a2bb71c98b4fd5300fdea99f /src
parent403fdbc2265fc1192798cec0878c8e9b587732e3 (diff)
lib/cbmem: provide optional cbmem top initialization hook
Provide a hook to allow an optional one-time cbmem_top() initialization. The new function, cbmem_top_init(), is called on the first expected initialization of cbmem based on the Kconfig options LATE_CBMEM_INIT and EARLY_CBMEM_INIT. Change-Id: I89edd2d11f226217c8e2aaca829b4f375a2cff28 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Signed-off-by: John Zhao <john.zhao@intel.com> Reviewed-on: https://review.coreboot.org/20847 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/cbmem.h5
-rw-r--r--src/lib/imd_cbmem.c21
2 files changed, 26 insertions, 0 deletions
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index b2d2a8be6c..007bc54b76 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -64,6 +64,11 @@ int cbmem_initialize_id_size(u32 id, u64 size);
void cbmem_initialize_empty(void);
void cbmem_initialize_empty_id_size(u32 id, u64 size);
+/* Optional hook for platforms to initialize cbmem_top() value. When employed
+ * it's called a single time during boot at cbmem initialization/recovery
+ * time. */
+void cbmem_top_init(void);
+
/* Return the top address for dynamic cbmem. The address returned needs to
* be consistent across romstage and ramstage, and it is required to be
* below 4GiB.
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());