summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/cbmem.h1
-rw-r--r--src/include/cpu/x86/car.h29
2 files changed, 30 insertions, 0 deletions
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index 67cb1cb7e5..baec780156 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -69,6 +69,7 @@
#define CBMEM_ID_RAMSTAGE_CACHE 0x9a3ca54e
#define CBMEM_ID_ROOT 0xff4007ff
#define CBMEM_ID_VBOOT_HANDOFF 0x780074f0
+#define CBMEM_ID_CAR_GLOBALS 0xcac4e6a3
#define CBMEM_ID_NONE 0x00000000
#ifndef __ASSEMBLER__
diff --git a/src/include/cpu/x86/car.h b/src/include/cpu/x86/car.h
index 2d2af03a37..7b5cedf213 100644
--- a/src/include/cpu/x86/car.h
+++ b/src/include/cpu/x86/car.h
@@ -28,4 +28,33 @@
#define CAR_CBMEM
#endif
+#if CONFIG_CAR_MIGRATION && defined(__PRE_RAM__)
+#define CAR_MIGRATE_ATTR __attribute__ ((used,section (".car.migrate")))
+
+/* Call migrate_fn_() when CAR globals are migrated. */
+#define CAR_MIGRATE(migrate_fn_) \
+ static void (* const migrate_fn_ ## _ptr)(void) CAR_MIGRATE_ATTR = \
+ migrate_fn_;
+
+/* Get the correct pointer for the CAR global variable. */
+void *car_get_var_ptr(void *var);
+
+/* Get and set a primitive type global variable. */
+#define car_get_var(var) \
+ *(typeof(var) *)car_get_var_ptr(&(var))
+#define car_set_var(var, val) \
+ do { car_get_var(var) = (val); } while(0)
+
+/* Migrate the CAR variables to memory. */
+void car_migrate_variables(void);
+
+#else
+#define CAR_MIGRATE(migrate_fn_)
+static inline void *car_get_var_ptr(void *var) { return var; }
+#define car_get_var(var) (var)
+#define car_set_var(var, val) do { (var) = (val); } while (0)
+static inline void car_migrate_variables(void) { }
+#endif
+
+
#endif