| 1 |
|
| 2 |
|
| 3 |
#include <libpayload-config.h> |
| 4 |
#include <arch/virtual.h> |
| 5 |
#include <assert.h> |
| 6 |
#include <libpayload.h> |
| 7 |
#include <stdio.h> |
| 8 |
#include <stdlib.h> |
| 9 |
#include <sysinfo.h> |
| 10 |
#include <vb2_api.h> |
| 11 |
#include <lp_vboot.h> |
| 12 |
|
| 13 |
struct vb2_context *vboot_get_context(void) |
| 14 |
{ |
| 15 |
static struct vb2_context *ctx; |
| 16 |
|
| 17 |
if (ctx) |
| 18 |
return ctx; |
| 19 |
|
| 20 |
die_if(lib_sysinfo.vboot_workbuf == 0, "vboot workbuf pointer is not set\n"); |
| 21 |
|
| 22 |
|
| 23 |
vb2_error_t rv = vb2api_reinit(phys_to_virt(lib_sysinfo.vboot_workbuf), &ctx); |
| 24 |
|
| 25 |
die_if(rv, "vboot workbuf could not be initialized, error: %#x\n", rv); |
| 26 |
|
| 27 |
return ctx; |
| 28 |
} |
| 29 |
|
| 30 |
void vboot_fail_and_reboot(struct vb2_context *ctx, uint8_t reason, uint8_t subcode) |
| 31 |
{ |
| 32 |
if (reason) |
| 33 |
vb2api_fail(ctx, reason, subcode); |
| 34 |
|
| 35 |
printf("vboot: reboot requested (reason: %#x, subcode %#x)", reason, subcode); |
| 36 |
vb2ex_commit_data(ctx); |
| 37 |
reboot(); |
| 38 |
} |
| 39 |
|
| 40 |
int vboot_recovery_mode_enabled(void) |
| 41 |
{ |
| 42 |
return !!(vboot_get_context()->flags & VB2_CONTEXT_RECOVERY_MODE); |
| 43 |
} |