lib/cbmem: allow anyone to use cbmem_possibly_online()

The cbmem_possibly_online() is a helpful construct. Therefore,
push it into cbmem.h so other users can take advantage of it.

BUG=chrome-os-partner:60592
BRANCH=reef

Change-Id: If5a1c7815ed03874dcf141014b8ffefb82b7cc92
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/17868
Tested-by: build bot (Jenkins)
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Aaron Durbin 2016-12-14 14:40:43 -06:00
parent dfcc60c385
commit b2a5f4833d
2 changed files with 17 additions and 16 deletions

View File

@ -158,4 +158,20 @@ void set_top_of_ram(uint64_t ramtop);
void backup_top_of_ram(uint64_t ramtop);
#endif
/*
* Returns 0 for the stages where we know that cbmem does not come online.
* Even if this function returns 1 for romstage, depending upon the point in
* bootup, cbmem might not actually be online.
*/
static inline int cbmem_possibly_online(void)
{
if (ENV_BOOTBLOCK)
return 0;
if (ENV_VERSTAGE && IS_ENABLED(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK))
return 0;
return 1;
}
#endif /* _CBMEM_H_ */

View File

@ -16,6 +16,7 @@
#include <assert.h>
#include <bootmode.h>
#include <bootstate.h>
#include <cbmem.h>
#include <rules.h>
#include <string.h>
#include <vb2_api.h>
@ -67,22 +68,6 @@ static void vb2_clear_recovery_reason_vbnv(void *unused)
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_EXIT,
vb2_clear_recovery_reason_vbnv, NULL);
/*
* Returns 0 for the stages where we know that cbmem does not come online.
* Even if this function returns 1 for romstage, depending upon the point in
* bootup, cbmem might not actually be online.
*/
static int cbmem_possibly_online(void)
{
if (ENV_BOOTBLOCK)
return 0;
if (ENV_VERSTAGE && IS_ENABLED(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK))
return 0;
return 1;
}
/*
* Returns 1 if vboot is being used and currently in a stage which might have
* already executed vboot verification.