lib: put romstage_handoff implementation in own compilation unit

Instead of putting all the functions inline just put the
current implementation into a C file. That way all the implementation
innards are not exposed.

Lastly, fix up the fallout of compilation units not including the
headers they actually use.

Change-Id: I01fd25d158c0d5016405b73a4d4df3721c281b04
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/17648
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:
Aaron Durbin
2016-11-29 21:37:42 -06:00
parent 6c191d8af4
commit afe8aeed81
8 changed files with 91 additions and 72 deletions

View File

@@ -15,80 +15,10 @@
#ifndef ROMSTAGE_HANDOFF_H
#define ROMSTAGE_HANDOFF_H
#include <stdint.h>
#include <string.h>
#include <cbmem.h>
#include <console/console.h>
#include <rules.h>
/* It is the chipset's responsibility for maintaining the integrity of this
* structure in CBMEM. For instance, if chipset code adds this structure
* using the CBMEM_ID_ROMSTAGE_INFO id it needs to ensure it doesn't clobber
* fields it doesn't own. */
struct romstage_handoff {
/* Indicate if the current boot is an S3 resume. If
* CONFIG_RELOCTABLE_RAMSTAGE is enabled the chipset code is
* responsible for initializing this variable. Otherwise, ramstage
* will be re-loaded from cbfs (which can be slower since it lives
* in flash). */
uint8_t s3_resume;
uint8_t reboot_required;
uint8_t reserved[2];
};
/* The romstage_handoff_find_or_add() function provides the necessary logic
* for initializing the romstage_handoff structure in cbmem. Different components
* of the romstage may be responsible for setting up different fields. Therefore
* that same logic flow should be used for allocating and initializing the
* structure. A newly allocated structure will be memset to 0. */
static inline struct romstage_handoff *romstage_handoff_find_or_add(void)
{
struct romstage_handoff *handoff;
/* cbmem_add() first does a find and uses the old location before the
* real add. However, it is important to know when the structure is not
* found so it can be initialized to 0. */
handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
if (handoff)
return handoff;
handoff = cbmem_add(CBMEM_ID_ROMSTAGE_INFO, sizeof(*handoff));
if (handoff != NULL)
memset(handoff, 0, sizeof(*handoff));
else
printk(BIOS_DEBUG, "Romstage handoff structure not added!\n");
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;
}
int romstage_handoff_init(int is_s3_resume);
/* Return 1 if resuming or 0 if not. */
static inline int romstage_handoff_is_resume(void)
{
struct romstage_handoff *handoff;
handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
if (handoff == NULL)
return 0;
return handoff->s3_resume;
}
int romstage_handoff_is_resume(void);
#endif /* ROMSTAGE_HANDOFF_H */