coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ec_sync.c File Reference
#include <assert.h>
#include <cbfs.h>
#include <console/console.h>
#include <delay.h>
#include <ec/google/chromeec/ec.h>
#include <halt.h>
#include <security/vboot/misc.h>
#include <security/vboot/vbnv.h>
#include <security/vboot/vboot_common.h>
#include <timer.h>
#include <timestamp.h>
#include <vb2_api.h>
Include dependency graph for ec_sync.c:

Go to the source code of this file.

Macros

#define _EC_FILENAME(select, suffix)    (select == VB_SELECT_FIRMWARE_READONLY ? "ecro" suffix : "ecrw" suffix)
 
#define EC_IMAGE_FILENAME(select)   _EC_FILENAME(select, "")
 
#define EC_HASH_FILENAME(select)   _EC_FILENAME(select, ".hash")
 
#define CROS_EC_HASH_CHECK_DELAY_MS   10
 
#define CROS_EC_HASH_TIMEOUT_MS   2000
 
#define LIMIT_POWER_WAIT_TIMEOUT_MS   3000
 
#define LIMIT_POWER_POLL_SLEEP_MS   10
 
#define CROS_EC_SYSJUMP_TIMEOUT_MS   3000
 

Functions

void vboot_sync_ec (void)
 
static uint32_t get_vboot_hash_offset (enum vb2_firmware_selection select)
 
static vb2_error_t ec_hash_image (enum vb2_firmware_selection select, const uint8_t **hash, int *hash_size)
 
static vb2_error_t ec_protect_flash (enum vb2_firmware_selection select, int enable)
 
static enum ec_flash_region vboot_to_ec_region (enum vb2_firmware_selection select)
 
static vb2_error_t ec_flash_write (void *image, uint32_t region_offset, int image_size)
 
static vb2_error_t ec_update_image (enum vb2_firmware_selection select)
 
static vb2_error_t ec_get_expected_hash (enum vb2_firmware_selection select, const uint8_t **hash, int *hash_size)
 
vb2_error_t vb2ex_commit_data (struct vb2_context *ctx)
 
vb2_error_t vb2ex_ec_running_rw (int *in_rw)
 
vb2_error_t vb2ex_ec_vboot_done (struct vb2_context *ctx)
 
vb2_error_t vb2ex_ec_battery_cutoff (void)
 
vb2_error_t vb2ex_ec_hash_image (enum vb2_firmware_selection select, const uint8_t **hash, int *hash_size)
 
vb2_error_t vb2ex_ec_protect (enum vb2_firmware_selection select)
 
vb2_error_t vb2ex_ec_get_expected_image_hash (enum vb2_firmware_selection select, const uint8_t **hash, int *hash_size)
 
vb2_error_t vb2ex_ec_disable_jump (void)
 
vb2_error_t vb2ex_ec_update_image (enum vb2_firmware_selection select)
 
vb2_error_t vb2ex_ec_jump_to_rw (void)
 

Macro Definition Documentation

◆ _EC_FILENAME

#define _EC_FILENAME (   select,
  suffix 
)     (select == VB_SELECT_FIRMWARE_READONLY ? "ecro" suffix : "ecrw" suffix)

Definition at line 16 of file ec_sync.c.

◆ CROS_EC_HASH_CHECK_DELAY_MS

#define CROS_EC_HASH_CHECK_DELAY_MS   10

Definition at line 22 of file ec_sync.c.

◆ CROS_EC_HASH_TIMEOUT_MS

#define CROS_EC_HASH_TIMEOUT_MS   2000

Definition at line 24 of file ec_sync.c.

◆ CROS_EC_SYSJUMP_TIMEOUT_MS

#define CROS_EC_SYSJUMP_TIMEOUT_MS   3000

Definition at line 32 of file ec_sync.c.

◆ EC_HASH_FILENAME

#define EC_HASH_FILENAME (   select)    _EC_FILENAME(select, ".hash")

Definition at line 19 of file ec_sync.c.

◆ EC_IMAGE_FILENAME

#define EC_IMAGE_FILENAME (   select)    _EC_FILENAME(select, "")

Definition at line 18 of file ec_sync.c.

◆ LIMIT_POWER_POLL_SLEEP_MS

#define LIMIT_POWER_POLL_SLEEP_MS   10

Definition at line 29 of file ec_sync.c.

◆ LIMIT_POWER_WAIT_TIMEOUT_MS

#define LIMIT_POWER_WAIT_TIMEOUT_MS   3000

Definition at line 27 of file ec_sync.c.

Function Documentation

◆ ec_flash_write()

static vb2_error_t ec_flash_write ( void image,
uint32_t  region_offset,
int  image_size 
)
static

◆ ec_get_expected_hash()

static vb2_error_t ec_get_expected_hash ( enum vb2_firmware_selection  select,
const uint8_t **  hash,
int *  hash_size 
)
static

Definition at line 376 of file ec_sync.c.

