| 27 | } |
| 28 | |
| 29 | struct vb2_context *vboot_get_context(void) |
| 30 | { |
| 31 | void *wb; |
| 32 | vb2_error_t rv; |
| 33 | |
| 34 | /* Return if context has already been initialized/restored. */ |
| 35 | if (vboot_ctx) |
| 36 | return vboot_ctx; |
| 37 | |
| 38 | wb = vboot_get_workbuf(); |
| 39 | |
| 40 | /* Restore context from a previous stage. */ |
| 41 | if (vboot_logic_executed()) { |
| 42 | rv = vb2api_reinit(wb, &vboot_ctx); |
| 43 | if (rv != VB2_SUCCESS) |
| 44 | die("%s: vb2api_reinit returned %#x\n", __func__, rv); |
| 45 | return vboot_ctx; |
| 46 | } |
| 47 | |
| 48 | assert(verification_should_run()); |
| 49 | |
| 50 | /* Initialize vb2_shared_data and friends. */ |
| 51 | rv = vb2api_init(wb, VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE, &vboot_ctx); |
| 52 | assert(rv == VB2_SUCCESS); |
| 53 | |
| 54 | return vboot_ctx; |
| 55 | } |
| 56 | |
| 57 | int vboot_locate_firmware(struct vb2_context *ctx, struct region_device *fw) |
| 58 | { |
no test coverage detected