* The external API for EC software sync. This function calls into * vboot, which kicks off the process. Vboot runs the verified boot * logic, and requires the client program to provide callbacks which * perform the work. */
| 38 | * perform the work. |
| 39 | */ |
| 40 | void vboot_sync_ec(void) |
| 41 | { |
| 42 | vb2_error_t retval = VB2_SUCCESS; |
| 43 | struct vb2_context *ctx; |
| 44 | |
| 45 | timestamp_add_now(TS_EC_SYNC_START); |
| 46 | |
| 47 | ctx = vboot_get_context(); |
| 48 | ctx->flags |= VB2_CONTEXT_EC_SYNC_SUPPORTED; |
| 49 | |
| 50 | retval = vb2api_ec_sync(ctx); |
| 51 | vboot_save_data(ctx); |
| 52 | |
| 53 | switch (retval) { |
| 54 | case VB2_SUCCESS: |
| 55 | break; |
| 56 | |
| 57 | case VB2_REQUEST_REBOOT_EC_TO_RO: |
| 58 | printk(BIOS_INFO, "EC Reboot requested. Doing cold reboot\n"); |
| 59 | if (google_chromeec_reboot(EC_REBOOT_COLD, EC_REBOOT_FLAG_IMMEDIATE)) |
| 60 | printk(BIOS_EMERG, "Failed to get EC to cold reboot\n"); |
| 61 | |
| 62 | halt(); |
| 63 | break; |
| 64 | |
| 65 | /* Only for EC-EFS */ |
| 66 | case VB2_REQUEST_REBOOT_EC_SWITCH_RW: |
| 67 | printk(BIOS_INFO, "Switch EC slot requested. Doing cold reboot\n"); |
| 68 | if (google_chromeec_reboot(EC_REBOOT_COLD, |
| 69 | EC_REBOOT_FLAG_SWITCH_RW_SLOT)) |
| 70 | printk(BIOS_EMERG, "Failed to get EC to cold reboot\n"); |
| 71 | |
| 72 | halt(); |
| 73 | break; |
| 74 | |
| 75 | case VB2_REQUEST_REBOOT: |
| 76 | printk(BIOS_INFO, "Reboot requested. Doing warm reboot\n"); |
| 77 | vboot_reboot(); |
| 78 | break; |
| 79 | |
| 80 | default: |
| 81 | printk(BIOS_ERR, "EC software sync failed (%#x)," |
| 82 | " rebooting\n", retval); |
| 83 | vboot_reboot(); |
| 84 | break; |
| 85 | } |
| 86 | |
| 87 | timestamp_add_now(TS_EC_SYNC_END); |
| 88 | } |
| 89 | |
| 90 | /* Convert firmware image type into a flash offset */ |
| 91 | static uint32_t get_vboot_hash_offset(enum vb2_firmware_selection select) |
no test coverage detected