From 6fdb223859959c5fe9392c0e5a34d6090cdeebeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Tue, 5 Mar 2019 16:48:25 +0200 Subject: arch/x86: Refactor CAR_GLOBAL quirk for FSP1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These platforms return to romstage from FSP only after already having torn CAR down. A copy of the entire CAR region is available and discoverable via HOB. Previously, CBMEM console detected on-the-fly that CAR migration had happened and relocated cbmem_console_p accoringlin with car_sync_var(). However, if the CAR_GLOBAL pointing to another object inside CAR is a relative offset instead, we have a more generic solution that can be used with timestamps code as well. Change-Id: Ica877b47e68d56189e9d998b5630019d4328a419 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/35140 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/arch/x86/include/arch/early_variables.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/arch/x86') diff --git a/src/arch/x86/include/arch/early_variables.h b/src/arch/x86/include/arch/early_variables.h index 3910a820da..8111e7e10b 100644 --- a/src/arch/x86/include/arch/early_variables.h +++ b/src/arch/x86/include/arch/early_variables.h @@ -33,19 +33,25 @@ asm(".previous"); /* Get the correct pointer for the CAR global variable. */ void *car_get_var_ptr(void *var); -/* Get and update a CAR_GLOBAL pointing elsewhere in car.global_data*/ -void *car_sync_var_ptr(void *var); - /* Return 1 when currently running with globals in Cache-as-RAM, 0 otherwise. */ int car_active(void); /* Get and set a primitive type global variable. */ #define car_get_var(var) \ (*(typeof(var) *)car_get_var_ptr(&(var))) -#define car_sync_var(var) \ - (*(typeof(var) *)car_sync_var_ptr(&(var))) #define car_set_var(var, val) car_get_var(var) = (val) +/* Get and set a CAR_GLOBAL pointing elsewhere inside CAR. */ +#if !CONFIG(PLATFORM_USES_FSP1_0) +#define car_get_ptr car_get_var +#define car_set_ptr car_set_var +#else +void *car_get_reloc_ptr(void *var); +void car_set_reloc_ptr(void *var, void *val); +#define car_get_ptr(var) car_get_reloc_ptr(&(var)) +#define car_set_ptr(var, val) car_set_reloc_ptr(&(var), (val)) +#endif + static inline size_t car_data_size(void) { size_t car_size = _car_relocatable_data_size; @@ -66,8 +72,9 @@ static inline size_t car_object_offset(void *ptr) #define CAR_GLOBAL #define car_get_var(var) (var) -#define car_sync_var(var) (var) #define car_set_var(var, val) (var) = (val) +#define car_get_ptr car_get_var +#define car_set_ptr car_set_var static inline void *car_get_var_ptr(void *var) { -- cgit v1.2.3