summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/2lib/2gbb.c6
-rw-r--r--firmware/2lib/include/2api.h11
-rw-r--r--tests/vb2_gbb_tests.c9
3 files changed, 26 insertions, 0 deletions
diff --git a/firmware/2lib/2gbb.c b/firmware/2lib/2gbb.c
index 75eed57e..8a7c57c5 100644
--- a/firmware/2lib/2gbb.c
+++ b/firmware/2lib/2gbb.c
@@ -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;
+}
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index 9cab74e9..487616d4 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -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 */
diff --git a/tests/vb2_gbb_tests.c b/tests/vb2_gbb_tests.c
index 0c5eff5e..a7ff9b35 100644
--- a/tests/vb2_gbb_tests.c
+++ b/tests/vb2_gbb_tests.c
@@ -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();