summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/x86/car.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/src/cpu/x86/car.c b/src/cpu/x86/car.c
index 6fc61686df..009ac192cc 100644
--- a/src/cpu/x86/car.c
+++ b/src/cpu/x86/car.c
@@ -77,41 +77,36 @@ void *car_get_var_ptr(void *var)
return &migrated_base[offset];
}
+#if CONFIG(PLATFORM_USES_FSP1_0)
/*
- * Update a CAR_GLOBAL variable var, originally pointing to CAR region,
- * with the address in migrated CAR region in DRAM.
+ * When a CAR_GLOBAL points to target object inside CAR, use relative
+ * addressing. Such CAR_GLOBAL has to be expicitly accessed using
+ * car_set_reloc_ptr() and car_get_reloc_ptr() as the stored value is now
+ * an offset instead of the absolute address (pointer) of the target.
+ *
+ * This way discovery of objects that are not CAR_GLOBALs themselves,
+ * remain discoverable after CAR migration has implicitly happened.
*/
-void *car_sync_var_ptr(void *var)
+void car_set_reloc_ptr(void *var, void *val)
{
- void **mig_var = car_get_var_ptr(var);
- void *_car_start = _car_relocatable_data_start;
- void *_car_end = _car_relocatable_data_end;
+ uintptr_t *offset = car_get_var_ptr(var);
+ *offset = 0;
- /* Not moved or migrated yet. */
- if (mig_var == var)
- return mig_var;
-
- /*
- * Migrate the cbmem console pointer for FSP 1.0 platforms. Otherwise,
- * keep console buffer in CAR until cbmemc_reinit() moves it.
- */
- if (*mig_var == _preram_cbmem_console) {
- if (CONFIG(PLATFORM_USES_FSP1_0))
- *mig_var += (char *)mig_var - (char *)var;
- return mig_var;
- }
+ if (val)
+ *offset = (uintptr_t)offset - (uintptr_t)val;
+}
- /* It's already pointing outside car.global_data. */
- if (*mig_var < _car_start || *mig_var > _car_end)
- return mig_var;
+void *car_get_reloc_ptr(void *var)
+{
+ uintptr_t *offset = car_get_var_ptr(var);
+ void *val = NULL;
- /* Move the pointer by the same amount the variable storing it was
- * moved by.
- */
- *mig_var += (char *)mig_var - (char *)var;
+ if (*offset)
+ val = (void *)((uintptr_t)offset - *offset);
- return mig_var;
+ return val;
}
+#endif
int car_active(void)
{