summaryrefslogtreecommitdiff
path: root/common/flash.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-08-15 16:34:52 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-09-21 01:07:55 -0700
commit729a4ba2bdc20675e24ed9e7d0a98d19934d72f8 (patch)
treee6096452677021e40378d7e50aaa722a9257c048 /common/flash.c
parent60b77099e0b7a0bd40e7504c2752091c378a2f1d (diff)
downloadchrome-ec-729a4ba2bdc20675e24ed9e7d0a98d19934d72f8.tar.gz
EFS: Switch active slot when current slot is invalid
When EFS finds the active slot is invalid, it tries the other slot. This patch makes the other slot active so that the following boots will try the other slot first. This patch also replaces enum flash_rw_slot with system_image_copy_t. The new APIs are therefore renamed from *_slot to *_copy. Basically, this makes vboot see slots as a conceptual place instead of physical spaces bound to flash storage. BUG=b:65028930 BRANCH=none TEST=On Fizz, verify: 1. RW_B is old and updated by soft sync. RW_B is activated and executed after reboot. System continues to boot to OS. 2. RW_A is old and updated by soft sync. RW_A is activated and executed after reboot. System continues to boot to OS. Change-Id: Icf97da13e651e7a931b9d507052b9422566eb16c Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/648449
Diffstat (limited to 'common/flash.c')
-rw-r--r--common/flash.c26
1 files changed, 2 insertions, 24 deletions
diff --git a/common/flash.c b/common/flash.c
index 3d6f579834..4dcb83ca40 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -1286,28 +1286,6 @@ static int flash_command_protect(struct host_cmd_handler_args *args)
return EC_RES_SUCCESS;
}
-enum flash_rw_slot flash_get_active_slot(void)
-{
- uint8_t slot;
- if (system_get_bbram(SYSTEM_BBRAM_IDX_TRY_SLOT, &slot))
- slot = FLASH_RW_SLOT_A;
- return slot;
-}
-
-enum flash_rw_slot flash_get_update_slot(void)
-{
-#ifdef CONFIG_VBOOT_EFS
- return 1 - flash_get_active_slot();
-#else
- return FLASH_RW_SLOT_A;
-#endif
-}
-
-enum system_image_copy_t flash_slot_to_image(enum flash_rw_slot slot)
-{
- return slot == FLASH_RW_SLOT_A ? SYSTEM_IMAGE_RW_A : SYSTEM_IMAGE_RW_B;
-}
-
/*
* TODO(crbug.com/239197) : Adding both versions to the version mask is a
* temporary workaround for a problem in the cros_ec driver. Drop
@@ -1330,7 +1308,7 @@ static int flash_command_region_info(struct host_cmd_handler_args *args)
r->size = CONFIG_RO_SIZE;
break;
case EC_FLASH_REGION_ACTIVE:
- r->offset = flash_get_rw_offset(flash_get_active_slot()) -
+ r->offset = flash_get_rw_offset(system_get_active_copy()) -
EC_FLASH_REGION_START;
r->size = CONFIG_RW_SIZE;
break;
@@ -1340,7 +1318,7 @@ static int flash_command_region_info(struct host_cmd_handler_args *args)
r->size = CONFIG_WP_STORAGE_SIZE;
break;
case EC_FLASH_REGION_UPDATE:
- r->offset = flash_get_rw_offset(flash_get_update_slot()) -
+ r->offset = flash_get_rw_offset(system_get_update_copy()) -
EC_FLASH_REGION_START;
r->size = CONFIG_RW_SIZE;
break;