Remove MAYBE_STATIC_BSS and ENV_STAGE_HAS_BSS_SECTION

After removal of CAR_MIGRATION there are no more reasons
to carry around ENV_STAGE_HAS_BSS_SECTION=n case.

Replace 'MAYBE_STATIC_BSS' with 'static' and remove explicit
zero-initializers.

Change-Id: I14dd9f52da5b06f0116bd97496cf794e5e71bc37
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/40535
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Kyösti Mälkki 2020-04-20 10:21:39 +03:00 committed by Patrick Georgi
parent 1c3faabf24
commit fcbbb91116
15 changed files with 14 additions and 25 deletions

View File

@ -62,13 +62,11 @@
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_bss = .;
#if ENV_STAGE_HAS_BSS_SECTION
/* Allow global uninitialized variables for stages without CAR teardown. */
*(.bss)
*(.bss.*)
*(.sbss)
*(.sbss.*)
#endif
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_ebss = .;
_car_unallocated_start = .;

View File

@ -227,7 +227,7 @@ DEVTREE_CONST struct device *pcidev_path_on_bus(unsigned int bus, pci_devfn_t de
DEVTREE_CONST struct bus *pci_root_bus(void)
{
DEVTREE_CONST struct device *pci_domain;
MAYBE_STATIC_BSS DEVTREE_CONST struct bus *pci_root = NULL;
static DEVTREE_CONST struct bus *pci_root;
if (pci_root)
return pci_root;

View File

@ -52,7 +52,7 @@ static enum cb_err get_cmos_value(unsigned long bit, unsigned long length,
static enum cb_err locate_cmos_layout(struct region_device *rdev)
{
uint32_t cbfs_type = CBFS_COMPONENT_CMOS_LAYOUT;
MAYBE_STATIC_BSS struct cbfsf fh = {};
static struct cbfsf fh;
/*
* In case VBOOT is enabled and this function is called from SMM,

View File

@ -1343,7 +1343,7 @@ static void google_chromeec_log_uptimeinfo(void)
/* Cache and retrieve the EC image type (ro or rw) */
enum ec_image google_chromeec_get_current_image(void)
{
MAYBE_STATIC_BSS enum ec_image ec_image_type = EC_IMAGE_UNKNOWN;
static enum ec_image ec_image_type = EC_IMAGE_UNKNOWN;
if (ec_image_type != EC_IMAGE_UNKNOWN)
return ec_image_type;

View File

@ -387,7 +387,7 @@ void google_chromeec_ioport_range(uint16_t *out_base, size_t *out_size)
int google_chromeec_command(struct chromeec_command *cec_command)
{
MAYBE_STATIC_BSS int command_version = 0;
static int command_version;
if (command_version <= 0)
command_version = google_chromeec_command_version();

View File

@ -252,12 +252,9 @@
#define ENV_CACHE_AS_RAM (ENV_ROMSTAGE_OR_BEFORE && !CONFIG(RESET_VECTOR_IN_RAM))
/* No .data sections with execute-in-place from ROM. */
#define ENV_STAGE_HAS_DATA_SECTION !ENV_CACHE_AS_RAM
/* No .bss sections for stage with CAR teardown. */
#define ENV_STAGE_HAS_BSS_SECTION 1
#else
/* Both .data and .bss, sometimes SRAM not DRAM. */
#define ENV_STAGE_HAS_DATA_SECTION 1
#define ENV_STAGE_HAS_BSS_SECTION 1
#define ENV_CACHE_AS_RAM 0
#endif

View File

@ -41,12 +41,6 @@ typedef unsigned int wint_t;
#define MAYBE_STATIC_NONZERO
#endif
#if ENV_STAGE_HAS_BSS_SECTION
#define MAYBE_STATIC_BSS static
#else
#define MAYBE_STATIC_BSS
#endif
/* Provide a pointer to address 0 that thwarts any "accessing this is
* undefined behaviour and do whatever" trickery in compilers.
* Use when you _really_ need to read32(zeroptr) (ie. read address 0).

View File

@ -19,7 +19,7 @@ static struct imd imd;
void *cbmem_top(void)
{
if (ENV_ROMSTAGE) {
MAYBE_STATIC_BSS void *top = NULL;
static void *top;
if (top)
return top;
top = cbmem_top_chipset();

View File

@ -26,7 +26,7 @@ size_t ulzman(const void *src, size_t srcn, void *dst, size_t dstn)
int res;
CLzmaDecoderState state;
SizeT mallocneeds;
MAYBE_STATIC_BSS unsigned char scratchpad[15980];
static unsigned char scratchpad[15980];
const unsigned char *cp;
if (srcn < data_offset) {

View File

@ -112,7 +112,7 @@
}
#endif
#if ENV_STAGE_HAS_BSS_SECTION && !ENV_CACHE_AS_RAM
#if !ENV_CACHE_AS_RAM
.bss . : {
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_bss = .;

View File

@ -53,8 +53,8 @@ int get_lid_switch(void)
*/
int get_recovery_mode_switch(void)
{
MAYBE_STATIC_BSS int ec_in_rec_mode = 0;
MAYBE_STATIC_BSS int ec_rec_flag_good = 0;
static int ec_in_rec_mode;
static int ec_rec_flag_good;
if (ec_rec_flag_good)
return ec_in_rec_mode;

View File

@ -11,7 +11,7 @@
static struct tcpa_table *tcpa_cbmem_init(void)
{
MAYBE_STATIC_BSS struct tcpa_table *tclt = NULL;
static struct tcpa_table *tclt;
if (tclt)
return tclt;
@ -32,7 +32,7 @@ static struct tcpa_table *tcpa_cbmem_init(void)
struct tcpa_table *tcpa_log_init(void)
{
MAYBE_STATIC_BSS struct tcpa_table *tclt = NULL;
static struct tcpa_table *tclt;
/* We are dealing here with pre CBMEM environment.
* If cbmem isn't available use CAR or SRAM */

View File

@ -51,7 +51,7 @@
uint32_t nc_read_top_of_low_memory(void)
{
MAYBE_STATIC_BSS uint32_t tolm = 0;
static uint32_t tolm;
if (tolm)
return tolm;

View File

@ -56,7 +56,7 @@
uint32_t nc_read_top_of_low_memory(void)
{
MAYBE_STATIC_BSS uint32_t tolm = 0;
static uint32_t tolm;
if (tolm)
return tolm;

View File

@ -55,7 +55,7 @@ CFLAGS_ppc64 +=
# stack use, we use 1.5K as heuristic, assuming that we typically have lots
# of tiny stack frames and the odd large one.
#
# Store larger buffers in BSS, use MAYBE_STATIC_BSS to share data in cache-as-ram
# Store larger buffers in BSS, use static to share data in cache-as-ram
# on x86.
# Since GCCs detection of dynamic array bounds unfortunately seems to be
# very basic, you'll sometimes have to use a static upper bound for the