summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2014-12-31 18:34:59 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2015-01-27 22:42:10 +0100
commite45542580c1765720dbfbd8b4076296e442a211b (patch)
treed07d5d17d9cd265d711d5818eb1585c023099414 /src/cpu
parent823edda98e6512d3f455b61549efea6fa68ee2b0 (diff)
CBMEM console: Fix CAR migration step
With the change it becomes irrelevant if memcpy() car.global_data or cbmemc_reinit() is done first. Change-Id: Ie479eef346c959e97dcc55861ccb0db1321fb7b2 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/8032 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@google.com> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/x86/car.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/cpu/x86/car.c b/src/cpu/x86/car.c
index c9cc6d6178..e757f0912c 100644
--- a/src/cpu/x86/car.c
+++ b/src/cpu/x86/car.c
@@ -73,6 +73,38 @@ void *car_get_var_ptr(void *var)
return &migrated_base[offset];
}
+/*
+ * Update a CAR_GLOBAL variable var, originally pointing to CAR region,
+ * with the address in migrated CAR region in DRAM.
+ */
+void *car_sync_var_ptr(void *var)
+{
+ void ** mig_var = car_get_var_ptr(var);
+ void * _car_start = &_car_data_start;
+ void * _car_end = &_car_data_end;
+
+ /* Not moved or migrated yet. */
+ if (mig_var == var)
+ return mig_var;
+
+ /* It's already pointing outside car.global_data. */
+ if (*mig_var < _car_start || *mig_var > _car_end)
+ return mig_var;
+
+#if !IS_ENABLED(CONFIG_PLATFORM_USES_FSP)
+ /* Keep console buffer in CAR until cbmemc_reinit() moves it. */
+ if (*mig_var == _car_end)
+ return mig_var;
+#endif
+
+ /* Move the pointer by the same amount the variable storing it was
+ * moved by.
+ */
+ *mig_var += (char *)mig_var - (char *)var;
+
+ return mig_var;
+}
+
static void do_car_migrate_variables(void)
{
void *migrated_base;