mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 10:45:02 +00:00
vboot: Pass vb2 context and use vboot2 NV routines
Passing the vb2 context around allows using more of the vb2 functions in future changes, and prepares for a future where we directly use the context as it was set up in firmware verification. BUG=chromium:611535 BRANCH=none TEST=make runtests; emerge-kevin coreboot depthcharge Change-Id: I8efa606dbdec5d195b66eb899e76fdc84337ad36 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/404997 Reviewed-by: Shelley Chen <shchen@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
b57d9505c0
commit
e4136dcaa0
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user