aboutsummaryrefslogtreecommitdiff
path: root/src/arch/x86/cbmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86/cbmem.c')
-rw-r--r--src/arch/x86/cbmem.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/arch/x86/cbmem.c b/src/arch/x86/cbmem.c
index 578bb8a4ed..e35d43cecb 100644
--- a/src/arch/x86/cbmem.c
+++ b/src/arch/x86/cbmem.c
@@ -18,49 +18,47 @@
#if IS_ENABLED(CONFIG_LATE_CBMEM_INIT)
-#if !defined(__PRE_RAM__)
void __attribute__((weak)) backup_top_of_ram(uint64_t ramtop)
{
/* Do nothing. Chipset may have implementation to save ramtop in NVRAM.
*/
}
-static void *ramtop_pointer;
-
-void set_top_of_ram(uint64_t ramtop)
+unsigned long __attribute__((weak)) get_top_of_ram(void)
{
- backup_top_of_ram(ramtop);
- ramtop_pointer = (void *)(uintptr_t)ramtop;
+ return 0;
}
-static inline void *saved_ramtop(void)
-{
- return ramtop_pointer;
-}
-#else
-static inline void *saved_ramtop(void)
-{
- return NULL;
-}
-#endif /* !__PRE_RAM__ */
+#endif /* LATE_CBMEM_INIT */
-unsigned long __attribute__((weak)) get_top_of_ram(void)
+#if IS_ENABLED(CONFIG_CBMEM_TOP_BACKUP)
+
+static void *ramtop_pointer;
+
+void set_top_of_ram(uint64_t ramtop)
{
- return 0;
+ backup_top_of_ram(ramtop);
+ if (ENV_RAMSTAGE)
+ ramtop_pointer = (void *)(uintptr_t)ramtop;
}
void *cbmem_top(void)
{
/* Top of cbmem is at lowest usable DRAM address below 4GiB. */
- void *ptr = saved_ramtop();
+ uintptr_t ramtop;
+
+ if (ENV_RAMSTAGE && ramtop_pointer != NULL)
+ return ramtop_pointer;
- if (ptr != NULL)
- return ptr;
+ ramtop = get_top_of_ram();
- return (void *)get_top_of_ram();
+ if (ENV_RAMSTAGE)
+ ramtop_pointer = (void *)ramtop;
+
+ return (void *)ramtop;
}
-#endif /* LATE_CBMEM_INIT */
+#endif /* CBMEM_TOP_BACKUP */
/* Something went wrong, our high memory area got wiped */
void cbmem_fail_resume(void)