romstage_handoff: remove code duplication
The same pattern was being used throughout the code base for initializing the romstage handoff structure. Provide a helper function to initialize the structure with the S3 resume state then utilize it at all the existing call sites. Change-Id: I1e9d588ab6b9ace67757387dbb5963ae31ceb252 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/17646 Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
parent
c1d72942f4
commit
77e13997d3
|
@ -129,14 +129,7 @@ void post_cache_as_ram(void)
|
||||||
|
|
||||||
prepare_romstage_ramstack(s3resume);
|
prepare_romstage_ramstack(s3resume);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)) {
|
romstage_handoff_init(s3resume);
|
||||||
struct romstage_handoff *handoff;
|
|
||||||
handoff = romstage_handoff_find_or_add();
|
|
||||||
if (handoff != NULL)
|
|
||||||
handoff->s3_resume = s3resume;
|
|
||||||
else
|
|
||||||
printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* from here don't store more data in CAR */
|
/* from here don't store more data in CAR */
|
||||||
if (family >= 0x1f && family <= 0x3f) {
|
if (family >= 0x1f && family <= 0x3f) {
|
||||||
|
|
|
@ -172,7 +172,6 @@ void romstage_common(const struct romstage_params *params)
|
||||||
{
|
{
|
||||||
int boot_mode;
|
int boot_mode;
|
||||||
int wake_from_s3;
|
int wake_from_s3;
|
||||||
struct romstage_handoff *handoff;
|
|
||||||
|
|
||||||
timestamp_init(get_initial_timestamp());
|
timestamp_init(get_initial_timestamp());
|
||||||
timestamp_add_now(TS_START_ROMSTAGE);
|
timestamp_add_now(TS_START_ROMSTAGE);
|
||||||
|
@ -245,11 +244,7 @@ void romstage_common(const struct romstage_params *params)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
handoff = romstage_handoff_find_or_add();
|
romstage_handoff_init(wake_from_s3);
|
||||||
if (handoff != NULL)
|
|
||||||
handoff->s3_resume = wake_from_s3;
|
|
||||||
else
|
|
||||||
printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
|
|
||||||
|
|
||||||
post_code(0x3f);
|
post_code(0x3f);
|
||||||
if (IS_ENABLED(CONFIG_LPC_TPM)) {
|
if (IS_ENABLED(CONFIG_LPC_TPM)) {
|
||||||
|
|
|
@ -99,7 +99,6 @@ void *cache_as_ram_stage_main(FSP_INFO_HEADER *fih)
|
||||||
void romstage_common(struct romstage_params *params)
|
void romstage_common(struct romstage_params *params)
|
||||||
{
|
{
|
||||||
const struct mrc_saved_data *cache;
|
const struct mrc_saved_data *cache;
|
||||||
struct romstage_handoff *handoff;
|
|
||||||
struct pei_data *pei_data;
|
struct pei_data *pei_data;
|
||||||
|
|
||||||
post_code(0x32);
|
post_code(0x32);
|
||||||
|
@ -165,14 +164,9 @@ void romstage_common(struct romstage_params *params)
|
||||||
mainboard_save_dimm_info(params);
|
mainboard_save_dimm_info(params);
|
||||||
|
|
||||||
/* Create romstage handof information */
|
/* Create romstage handof information */
|
||||||
handoff = romstage_handoff_find_or_add();
|
if (romstage_handoff_init(
|
||||||
if (handoff != NULL)
|
params->power_state->prev_sleep_state == ACPI_S3) < 0)
|
||||||
handoff->s3_resume = (params->power_state->prev_sleep_state ==
|
|
||||||
ACPI_S3);
|
|
||||||
else {
|
|
||||||
printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
|
|
||||||
hard_reset();
|
hard_reset();
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the TPM, unless the TPM was already initialized
|
* Initialize the TPM, unless the TPM was already initialized
|
||||||
|
|
|
@ -117,7 +117,6 @@ static void save_memory_training_data(bool s3wake, uint32_t fsp_version)
|
||||||
static void do_fsp_post_memory_init(bool s3wake, uint32_t fsp_version)
|
static void do_fsp_post_memory_init(bool s3wake, uint32_t fsp_version)
|
||||||
{
|
{
|
||||||
struct range_entry fsp_mem;
|
struct range_entry fsp_mem;
|
||||||
struct romstage_handoff *handoff;
|
|
||||||
|
|
||||||
if (fsp_find_reserved_memory(&fsp_mem))
|
if (fsp_find_reserved_memory(&fsp_mem))
|
||||||
die("Failed to find FSP_RESERVED_MEMORY_RESOURCE_HOB!\n");
|
die("Failed to find FSP_RESERVED_MEMORY_RESOURCE_HOB!\n");
|
||||||
|
@ -144,11 +143,7 @@ static void do_fsp_post_memory_init(bool s3wake, uint32_t fsp_version)
|
||||||
save_memory_training_data(s3wake, fsp_version);
|
save_memory_training_data(s3wake, fsp_version);
|
||||||
|
|
||||||
/* Create romstage handof information */
|
/* Create romstage handof information */
|
||||||
handoff = romstage_handoff_find_or_add();
|
romstage_handoff_init(s3wake);
|
||||||
if (handoff != NULL)
|
|
||||||
handoff->s3_resume = s3wake;
|
|
||||||
else
|
|
||||||
printk(BIOS_SPEW, "Romstage handoff structure not added!\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *mrc_cache_get_region_name(void)
|
static const char *mrc_cache_get_region_name(void)
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <cbmem.h>
|
#include <cbmem.h>
|
||||||
|
#include <console/console.h>
|
||||||
|
#include <rules.h>
|
||||||
|
|
||||||
/* It is the chipset's responsibility for maintaining the integrity of this
|
/* It is the chipset's responsibility for maintaining the integrity of this
|
||||||
* structure in CBMEM. For instance, if chipset code adds this structure
|
* structure in CBMEM. For instance, if chipset code adds this structure
|
||||||
|
@ -48,13 +50,32 @@ static inline struct romstage_handoff *romstage_handoff_find_or_add(void)
|
||||||
* found so it can be initialized to 0. */
|
* found so it can be initialized to 0. */
|
||||||
handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
|
handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
|
||||||
|
|
||||||
if (handoff == NULL) {
|
if (handoff)
|
||||||
|
return handoff;
|
||||||
|
|
||||||
handoff = cbmem_add(CBMEM_ID_ROMSTAGE_INFO, sizeof(*handoff));
|
handoff = cbmem_add(CBMEM_ID_ROMSTAGE_INFO, sizeof(*handoff));
|
||||||
|
|
||||||
if (handoff != NULL)
|
if (handoff != NULL)
|
||||||
memset(handoff, 0, sizeof(*handoff));
|
memset(handoff, 0, sizeof(*handoff));
|
||||||
}
|
else
|
||||||
|
printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
|
||||||
|
|
||||||
return handoff;
|
return handoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns 0 if initialized. Else < 0 if handoff structure not added. */
|
||||||
|
static inline int romstage_handoff_init(int is_s3_resume)
|
||||||
|
{
|
||||||
|
struct romstage_handoff *handoff;
|
||||||
|
|
||||||
|
handoff = romstage_handoff_find_or_add();
|
||||||
|
|
||||||
|
if (handoff == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
handoff->s3_resume = is_s3_resume;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* ROMSTAGE_HANDOFF_H */
|
#endif /* ROMSTAGE_HANDOFF_H */
|
||||||
|
|
|
@ -227,13 +227,7 @@ void sandybridge_early_initialization(int chipset_type)
|
||||||
|
|
||||||
void northbridge_romstage_finalize(int s3resume)
|
void northbridge_romstage_finalize(int s3resume)
|
||||||
{
|
{
|
||||||
struct romstage_handoff *handoff;
|
|
||||||
|
|
||||||
MCHBAR16(SSKPD) = 0xCAFE;
|
MCHBAR16(SSKPD) = 0xCAFE;
|
||||||
|
|
||||||
handoff = romstage_handoff_find_or_add();
|
romstage_handoff_init(s3resume);
|
||||||
if (handoff != NULL)
|
|
||||||
handoff->s3_resume = s3resume;
|
|
||||||
else
|
|
||||||
printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,6 @@ static int chipset_prev_sleep_state(struct chipset_power_state *ps)
|
||||||
/* Entry from the mainboard. */
|
/* Entry from the mainboard. */
|
||||||
void romstage_common(struct romstage_params *params)
|
void romstage_common(struct romstage_params *params)
|
||||||
{
|
{
|
||||||
struct romstage_handoff *handoff;
|
|
||||||
struct chipset_power_state *ps;
|
struct chipset_power_state *ps;
|
||||||
int prev_sleep_state;
|
int prev_sleep_state;
|
||||||
|
|
||||||
|
@ -232,11 +231,7 @@ void romstage_common(struct romstage_params *params)
|
||||||
|
|
||||||
timestamp_add_now(TS_AFTER_INITRAM);
|
timestamp_add_now(TS_AFTER_INITRAM);
|
||||||
|
|
||||||
handoff = romstage_handoff_find_or_add();
|
romstage_handoff_init(prev_sleep_state == ACPI_S3);
|
||||||
if (handoff != NULL)
|
|
||||||
handoff->s3_resume = (prev_sleep_state == ACPI_S3);
|
|
||||||
else
|
|
||||||
printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
|
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_LPC_TPM)) {
|
if (IS_ENABLED(CONFIG_LPC_TPM)) {
|
||||||
init_tpm(prev_sleep_state == ACPI_S3);
|
init_tpm(prev_sleep_state == ACPI_S3);
|
||||||
|
|
|
@ -89,8 +89,6 @@ void * asmlinkage romstage_main(unsigned long bist,
|
||||||
/* Entry from the mainboard. */
|
/* Entry from the mainboard. */
|
||||||
void romstage_common(struct romstage_params *params)
|
void romstage_common(struct romstage_params *params)
|
||||||
{
|
{
|
||||||
struct romstage_handoff *handoff;
|
|
||||||
|
|
||||||
post_code(0x32);
|
post_code(0x32);
|
||||||
|
|
||||||
timestamp_add_now(TS_BEFORE_INITRAM);
|
timestamp_add_now(TS_BEFORE_INITRAM);
|
||||||
|
@ -114,12 +112,7 @@ void romstage_common(struct romstage_params *params)
|
||||||
|
|
||||||
timestamp_add_now(TS_AFTER_INITRAM);
|
timestamp_add_now(TS_AFTER_INITRAM);
|
||||||
|
|
||||||
handoff = romstage_handoff_find_or_add();
|
romstage_handoff_init(params->power_state->prev_sleep_state == ACPI_S3);
|
||||||
if (handoff != NULL)
|
|
||||||
handoff->s3_resume = (params->power_state->prev_sleep_state ==
|
|
||||||
ACPI_S3);
|
|
||||||
else
|
|
||||||
printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
|
|
||||||
|
|
||||||
#if CONFIG_LPC_TPM
|
#if CONFIG_LPC_TPM
|
||||||
init_tpm(params->power_state->prev_sleep_state == ACPI_S3);
|
init_tpm(params->power_state->prev_sleep_state == ACPI_S3);
|
||||||
|
|
|
@ -218,7 +218,6 @@ void romstage_main_continue(EFI_STATUS status, void *hob_list_ptr)
|
||||||
int cbmem_was_initted;
|
int cbmem_was_initted;
|
||||||
void *cbmem_hob_ptr;
|
void *cbmem_hob_ptr;
|
||||||
uint32_t prev_sleep_state;
|
uint32_t prev_sleep_state;
|
||||||
struct romstage_handoff *handoff;
|
|
||||||
|
|
||||||
timestamp_add_now(TS_AFTER_INITRAM);
|
timestamp_add_now(TS_AFTER_INITRAM);
|
||||||
|
|
||||||
|
@ -257,11 +256,7 @@ void romstage_main_continue(EFI_STATUS status, void *hob_list_ptr)
|
||||||
*(u32*)cbmem_hob_ptr = (u32)hob_list_ptr;
|
*(u32*)cbmem_hob_ptr = (u32)hob_list_ptr;
|
||||||
post_code(0x4e);
|
post_code(0x4e);
|
||||||
|
|
||||||
handoff = romstage_handoff_find_or_add();
|
romstage_handoff_init(prev_sleep_state == ACPI_S3);
|
||||||
if (handoff != NULL)
|
|
||||||
handoff->s3_resume = (prev_sleep_state == ACPI_S3);
|
|
||||||
else
|
|
||||||
printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
|
|
||||||
|
|
||||||
post_code(0x4f);
|
post_code(0x4f);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue