arch/x86: Simplify <arch/early_variables.h>
This enables the use of .bss section for ENV_BOOTBLOCK and ENV_VERSTAGE even with CAR_GLOBAL_MIGRATION=y. In practice, boards with CAR_GLOBAL_MIGRATION=y currently build with romcc-bootblock so they will not be using .bss. Change-Id: Ie9dc14f3e528d3e4f48304f4d7de50df448a8af6 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/35016 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
parent
19e1d631e3
commit
a165c07ed7
|
@ -76,8 +76,8 @@
|
||||||
* cbmem console. This is useful for clearing this area on a per-stage
|
* cbmem console. This is useful for clearing this area on a per-stage
|
||||||
* basis when more than one stage uses cache-as-ram for CAR_GLOBALs. */
|
* basis when more than one stage uses cache-as-ram for CAR_GLOBALs. */
|
||||||
_car_global_start = .;
|
_car_global_start = .;
|
||||||
#if !CONFIG(CAR_GLOBAL_MIGRATION)
|
#if ENV_STAGE_HAS_BSS_SECTION
|
||||||
/* Allow global unitialized variables when CAR_GLOBALs are not used. */
|
/* Allow global uninitialized variables for stages without CAR teardown. */
|
||||||
*(.bss)
|
*(.bss)
|
||||||
*(.bss.*)
|
*(.bss.*)
|
||||||
*(.sbss)
|
*(.sbss)
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
#include <commonlib/helpers.h>
|
#include <commonlib/helpers.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#if ENV_CACHE_AS_RAM && CONFIG(CAR_GLOBAL_MIGRATION)
|
#if ENV_ROMSTAGE && CONFIG(CAR_GLOBAL_MIGRATION)
|
||||||
|
|
||||||
asm(".section .car.global_data,\"w\",@nobits");
|
asm(".section .car.global_data,\"w\",@nobits");
|
||||||
asm(".previous");
|
asm(".previous");
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
@ -29,27 +30,6 @@ asm(".previous");
|
||||||
#define CAR_GLOBAL __attribute__((used, section(".car.global_data#")))
|
#define CAR_GLOBAL __attribute__((used, section(".car.global_data#")))
|
||||||
#endif /* __clang__ */
|
#endif /* __clang__ */
|
||||||
|
|
||||||
/*
|
|
||||||
* In stages that use CAR (verstage, C bootblock) all CAR_GLOBAL variables are
|
|
||||||
* accessed unconditionally because cbmem is never initialized until romstage
|
|
||||||
* when dram comes up.
|
|
||||||
*/
|
|
||||||
#if !ENV_ROMSTAGE
|
|
||||||
static inline void *car_get_var_ptr(void *var)
|
|
||||||
{
|
|
||||||
return var;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *car_sync_var_ptr(void *var)
|
|
||||||
{
|
|
||||||
return var;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int car_active(void)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* Get the correct pointer for the CAR global variable. */
|
/* Get the correct pointer for the CAR global variable. */
|
||||||
void *car_get_var_ptr(void *var);
|
void *car_get_var_ptr(void *var);
|
||||||
|
|
||||||
|
@ -58,7 +38,6 @@ void *car_sync_var_ptr(void *var);
|
||||||
|
|
||||||
/* Return 1 when currently running with globals in Cache-as-RAM, 0 otherwise. */
|
/* Return 1 when currently running with globals in Cache-as-RAM, 0 otherwise. */
|
||||||
int car_active(void);
|
int car_active(void);
|
||||||
#endif /* !ENV_ROMSTAGE */
|
|
||||||
|
|
||||||
/* Get and set a primitive type global variable. */
|
/* Get and set a primitive type global variable. */
|
||||||
#define car_get_var(var) \
|
#define car_get_var(var) \
|
||||||
|
@ -81,26 +60,25 @@ static inline size_t car_object_offset(void *ptr)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We might end up here if:
|
* For all stages other than romstage, all CAR_GLOBAL variables are accessed
|
||||||
* 1. ENV_CACHE_AS_RAM is not set for the stage or
|
* unconditionally as there is no migration of symbols.
|
||||||
* 2. ENV_CACHE_AS_RAM is set for the stage but CONFIG_CAR_GLOBAL_MIGRATION
|
|
||||||
* is not set. In this case, there is no need to migrate CAR global
|
|
||||||
* variables. But, since we might still be running out of CAR, car_active needs
|
|
||||||
* to return 1 if ENV_CACHE_AS_RAM is set.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CAR_GLOBAL
|
#define CAR_GLOBAL
|
||||||
static inline void *car_get_var_ptr(void *var) { return var; }
|
|
||||||
|
|
||||||
#if ENV_CACHE_AS_RAM
|
|
||||||
static inline int car_active(void) { return 1; }
|
|
||||||
#else
|
|
||||||
static inline int car_active(void) { return 0; }
|
|
||||||
#endif /* ENV_CACHE_AS_RAM */
|
|
||||||
|
|
||||||
#define car_get_var(var) (var)
|
#define car_get_var(var) (var)
|
||||||
#define car_sync_var(var) (var)
|
#define car_sync_var(var) (var)
|
||||||
#define car_set_var(var, val) (var) = (val)
|
#define car_set_var(var, val) (var) = (val)
|
||||||
#endif /* ENV_CACHE_AS_RAM && CONFIG(CAR_GLOBAL_MIGRATION) */
|
|
||||||
|
static inline void *car_get_var_ptr(void *var)
|
||||||
|
{
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int car_active(void)
|
||||||
|
{
|
||||||
|
return ENV_CACHE_AS_RAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* ARCH_EARLY_VARIABLES_H */
|
#endif /* ARCH_EARLY_VARIABLES_H */
|
||||||
|
|
|
@ -363,7 +363,7 @@ static int read_from_cbfs(const char *name, void *buf, size_t size)
|
||||||
|
|
||||||
int paging_enable_for_car(const char *pdpt_name, const char *pt_name)
|
int paging_enable_for_car(const char *pdpt_name, const char *pt_name)
|
||||||
{
|
{
|
||||||
if (!ENV_CACHE_AS_RAM)
|
if (!preram_symbols_available())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (read_from_cbfs(pdpt_name, _pdpt, REGION_SIZE(pdpt))) {
|
if (read_from_cbfs(pdpt_name, _pdpt, REGION_SIZE(pdpt))) {
|
||||||
|
@ -383,7 +383,7 @@ int paging_enable_for_car(const char *pdpt_name, const char *pt_name)
|
||||||
|
|
||||||
static void *get_pdpt_addr(void)
|
static void *get_pdpt_addr(void)
|
||||||
{
|
{
|
||||||
if (ENV_CACHE_AS_RAM)
|
if (preram_symbols_available())
|
||||||
return _pdpt;
|
return _pdpt;
|
||||||
return (void *)(uintptr_t)read_cr3();
|
return (void *)(uintptr_t)read_cr3();
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,8 +274,8 @@
|
||||||
#define ENV_CACHE_AS_RAM ENV_ROMSTAGE_OR_BEFORE
|
#define ENV_CACHE_AS_RAM ENV_ROMSTAGE_OR_BEFORE
|
||||||
/* No .data sections with execute-in-place from ROM. */
|
/* No .data sections with execute-in-place from ROM. */
|
||||||
#define ENV_STAGE_HAS_DATA_SECTION !ENV_CACHE_AS_RAM
|
#define ENV_STAGE_HAS_DATA_SECTION !ENV_CACHE_AS_RAM
|
||||||
/* No .bss sections with execute-in-place from ROM. */
|
/* No .bss sections for stage with CAR teardown. */
|
||||||
#define ENV_STAGE_HAS_BSS_SECTION !ENV_CACHE_AS_RAM
|
#define ENV_STAGE_HAS_BSS_SECTION !(ENV_ROMSTAGE && CONFIG(CAR_GLOBAL_MIGRATION))
|
||||||
#else
|
#else
|
||||||
/* Both .data and .bss, sometimes SRAM not DRAM. */
|
/* Both .data and .bss, sometimes SRAM not DRAM. */
|
||||||
#define ENV_STAGE_HAS_DATA_SECTION 1
|
#define ENV_STAGE_HAS_DATA_SECTION 1
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENV_STAGE_HAS_BSS_SECTION
|
#if ENV_STAGE_HAS_BSS_SECTION && !ENV_CACHE_AS_RAM
|
||||||
.bss . : {
|
.bss . : {
|
||||||
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
|
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
|
||||||
_bss = .;
|
_bss = .;
|
||||||
|
|
Loading…
Reference in New Issue