Split MAYBE_STATIC to _BSS and _NONZERO variants
These are required to cover the absensce of .data and .bss sections in some programs, most notably ARCH_X86 in execute-in-place with cache-as-ram. Change-Id: I80485ebac94b88c5864a949b17ad1dccdfda6a40 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/35003 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
parent
f2cc52b694
commit
117cf2bdcb
|
@ -204,7 +204,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 bus *pci_root_bus(void)
|
||||||
{
|
{
|
||||||
DEVTREE_CONST struct device *pci_domain;
|
DEVTREE_CONST struct device *pci_domain;
|
||||||
MAYBE_STATIC DEVTREE_CONST struct bus *pci_root = NULL;
|
MAYBE_STATIC_BSS DEVTREE_CONST struct bus *pci_root = NULL;
|
||||||
|
|
||||||
if (pci_root)
|
if (pci_root)
|
||||||
return pci_root;
|
return pci_root;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
uint32_t board_id(void)
|
uint32_t board_id(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC uint32_t id = BOARD_ID_INIT;
|
MAYBE_STATIC_NONZERO uint32_t id = BOARD_ID_INIT;
|
||||||
|
|
||||||
if (id == BOARD_ID_INIT) {
|
if (id == BOARD_ID_INIT) {
|
||||||
if (google_chromeec_get_board_version(&id))
|
if (google_chromeec_get_board_version(&id))
|
||||||
|
|
|
@ -401,7 +401,7 @@ void google_chromeec_ioport_range(uint16_t *out_base, size_t *out_size)
|
||||||
|
|
||||||
int google_chromeec_command(struct chromeec_command *cec_command)
|
int google_chromeec_command(struct chromeec_command *cec_command)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC int command_version = 0;
|
MAYBE_STATIC_BSS int command_version = 0;
|
||||||
|
|
||||||
if (command_version <= 0)
|
if (command_version <= 0)
|
||||||
command_version = google_chromeec_command_version();
|
command_version = google_chromeec_command_version();
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
uint32_t board_id(void)
|
uint32_t board_id(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC uint32_t id = BOARD_ID_INIT;
|
MAYBE_STATIC_NONZERO uint32_t id = BOARD_ID_INIT;
|
||||||
|
|
||||||
if (id == BOARD_ID_INIT) {
|
if (id == BOARD_ID_INIT) {
|
||||||
uint8_t ec_id;
|
uint8_t ec_id;
|
||||||
|
|
|
@ -35,11 +35,16 @@ typedef unsigned int wint_t;
|
||||||
#define DEVTREE_CONST
|
#define DEVTREE_CONST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Work around non-writable data segment in execute-in-place romstage on x86. */
|
#if ENV_STAGE_HAS_DATA_SECTION
|
||||||
#if defined(__PRE_RAM__) && CONFIG(ARCH_X86)
|
#define MAYBE_STATIC_NONZERO static
|
||||||
#define MAYBE_STATIC
|
|
||||||
#else
|
#else
|
||||||
#define MAYBE_STATIC static
|
#define MAYBE_STATIC_NONZERO
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENV_STAGE_HAS_BSS_SECTION
|
||||||
|
#define MAYBE_STATIC_BSS static
|
||||||
|
#else
|
||||||
|
#define MAYBE_STATIC_BSS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __ROMCC__
|
#ifndef __ROMCC__
|
||||||
|
|
|
@ -26,7 +26,7 @@ size_t ulzman(const void *src, size_t srcn, void *dst, size_t dstn)
|
||||||
int res;
|
int res;
|
||||||
CLzmaDecoderState state;
|
CLzmaDecoderState state;
|
||||||
SizeT mallocneeds;
|
SizeT mallocneeds;
|
||||||
MAYBE_STATIC unsigned char scratchpad[15980];
|
MAYBE_STATIC_BSS unsigned char scratchpad[15980];
|
||||||
const unsigned char *cp;
|
const unsigned char *cp;
|
||||||
|
|
||||||
memcpy(properties, src, LZMA_PROPERTIES_SIZE);
|
memcpy(properties, src, LZMA_PROPERTIES_SIZE);
|
||||||
|
|
|
@ -128,7 +128,7 @@ static int timestamp_should_run(void)
|
||||||
|
|
||||||
static struct timestamp_table *timestamp_table_get(void)
|
static struct timestamp_table *timestamp_table_get(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC struct timestamp_table *ts_table = NULL;
|
MAYBE_STATIC_BSS struct timestamp_table *ts_table = NULL;
|
||||||
struct timestamp_cache *ts_cache;
|
struct timestamp_cache *ts_cache;
|
||||||
|
|
||||||
if (ts_table != NULL)
|
if (ts_table != NULL)
|
||||||
|
|
|
@ -71,8 +71,8 @@ int get_lid_switch(void)
|
||||||
*/
|
*/
|
||||||
int get_recovery_mode_switch(void)
|
int get_recovery_mode_switch(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC int ec_in_rec_mode = 0;
|
MAYBE_STATIC_BSS int ec_in_rec_mode = 0;
|
||||||
MAYBE_STATIC int ec_rec_flag_good = 0;
|
MAYBE_STATIC_BSS int ec_rec_flag_good = 0;
|
||||||
|
|
||||||
if (ec_rec_flag_good)
|
if (ec_rec_flag_good)
|
||||||
return ec_in_rec_mode;
|
return ec_in_rec_mode;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
uint32_t board_id(void)
|
uint32_t board_id(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC int id = -1;
|
MAYBE_STATIC_NONZERO int id = -1;
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
if (CONFIG(EC_GOOGLE_CHROMEEC))
|
if (CONFIG(EC_GOOGLE_CHROMEEC))
|
||||||
id = variant_board_id();
|
id = variant_board_id();
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
int variant_board_id(void)
|
int variant_board_id(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC uint32_t id = BOARD_ID_INIT;
|
MAYBE_STATIC_NONZERO uint32_t id = BOARD_ID_INIT;
|
||||||
|
|
||||||
if (CONFIG(EC_GOOGLE_CHROMEEC)) {
|
if (CONFIG(EC_GOOGLE_CHROMEEC)) {
|
||||||
if (id == BOARD_ID_INIT) {
|
if (id == BOARD_ID_INIT) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ static int get_board_id_via_ext_ec(void)
|
||||||
/* Get Board ID via EC I/O port write/read */
|
/* Get Board ID via EC I/O port write/read */
|
||||||
int get_board_id(void)
|
int get_board_id(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC int id = -1;
|
MAYBE_STATIC_NONZERO int id = -1;
|
||||||
|
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
if (CONFIG(EC_GOOGLE_CHROMEEC))
|
if (CONFIG(EC_GOOGLE_CHROMEEC))
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
int get_ec_boardinfo(void)
|
int get_ec_boardinfo(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC int ec_info = -1;
|
MAYBE_STATIC_NONZERO int ec_info = -1;
|
||||||
if (ec_info < 0) {
|
if (ec_info < 0) {
|
||||||
uint8_t buffer[2];
|
uint8_t buffer[2];
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
static struct tcpa_table *tcpa_cbmem_init(void)
|
static struct tcpa_table *tcpa_cbmem_init(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC struct tcpa_table *tclt = NULL;
|
MAYBE_STATIC_BSS struct tcpa_table *tclt = NULL;
|
||||||
if (tclt)
|
if (tclt)
|
||||||
return tclt;
|
return tclt;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ static struct tcpa_table *tcpa_cbmem_init(void)
|
||||||
|
|
||||||
static struct tcpa_table *tcpa_log_init(void)
|
static struct tcpa_table *tcpa_log_init(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC struct tcpa_table *tclt = NULL;
|
MAYBE_STATIC_BSS struct tcpa_table *tclt = NULL;
|
||||||
|
|
||||||
/* We are dealing here with pre CBMEM environment.
|
/* We are dealing here with pre CBMEM environment.
|
||||||
* If cbmem isn't available use CAR or SRAM */
|
* If cbmem isn't available use CAR or SRAM */
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
uint32_t nc_read_top_of_low_memory(void)
|
uint32_t nc_read_top_of_low_memory(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC uint32_t tolm = 0;
|
MAYBE_STATIC_BSS uint32_t tolm = 0;
|
||||||
|
|
||||||
if (tolm)
|
if (tolm)
|
||||||
return tolm;
|
return tolm;
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
|
|
||||||
uint32_t nc_read_top_of_low_memory(void)
|
uint32_t nc_read_top_of_low_memory(void)
|
||||||
{
|
{
|
||||||
MAYBE_STATIC uint32_t tolm = 0;
|
MAYBE_STATIC_BSS uint32_t tolm = 0;
|
||||||
|
|
||||||
if (tolm)
|
if (tolm)
|
||||||
return tolm;
|
return tolm;
|
||||||
|
|
|
@ -72,7 +72,7 @@ CFLAGS_ppc64 +=
|
||||||
# stack use, we use 1.5K as heuristic, assuming that we typically have lots
|
# stack use, we use 1.5K as heuristic, assuming that we typically have lots
|
||||||
# of tiny stack frames and the odd large one.
|
# of tiny stack frames and the odd large one.
|
||||||
#
|
#
|
||||||
# Store larger buffers in BSS, use MAYBE_STATIC to share code with __PRE_RAM__
|
# Store larger buffers in BSS, use MAYBE_STATIC_BSS to share code with __PRE_RAM__
|
||||||
# on x86.
|
# on x86.
|
||||||
# Since GCCs detection of dynamic array bounds unfortunately seems to be
|
# 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
|
# very basic, you'll sometimes have to use a static upper bound for the
|
||||||
|
|
Loading…
Reference in New Issue