References cbfs_map(), EC_HASH_FILENAME, NULL, and ec_params_flash_write::size.

Referenced by vb2ex_ec_get_expected_image_hash().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ec_hash_image()

◆ ec_protect_flash()

static vb2_error_t ec_protect_flash ( enum vb2_firmware_selection  select,
int  enable 
)
static

Definition at line 189 of file ec_sync.c.

References EC_FLASH_PROTECT_ALL_AT_BOOT, EC_FLASH_PROTECT_ALL_NOW, EC_FLASH_PROTECT_GPIO_ASSERTED, EC_FLASH_PROTECT_RO_AT_BOOT, EC_FLASH_PROTECT_RO_NOW, ec_response_flash_protect::flags, google_chromeec_flash_protect(), and mask.

Referenced by ec_update_image(), and vb2ex_ec_protect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ec_update_image()

static vb2_error_t ec_update_image ( enum vb2_firmware_selection  select)
static

Definition at line 325 of file ec_sync.c.

References cbfs_map(), cbfs_unmap(), ec_flash_write(), EC_IMAGE_FILENAME, ec_protect_flash(), google_chromeec_efs_verify(), google_chromeec_flash_erase(), google_chromeec_flash_region_info(), region_offset(), and vboot_to_ec_region().

Referenced by vb2ex_ec_update_image().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_vboot_hash_offset()

static uint32_t get_vboot_hash_offset ( enum vb2_firmware_selection  select)
static

Definition at line 91 of file ec_sync.c.

References EC_VBOOT_HASH_OFFSET_ACTIVE, EC_VBOOT_HASH_OFFSET_RO, and EC_VBOOT_HASH_OFFSET_UPDATE.

Referenced by ec_hash_image().

Here is the caller graph for this function:

◆ vb2ex_commit_data()

vb2_error_t vb2ex_commit_data ( struct vb2_context *  ctx)

Definition at line 402 of file ec_sync.c.

References save_vbnv().

Here is the call graph for this function:

◆ vb2ex_ec_battery_cutoff()

vb2_error_t vb2ex_ec_battery_cutoff ( void  )

Definition at line 473 of file ec_sync.c.

References EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN, and google_chromeec_battery_cutoff().

Here is the call graph for this function:

◆ vb2ex_ec_disable_jump()

vb2_error_t vb2ex_ec_disable_jump ( void  )

Definition at line 511 of file ec_sync.c.

References EC_REBOOT_DISABLE_JUMP, and google_chromeec_reboot().

Here is the call graph for this function:

◆ vb2ex_ec_get_expected_image_hash()

vb2_error_t vb2ex_ec_get_expected_image_hash ( enum vb2_firmware_selection  select,
const uint8_t **  hash,
int *  hash_size 
)

Definition at line 501 of file ec_sync.c.

References ec_get_expected_hash().

Here is the call graph for this function:

◆ vb2ex_ec_hash_image()

vb2_error_t vb2ex_ec_hash_image ( enum vb2_firmware_selection  select,
const uint8_t **  hash,
int *  hash_size 
)

Definition at line 484 of file ec_sync.c.

References ec_hash_image().

Here is the call graph for this function:

◆ vb2ex_ec_jump_to_rw()

vb2_error_t vb2ex_ec_jump_to_rw ( void  )

◆ vb2ex_ec_protect()

vb2_error_t vb2ex_ec_protect ( enum vb2_firmware_selection  select)

Definition at line 493 of file ec_sync.c.

References ec_protect_flash().

Here is the call graph for this function:

◆ vb2ex_ec_running_rw()

vb2_error_t vb2ex_ec_running_rw ( int *  in_rw)

Definition at line 411 of file ec_sync.c.

References google_ec_running_ro().

Here is the call graph for this function:

◆ vb2ex_ec_update_image()

vb2_error_t vb2ex_ec_update_image ( enum vb2_firmware_selection  select)

Definition at line 522 of file ec_sync.c.

References ec_update_image().

Here is the call graph for this function:

◆ vb2ex_ec_vboot_done()

vb2_error_t vb2ex_ec_vboot_done ( struct vb2_context *  ctx)

◆ vboot_sync_ec()

void vboot_sync_ec ( void  )

Definition at line 40 of file ec_sync.c.

References BIOS_EMERG, BIOS_ERR, BIOS_INFO, EC_REBOOT_COLD, EC_REBOOT_FLAG_SWITCH_RW_SLOT, google_chromeec_reboot(), halt(), printk, timestamp_add_now(), TS_EC_SYNC_END, TS_EC_SYNC_START, vboot_get_context(), vboot_reboot(), and vboot_save_data().

Referenced by romstage_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vboot_to_ec_region()

static enum ec_flash_region vboot_to_ec_region ( enum vb2_firmware_selection  select)
static

Definition at line 189 of file ec_sync.c.

Referenced by ec_update_image().

Here is the caller graph for this function: