vboot: add vb2api_gbb_get_flags function

BUG=b:124141368, chromium:954774
TEST=make clean && make runtests
BRANCH=none

Change-Id: I7b422e8a26621720a6b7efc5211629996a6aa385
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1659989
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Julius Werner <jwerner@chromium.org>
Auto-Submit: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Joel Kitching 2019-06-14 14:00:10 +08:00 committed by Commit Bot
parent 5306ca28f4
commit 01b1a94bcc
3 changed files with 26 additions and 0 deletions

View File

@ -122,3 +122,9 @@ int vb2api_gbb_read_hwid(struct vb2_context *ctx,
return VB2_SUCCESS;
}
vb2_gbb_flags_t vb2api_gbb_get_flags(struct vb2_context *ctx)
{
struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
return gbb->flags;
}

View File

@ -664,6 +664,17 @@ int vb2api_gbb_read_hwid(struct vb2_context *ctx,
char *hwid,
uint32_t *size);
/**
* Retrieve current GBB flags.
*
* See enum vb2_gbb_flag in 2gbb_flags.h for a list of all GBB flags.
*
* @param ctx Vboot context.
*
* @return vb2_gbb_flags_t representing current GBB flags.
*/
vb2_gbb_flags_t vb2api_gbb_get_flags(struct vb2_context *ctx);
/*****************************************************************************/
/* APIs provided by the caller to verified boot */

View File

@ -88,6 +88,14 @@ int vb2ex_read_resource(struct vb2_context *c,
}
/* Tests */
static void flag_tests(void)
{
reset_common_data();
gbb->flags = 0xdeadbeef;
TEST_EQ(vb2api_gbb_get_flags(&ctx), gbb->flags,
"retrieve GBB flags");
}
static void key_tests(void)
{
/* Assume that root key and recovery key are dealt with using the same
@ -343,6 +351,7 @@ static void hwid_tests(void)
int main(int argc, char* argv[])
{
flag_tests();
key_tests();
hwid_tests();