MCPcopy Create free account
hub / github.com/coreboot/coreboot / ec_update_image

Function ec_update_image

src/security/vboot/ec_sync.c:322–371  ·  view source on GitHub ↗

* The logic for updating an EC firmware image. */

Source from the content-addressed store, hash-verified

320 * The logic for updating an EC firmware image.
321 */
322static vb2_error_t ec_update_image(enum vb2_firmware_selection select)
323{
324 uint32_t region_offset, region_size;
325 enum ec_flash_region region;
326 vb2_error_t rv;
327 void *image;
328 size_t image_size;
329
330 /* Un-protect the flash region */
331 rv = ec_protect_flash(0);
332 if (rv != VB2_SUCCESS)
333 return rv;
334
335 /* Convert vboot region into an EC region */
336 region = vboot_to_ec_region(select);
337
338 /* Get information about the flash region */
339 if (google_chromeec_flash_region_info(region, &region_offset,
340 &region_size))
341 return VB2_ERROR_UNKNOWN;
342
343 /* Map the CBFS file */
344 image = cbfs_map(EC_IMAGE_FILENAME(select), &image_size);
345 if (!image)
346 return VB2_ERROR_UNKNOWN;
347
348 rv = VB2_ERROR_UNKNOWN;
349
350 /* Bail if the image is too large */
351 if (image_size > region_size)
352 goto unmap;
353
354 /* Erase the region */
355 if (google_chromeec_flash_erase(region_offset, region_size))
356 goto unmap;
357
358 /* Write the image into the region */
359 if (ec_flash_write(image, region_offset, image_size))
360 goto unmap;
361
362 /* Verify the image */
363 if (google_chromeec_efs_verify(region))
364 goto unmap;
365
366 rv = VB2_SUCCESS;
367
368unmap:
369 cbfs_unmap(image);
370 return rv;
371}
372
373static vb2_error_t ec_get_expected_hash(enum vb2_firmware_selection select,
374 const uint8_t **hash,

Callers 1

vb2ex_ec_update_imageFunction · 0.85

Calls 8

ec_protect_flashFunction · 0.85
vboot_to_ec_regionFunction · 0.85
ec_flash_writeFunction · 0.85
cbfs_mapFunction · 0.50
cbfs_unmapFunction · 0.50

Tested by

no test coverage detected