1) wraps the s3 parts of chipset code/memory init code with if CONFIG_HAVE_ACPI_RESUM...
[coreboot.git] / src / lib / cbmem.c
index 5490a1fef6dd6195a3f83047abf0d2c3487c1978..d85c74881014e44a7d550b6908fb37f2e6d9aed3 100644 (file)
@@ -36,11 +36,32 @@ struct cbmem_entry {
        u64 size;
 } __attribute__((packed));
 
-#ifndef __PRE_RAM__
-struct cbmem_entry *bss_cbmem_toc;
-#define get_cbmem_toc()        bss_cbmem_toc
+
+#ifdef __PRE_RAM__
+
+/* note this should be done as weak function but we do #include
+   of C files in the romstage breaking this (in same compile
+   unit is weak and non weak function
+struct cbmem_entry *__attribute__((weak)) get_cbmem_toc(void)
+*/
+#ifndef get_cbmem_toc
+       #define get_cbmem_toc() (struct cbmem_entry *)(get_top_of_ram() - HIGH_MEMORY_SIZE)
+#endif
+
 #else
-#define get_cbmem_toc()        (struct cbmem_entry *)(get_top_of_ram() - HIGH_MEMORY_SIZE)
+
+static struct cbmem_entry *bss_cbmem_toc;
+
+struct cbmem_entry *__attribute__((weak)) get_cbmem_toc(void)
+{
+       return bss_cbmem_toc;
+}
+
+void __attribute__((weak)) set_cbmem_toc(struct cbmem_entry * x)
+{
+       /* do nothing, this should be called by chipset to save TOC in NVRAM */
+}
+
 #endif
 
 /**
@@ -70,6 +91,10 @@ void cbmem_init(u64 baseaddr, u64 size)
                for (;;) ;
        }
 
+       /* we don't need to call this in romstage, usefull only from ramstage */
+#ifndef __PRE_RAM__
+       set_cbmem_toc((struct cbmem_entry *)(unsigned long)baseaddr);
+#endif
        memset(cbmem_toc, 0, CBMEM_TOC_RESERVED);
 
        cbmem_toc[0] = (struct cbmem_entry) {