UPSTREAM: 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. BUG=None BRANCH=None TEST=None Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/17646 Tested-by: build bot (Jenkins) Reviewed-by: Kysti Mlkki <kyosti.malkki@gmail.com> Reviewed-by: Furquan Shaikh <furquan@google.com> Change-Id: I1e9d588ab6b9ace67757387dbb5963ae31ceb252 Reviewed-on: https://chromium-review.googlesource.com/416155 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
b95c3a7f40
commit
c7b7a3fb44
9 changed files with 35 additions and 60 deletions
|
|
@ -18,6 +18,8 @@
|
|||
#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
|
||||
|
|
@ -48,13 +50,32 @@ static inline struct romstage_handoff *romstage_handoff_find_or_add(void)
|
|||
* found so it can be initialized to 0. */
|
||||
handoff = cbmem_find(CBMEM_ID_ROMSTAGE_INFO);
|
||||
|
||||
if (handoff == NULL) {
|
||||
handoff = cbmem_add(CBMEM_ID_ROMSTAGE_INFO, sizeof(*handoff));
|
||||
if (handoff != NULL)
|
||||
memset(handoff, 0, sizeof(*handoff));
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
#endif /* ROMSTAGE_HANDOFF_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue