summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2013-05-10 00:33:32 -0500
committerAaron Durbin <adurbin@google.com>2013-05-16 01:29:50 +0200
commit716738a6b84535f731ee9749f161505945eab93c (patch)
tree1698dbb1c22e5feca94bba6df30a49ed5f0d8d36 /src/lib
parentadc300d88b35ceafafb4d4b6426c6458dc46b685 (diff)
downloadcoreboot-716738a6b84535f731ee9749f161505945eab93c.tar.xz
x86: add cache-as-ram migration option
There are some boards that do a significant amount of work after cache-as-ram is torn down but before ramstage is loaded. For example, using vboot to verify the ramstage is one such operation. However, there are pieces of code that are executed that reference global variables that are linked in the cache-as-ram region. If those variables are referenced after cache-as-ram is torn down then the values observed will most likely be incorrect. Therefore provide a Kconfig option to select cache-as-ram migration to memory using cbmem. This option is named CAR_MIGRATION. When enabled, the address of cache-as-ram variables may be obtained dynamically. Additionally, when cache-as-ram migration occurs the cache-as-ram data region for global variables is copied into cbmem. There are also automatic callbacks for other modules to perform their own migration, if necessary. Change-Id: I2e77219647c2bd2b1aa845b262be3b2543f1fcb7 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/3232 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cbmem.c4
-rw-r--r--src/lib/cbmem_info.c1
-rw-r--r--src/lib/dynamic_cbmem.c9
3 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/cbmem.c b/src/lib/cbmem.c
index e8200b6045..3702da1e1d 100644
--- a/src/lib/cbmem.c
+++ b/src/lib/cbmem.c
@@ -22,6 +22,7 @@
#include <bootstate.h>
#include <cbmem.h>
#include <console/console.h>
+#include <cpu/x86/car.h>
#if CONFIG_HAVE_ACPI_RESUME && !defined(__PRE_RAM__)
#include <arch/acpi.h>
#endif
@@ -228,6 +229,9 @@ int cbmem_initialize(void)
#ifndef __PRE_RAM__
cbmem_arch_init();
#endif
+ /* Migrate cache-as-ram variables. */
+ car_migrate_variables();
+
return rv;
}
#endif
diff --git a/src/lib/cbmem_info.c b/src/lib/cbmem_info.c
index ad8c890666..7031a70d54 100644
--- a/src/lib/cbmem_info.c
+++ b/src/lib/cbmem_info.c
@@ -46,6 +46,7 @@ static struct cbmem_id_to_name {
{ CBMEM_ID_RAMSTAGE_CACHE, "RAMSTAGE $ " },
{ CBMEM_ID_ROOT, "CBMEM ROOT " },
{ CBMEM_ID_VBOOT_HANDOFF, "VBOOT " },
+ { CBMEM_ID_CAR_GLOBALS, "CAR GLOBALS" },
};
void cbmem_print_entry(int n, u32 id, u64 base, u64 size)
diff --git a/src/lib/dynamic_cbmem.c b/src/lib/dynamic_cbmem.c
index 5c269a0282..ba7760dcd1 100644
--- a/src/lib/dynamic_cbmem.c
+++ b/src/lib/dynamic_cbmem.c
@@ -23,6 +23,7 @@
#include <cbmem.h>
#include <string.h>
#include <stdlib.h>
+#include <cpu/x86/car.h>
#if CONFIG_HAVE_ACPI_RESUME && !defined(__PRE_RAM__)
#include <arch/acpi.h>
#endif
@@ -182,12 +183,17 @@ void cbmem_initialize_empty(void)
root, root->max_entries);
cbmem_arch_init();
+
+ /* Migrate cache-as-ram variables. */
+ car_migrate_variables();
}
static inline int cbmem_fail_recovery(void)
{
cbmem_initialize_empty();
cbmem_handle_acpi_resume();
+ /* Migrate cache-as-ram variables. */
+ car_migrate_variables();
return 1;
}
@@ -256,6 +262,9 @@ int cbmem_initialize(void)
cbmem_arch_init();
+ /* Migrate cache-as-ram variables. */
+ car_migrate_variables();
+
/* Recovery successful. */
return 0;
}