summaryrefslogtreecommitdiff
path: root/utility/load_kernel_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'utility/load_kernel_test.c')
-rw-r--r--utility/load_kernel_test.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/utility/load_kernel_test.c b/utility/load_kernel_test.c
index 71bead8e..4ca061ef 100644
--- a/utility/load_kernel_test.c
+++ b/utility/load_kernel_test.c
@@ -14,6 +14,9 @@
#include <sys/types.h>
#include <unistd.h>
+#include "2sysincludes.h"
+#include "2api.h"
+#include "2misc.h"
#include "gbb_header.h"
#include "host_common.h"
#include "load_kernel_fw.h"
@@ -221,8 +224,33 @@ int main(int argc, char* argv[]) {
}
lkp.kernel_buffer_size = KERNEL_BUFFER_SIZE;
+ /*
+ * Set up vboot context.
+ *
+ * TODO: Propagate this up to higher API levels
+ */
+ struct vb2_context ctx;
+ memset(&ctx, 0, sizeof(ctx));
+ /* No need to initialize ctx->nvdata[]; defaults are fine */
+ /* TODO(chromium:441893): support dev-mode flag and external gpt flag */
+ ctx.workbuf = malloc(VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE);
+ if (!ctx.workbuf) {
+ fprintf(stderr, "Can't allocate workbuf\n");
+ return 1;
+ }
+ ctx.workbuf_size = VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE;
+ if (lkp.boot_flags & BOOT_FLAG_RECOVERY)
+ ctx.flags |= VB2_CONTEXT_RECOVERY_MODE;
+ if (lkp.boot_flags & BOOT_FLAG_DEVELOPER)
+ ctx.flags |= VB2_CONTEXT_DEVELOPER_MODE;
+ if (VB2_SUCCESS != vb2_init_context(&ctx)) {
+ free(ctx.workbuf);
+ fprintf(stderr, "Can't init context\n");
+ return 1;
+ }
+
/* Call LoadKernel() */
- rv = LoadKernel(&lkp, &cparams);
+ rv = LoadKernel(&ctx, &lkp, &cparams);
printf("LoadKernel() returned %d\n", rv);
if (VBERROR_SUCCESS == rv) {