bootstate: remove need for #ifdef ENV_RAMSTAGE

The BOOT_STATE_INIT_ENTRY macro can only be used in ramstage, however
the current state of the header meant bad build errors in non-ramstage.
Therefore, people had to #ifdef in the source. Remove that requirement.

Change-Id: I8755fc68bbaca6b72fbe8b4db4bcc1ccb35622bd
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/11492
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Aaron Durbin 2015-09-02 17:34:04 -05:00
parent c6a177d500
commit 4d3de7e328
9 changed files with 12 additions and 38 deletions

View File

@ -134,8 +134,6 @@ void print_fsp_info(FSP_INFO_HEADER *fsp_header)
#endif #endif
} }
#if ENV_RAMSTAGE
void fsp_notify(u32 phase) void fsp_notify(u32 phase)
{ {
FSP_NOTIFY_PHASE notify_phase_proc; FSP_NOTIFY_PHASE notify_phase_proc;
@ -189,8 +187,6 @@ BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY,
fsp_notify_boot_state_callback, fsp_notify_boot_state_callback,
(void *)EnumInitPhaseReadyToBoot); (void *)EnumInitPhaseReadyToBoot);
#endif /* ENV_RAMSTAGE */
struct fsp_runtime { struct fsp_runtime {
uint32_t fih; uint32_t fih;
uint32_t hob_list; uint32_t hob_list;

View File

@ -19,8 +19,7 @@
#ifndef BOOTSTATE_H #ifndef BOOTSTATE_H
#define BOOTSTATE_H #define BOOTSTATE_H
#if !defined(__SMM__) && !defined(__PRE_RAM__) #include <rules.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
@ -173,8 +172,10 @@ int boot_state_unblock(boot_state_t state, boot_state_sequence_t seq);
void boot_state_current_block(void); void boot_state_current_block(void);
void boot_state_current_unblock(void); void boot_state_current_unblock(void);
#if ENV_RAMSTAGE
/* Entry into the boot state machine. */ /* Entry into the boot state machine. */
void main(void); void main(void);
#endif
/* In order to schedule boot state callbacks at compile-time specify the /* In order to schedule boot state callbacks at compile-time specify the
* entries in an array using the BOOT_STATE_INIT_ENTRIES and * entries in an array using the BOOT_STATE_INIT_ENTRIES and
@ -185,7 +186,11 @@ struct boot_state_init_entry {
struct boot_state_callback bscb; struct boot_state_callback bscb;
}; };
#if ENV_RAMSTAGE
#define BOOT_STATE_INIT_ATTR __attribute__ ((used,section (".bs_init"))) #define BOOT_STATE_INIT_ATTR __attribute__ ((used,section (".bs_init")))
#else
#define BOOT_STATE_INIT_ATTR __attribute__ ((unused))
#endif
#define BOOT_STATE_INIT_ENTRY(state_, when_, func_, arg_) \ #define BOOT_STATE_INIT_ENTRY(state_, when_, func_, arg_) \
static struct boot_state_init_entry func_ ##_## state_ ##_## when_ = \ static struct boot_state_init_entry func_ ##_## state_ ##_## when_ = \
@ -198,5 +203,4 @@ struct boot_state_init_entry {
bsie_ ## func_ ##_## state_ ##_## when_ BOOT_STATE_INIT_ATTR = \ bsie_ ## func_ ##_## state_ ##_## when_ BOOT_STATE_INIT_ATTR = \
& func_ ##_## state_ ##_## when_; & func_ ##_## state_ ##_## when_;
#endif
#endif /* BOOTSTATE_H */ #endif /* BOOTSTATE_H */

View File

@ -128,7 +128,7 @@ static struct mrc_data_container *find_current_mrc_cache_local
/* SPI code needs malloc/free. /* SPI code needs malloc/free.
* Also unknown if writing flash from XIP-flash code is a good idea * Also unknown if writing flash from XIP-flash code is a good idea
*/ */
#if !defined(__PRE_RAM__)
/* find the first empty block in the MRC cache area. /* find the first empty block in the MRC cache area.
* If there's none, return NULL. * If there's none, return NULL.
* *
@ -229,7 +229,6 @@ static void update_mrc_cache(void *unused)
} }
BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, update_mrc_cache, NULL); BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, update_mrc_cache, NULL);
#endif
struct mrc_data_container *find_current_mrc_cache(void) struct mrc_data_container *find_current_mrc_cache(void)
{ {

View File

@ -128,7 +128,7 @@ static struct mrc_data_container *find_current_mrc_cache_local
/* SPI code needs malloc/free. /* SPI code needs malloc/free.
* Also unknown if writing flash from XIP-flash code is a good idea * Also unknown if writing flash from XIP-flash code is a good idea
*/ */
#if !defined(__PRE_RAM__)
/* find the first empty block in the MRC cache area. /* find the first empty block in the MRC cache area.
* If there's none, return NULL. * If there's none, return NULL.
* *
@ -229,7 +229,6 @@ static void update_mrc_cache(void *unused)
} }
BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, update_mrc_cache, NULL); BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, update_mrc_cache, NULL);
#endif
struct mrc_data_container *find_current_mrc_cache(void) struct mrc_data_container *find_current_mrc_cache(void)
{ {

View File

@ -316,14 +316,12 @@ void spi_init(void)
ich_set_bbar(0); ich_set_bbar(0);
} }
#ifndef __SMM__
static void spi_init_cb(void *unused) static void spi_init_cb(void *unused)
{ {
spi_init(); spi_init();
} }
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL); BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
#endif
int spi_claim_bus(struct spi_slave *slave) int spi_claim_bus(struct spi_slave *slave)
{ {

View File

@ -295,8 +295,6 @@ void spi_init(void)
cntlr.preop = &ich9_spi->preop; cntlr.preop = &ich9_spi->preop;
} }
#if ENV_RAMSTAGE
static void spi_init_cb(void *unused) static void spi_init_cb(void *unused)
{ {
spi_init(); spi_init();
@ -304,8 +302,6 @@ static void spi_init_cb(void *unused)
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL); BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
#endif /* ENV_RAMSTAGE */
int spi_claim_bus(struct spi_slave *slave) int spi_claim_bus(struct spi_slave *slave)
{ {
/* Handled by ICH automatically. */ /* Handled by ICH automatically. */

View File

@ -312,14 +312,12 @@ void spi_init(void)
pci_write_config_byte(dev, 0xdc, bios_cntl | 0x1); pci_write_config_byte(dev, 0xdc, bios_cntl | 0x1);
} }
#if ENV_RAMSTAGE
static void spi_init_cb(void *unused) static void spi_init_cb(void *unused)
{ {
spi_init(); spi_init();
} }
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL); BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
#endif
int spi_claim_bus(struct spi_slave *slave) int spi_claim_bus(struct spi_slave *slave)
{ {

View File

@ -18,11 +18,13 @@
*/ */
#include <string.h> #include <string.h>
#include <bootstate.h>
#include <console/console.h> #include <console/console.h>
#include <cbmem.h> #include <cbmem.h>
#include <fmap.h> #include <fmap.h>
#include <ip_checksum.h> #include <ip_checksum.h>
#include "mrc_cache.h" #include "mrc_cache.h"
#include "nvm.h"
#define MRC_DATA_ALIGN 0x1000 #define MRC_DATA_ALIGN 0x1000
#define MRC_DATA_SIGNATURE (('M'<<0)|('R'<<8)|('C'<<16)|('D'<<24)) #define MRC_DATA_SIGNATURE (('M'<<0)|('R'<<8)|('C'<<16)|('D'<<24))
@ -154,12 +156,6 @@ int mrc_cache_get_current(const struct mrc_saved_data **cache)
return __mrc_cache_get_current(&region, cache); return __mrc_cache_get_current(&region, cache);
} }
#if ENV_ROMSTAGE
/*
* romstage code
*/
/* Fill in mrc_saved_data structure with payload. */ /* Fill in mrc_saved_data structure with payload. */
static void mrc_cache_fill(struct mrc_saved_data *cache, void *data, static void mrc_cache_fill(struct mrc_saved_data *cache, void *data,
size_t size) size_t size)
@ -197,15 +193,6 @@ int mrc_cache_stash_data(void *data, size_t size)
return 0; return 0;
} }
#else
/*
* ramstage code
*/
#include <bootstate.h>
#include "nvm.h"
static int mrc_slot_valid(const struct mrc_data_region *region, static int mrc_slot_valid(const struct mrc_data_region *region,
const struct mrc_saved_data *slot, const struct mrc_saved_data *slot,
const struct mrc_saved_data *to_save) const struct mrc_saved_data *to_save)
@ -330,5 +317,3 @@ static void update_mrc_cache(void *unused)
} }
BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, update_mrc_cache, NULL); BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, update_mrc_cache, NULL);
#endif /* ENV_ROMSTAGE */

View File

@ -359,14 +359,13 @@ void spi_init(void)
bios_cntl &= ~(1 << 5); bios_cntl &= ~(1 << 5);
pci_write_config_byte(dev, 0xdc, bios_cntl | 0x1); pci_write_config_byte(dev, 0xdc, bios_cntl | 0x1);
} }
#ifndef __SMM__
static void spi_init_cb(void *unused) static void spi_init_cb(void *unused)
{ {
spi_init(); spi_init();
} }
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL); BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
#endif
int spi_claim_bus(struct spi_slave *slave) int spi_claim_bus(struct spi_slave *slave)
{ {