diff options
author | Joel Kitching <kitching@google.com> | 2019-07-25 18:26:18 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-13 06:14:05 +0000 |
commit | ecdca931ae0637d1a9498f64862939bd5bb99e0b (patch) | |
tree | fac935a23124d281c72b765333cedaca446bb1e4 /utility | |
parent | 87276ffed46b3c64ff62153ac8599a79b9bcb683 (diff) | |
download | vboot-ecdca931ae0637d1a9498f64862939bd5bb99e0b.tar.gz |
vboot: move vb2_context inside vb2_shared_data (persistent context)
Move vb2_context to live inside of vb2_shared_data, instead of
in a separate memory space allocated by the caller.
See design doc:
http://go/vboot2-persistent-context
BUG=b:124141368, chromium:994060
TEST=make clean && make runtests
BRANCH=none
Change-Id: If2421756572a43ba58b9da9f00e56a8f26ad3ad5
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:1874753, chromium:1902339
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1716351
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Julius Werner <jwerner@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'utility')
-rw-r--r-- | utility/load_kernel_test.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/utility/load_kernel_test.c b/utility/load_kernel_test.c index 3e4fb90c..540d4382 100644 --- a/utility/load_kernel_test.c +++ b/utility/load_kernel_test.c @@ -22,6 +22,10 @@ #define LBA_BYTES 512 #define KERNEL_BUFFER_SIZE 0xA00000 +static uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE]; +static struct vb2_context *ctx; +static struct vb2_shared_data *sd; + /* Global variables for stub functions */ static LoadKernelParams lkp; static FILE *image_file = NULL; @@ -225,31 +229,22 @@ int main(int argc, char* argv[]) lkp.kernel_buffer_size = KERNEL_BUFFER_SIZE; /* Set up vboot context. */ - 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"); + if (vb2api_init(&workbuf, sizeof(workbuf), &ctx)) { + fprintf(stderr, "Can't initialize workbuf\n"); return 1; } - ctx.workbuf_size = VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE; + sd = vb2_get_sd(ctx); + sd->vbsd = shared; + + /* No need to initialize ctx->nvdata[]; defaults are fine */ + /* TODO(chromium:441893): support dev-mode flag and external gpt flag */ if (boot_flags & BOOT_FLAG_RECOVERY) - ctx.flags |= VB2_CONTEXT_RECOVERY_MODE; + ctx->flags |= VB2_CONTEXT_RECOVERY_MODE; if (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; - } - - struct vb2_shared_data *sd = vb2_get_sd(&ctx); - sd->vbsd = shared; + ctx->flags |= VB2_CONTEXT_DEVELOPER_MODE; /* Call LoadKernel() */ - rv = LoadKernel(&ctx, &lkp); + rv = LoadKernel(ctx, &lkp); printf("LoadKernel() returned %d\n", rv); if (VB2_SUCCESS == rv) { |