From b11c1e234b86498311c340bd8b9b51b8d22e2ff5 Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Thu, 23 Aug 2012 15:30:05 +0800 Subject: Rename EC_FLASH_PROTECT_RW_* flags to EC_FLASH_PROTECT_ALL_*. Current *_RW_NOW/RW_AT_BOOT is used to lock the entire flash. This could lead confusion in the future. So, rename them. Since the bit definition is unchanged, thus the callers (u-boot, flashrom) is fine if they don't change the name. BUG=chrome-os-partner:12951 BRANCH=snow,link TEST=build in chroot only:daisy,snow,link,bds Signed-off-by: Louis Yung-Chieh Lo Change-Id: I2395e93793f590e6fb8aae7006eb8e5c836002bc Reviewed-on: https://gerrit.chromium.org/gerrit/31199 Commit-Ready: Yung-Chieh Lo Reviewed-by: Yung-Chieh Lo Tested-by: Yung-Chieh Lo Reviewed-by: Randall Spangler --- chip/lm4/flash.c | 12 ++++++++---- chip/stm32/flash-stm32f100.c | 11 ++++++----- chip/stm32/flash-stm32l15x.c | 2 +- common/flash_common.c | 29 ++++++++++++++--------------- include/ec_commands.h | 8 ++++---- util/ectool.c | 12 ++++++------ 6 files changed, 39 insertions(+), 35 deletions(-) diff --git a/chip/lm4/flash.c b/chip/lm4/flash.c index c9922b4ea4..9309fc7c35 100644 --- a/chip/lm4/flash.c +++ b/chip/lm4/flash.c @@ -296,7 +296,7 @@ uint32_t flash_get_protect(void) i < RO_BANK_OFFSET + RO_BANK_COUNT) || i == PSTATE_BANK); int bank_flag = (is_ro ? EC_FLASH_PROTECT_RO_NOW : - EC_FLASH_PROTECT_RW_NOW); + EC_FLASH_PROTECT_ALL_NOW); if (flash_physical_get_protect(i)) { /* At least one bank in the region is protected */ @@ -307,6 +307,10 @@ uint32_t flash_get_protect(void) } } + if ((flags & EC_FLASH_PROTECT_ALL_NOW) && + !(flags & EC_FLASH_PROTECT_RO_NOW)) + flags |= EC_FLASH_PROTECT_ERROR_INCONSISTENT; + /* Check if blocks were stuck locked at pre-init */ if (stuck_locked) flags |= EC_FLASH_PROTECT_ERROR_STUCK; @@ -347,8 +351,8 @@ int flash_set_protect(uint32_t mask, uint32_t flags) protect_banks(RO_BANK_OFFSET, RO_BANK_COUNT); } - if ((mask & EC_FLASH_PROTECT_RW_NOW) && - (flags & EC_FLASH_PROTECT_RW_NOW)) { + if ((mask & EC_FLASH_PROTECT_ALL_NOW) && + (flags & EC_FLASH_PROTECT_ALL_NOW)) { /* Protect the entire flash */ protect_banks(0, CONFIG_FLASH_PHYSICAL_SIZE / CONFIG_FLASH_BANK_SIZE); @@ -361,7 +365,7 @@ int flash_pre_init(void) { uint32_t reset_flags = system_get_reset_flags(); uint32_t prot_flags = flash_get_protect(); - uint32_t unwanted_prot_flags = EC_FLASH_PROTECT_RW_NOW | + uint32_t unwanted_prot_flags = EC_FLASH_PROTECT_ALL_NOW | EC_FLASH_PROTECT_ERROR_INCONSISTENT; /* diff --git a/chip/stm32/flash-stm32f100.c b/chip/stm32/flash-stm32f100.c index b42400ec7a..1221bf1b50 100644 --- a/chip/stm32/flash-stm32f100.c +++ b/chip/stm32/flash-stm32f100.c @@ -496,7 +496,7 @@ static int protect_entire_flash_until_reboot(void) /** * Determine if write protect register is inconsistent with RO_AT_BOOT and - * RW_AT_BOOT state. + * ALL_AT_BOOT state. */ static int register_need_reset(void) { @@ -589,8 +589,9 @@ uint32_t flash_get_protect(void) if (pstate.flags & PERSIST_FLAG_PROTECT_RO) flags |= EC_FLASH_PROTECT_RO_AT_BOOT; - if (entire_flash_locked) - flags |= EC_FLASH_PROTECT_RW_NOW; + if (entire_flash_locked) { + flags |= EC_FLASH_PROTECT_ALL_NOW; + } /* Scan flash protection */ for (i = 0; i < PHYSICAL_BANKS; i++) { @@ -599,7 +600,7 @@ uint32_t flash_get_protect(void) i < RO_BANK_OFFSET + RO_BANK_COUNT + PSTATE_BANK_COUNT) ? 1 : 0; int bank_flag = (is_ro ? EC_FLASH_PROTECT_RO_NOW : - EC_FLASH_PROTECT_RW_NOW); + EC_FLASH_PROTECT_ALL_NOW); if (flash_physical_get_protect(i)) { flags |= bank_flag; @@ -640,7 +641,7 @@ int flash_set_protect(uint32_t mask, uint32_t flags) EC_FLASH_PROTECT_RO_AT_BOOT)) return retval; - if (mask & EC_FLASH_PROTECT_RW_NOW) { + if (mask & EC_FLASH_PROTECT_ALL_NOW) { /* * Since RO is already protected, protecting entire flash * is effectively protecting RW. diff --git a/chip/stm32/flash-stm32l15x.c b/chip/stm32/flash-stm32l15x.c index 4ba2c66940..885047a032 100644 --- a/chip/stm32/flash-stm32l15x.c +++ b/chip/stm32/flash-stm32l15x.c @@ -315,7 +315,7 @@ uint32_t flash_get_protect(void) int is_ro = (i >= RO_BANK_OFFSET && i < RO_BANK_OFFSET + RO_BANK_COUNT); int bank_flag = (is_ro ? EC_FLASH_PROTECT_RO_NOW : - EC_FLASH_PROTECT_RW_NOW); + EC_FLASH_PROTECT_ALL_NOW); if (flash_physical_get_protect(i)) { /* At least one bank in the region is protected */ diff --git a/common/flash_common.c b/common/flash_common.c index 6beb95e0f1..f13a978ebf 100644 --- a/common/flash_common.c +++ b/common/flash_common.c @@ -110,12 +110,12 @@ static int command_flash_info(int argc, char **argv) ccputs(" wp_gpio_asserted"); if (i & EC_FLASH_PROTECT_RO_AT_BOOT) ccputs(" ro_at_boot"); - if (i & EC_FLASH_PROTECT_RW_AT_BOOT) - ccputs(" rw_at_boot"); + if (i & EC_FLASH_PROTECT_ALL_AT_BOOT) + ccputs(" all_at_boot"); if (i & EC_FLASH_PROTECT_RO_NOW) ccputs(" ro_now"); - if (i & EC_FLASH_PROTECT_RW_NOW) - ccputs(" rw_now"); + if (i & EC_FLASH_PROTECT_ALL_NOW) + ccputs(" all_now"); if (i & EC_FLASH_PROTECT_ERROR_STUCK) ccputs(" STUCK"); if (i & EC_FLASH_PROTECT_ERROR_INCONSISTENT) @@ -209,12 +209,12 @@ static int command_flash_wp(int argc, char **argv) else if (!strcasecmp(argv[1], "disable")) return flash_set_protect(EC_FLASH_PROTECT_RO_AT_BOOT, 0); else if (!strcasecmp(argv[1], "now")) - return flash_set_protect(EC_FLASH_PROTECT_RW_NOW | + return flash_set_protect(EC_FLASH_PROTECT_ALL_NOW | EC_FLASH_PROTECT_RO_NOW, -1); else if (!strcasecmp(argv[1], "rw")) - return flash_set_protect(EC_FLASH_PROTECT_RW_AT_BOOT, -1); + return flash_set_protect(EC_FLASH_PROTECT_ALL_AT_BOOT, -1); else if (!strcasecmp(argv[1], "norw")) - return flash_set_protect(EC_FLASH_PROTECT_RW_AT_BOOT, 0); + return flash_set_protect(EC_FLASH_PROTECT_ALL_AT_BOOT, 0); else return EC_ERROR_PARAM1; } @@ -324,7 +324,7 @@ static int flash_command_protect(struct host_cmd_handler_args *args) EC_FLASH_PROTECT_ERROR_STUCK | EC_FLASH_PROTECT_RO_AT_BOOT | EC_FLASH_PROTECT_RO_NOW | - EC_FLASH_PROTECT_RW_NOW | + EC_FLASH_PROTECT_ALL_NOW | EC_FLASH_PROTECT_ERROR_INCONSISTENT; r->writable_flags = 0; @@ -334,17 +334,16 @@ static int flash_command_protect(struct host_cmd_handler_args *args) #ifdef CHIP_lm4 /* - * If RW protection isn't enabled this boot, it can be enabled if the * - * WP GPIO is asserted. + * If entire flash isn't protected at this boot, it can be enabled if + * the WP GPIO is asserted. */ - if (!(r->flags & EC_FLASH_PROTECT_RW_NOW) && + if (!(r->flags & EC_FLASH_PROTECT_ALL_NOW) && (r->flags & EC_FLASH_PROTECT_GPIO_ASSERTED)) - r->writable_flags |= EC_FLASH_PROTECT_RW_NOW; + r->writable_flags |= EC_FLASH_PROTECT_ALL_NOW; #elif defined(CHIP_stm32) - /* RW protection can only be changed at boot */ - r->valid_flags |= EC_FLASH_PROTECT_RW_AT_BOOT; - r->writable_flags |= EC_FLASH_PROTECT_RW_AT_BOOT; + r->valid_flags |= EC_FLASH_PROTECT_ALL_NOW; + r->writable_flags |= EC_FLASH_PROTECT_ALL_NOW; #endif args->response_size = sizeof(*r); diff --git a/include/ec_commands.h b/include/ec_commands.h index 99d5bb90c3..b5d9ef24fe 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -490,8 +490,8 @@ struct ec_params_flash_erase { * be changed. */ #define EC_FLASH_PROTECT_RO_NOW (1 << 1) -/* RW flash code protected now, until reboot. */ -#define EC_FLASH_PROTECT_RW_NOW (1 << 2) +/* Entire flash code protected now, until reboot. */ +#define EC_FLASH_PROTECT_ALL_NOW (1 << 2) /* Flash write protect GPIO is asserted now */ #define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3) /* Error - at least one bank of flash is stuck locked, and cannot be unlocked */ @@ -502,8 +502,8 @@ struct ec_params_flash_erase { * re-requesting the desired flags, or by a hard reset if that fails. */ #define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5) -/* RW flash code protected when the EC boots */ -#define EC_FLASH_PROTECT_RW_AT_BOOT (1 << 6) +/* Entile flash code protected when the EC boots */ +#define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6) struct ec_params_flash_protect { uint32_t mask; /* Bits in flags to apply */ diff --git a/util/ectool.c b/util/ectool.c index 0b6fa089e4..9b40bf68cf 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -588,12 +588,12 @@ static void print_flash_protect_flags(const char *desc, uint32_t flags) printf(" wp_gpio_asserted"); if (flags & EC_FLASH_PROTECT_RO_AT_BOOT) printf(" ro_at_boot"); - if (flags & EC_FLASH_PROTECT_RW_AT_BOOT) - printf(" rw_at_boot"); + if (flags & EC_FLASH_PROTECT_ALL_AT_BOOT) + printf(" all_at_boot"); if (flags & EC_FLASH_PROTECT_RO_NOW) printf(" ro_now"); - if (flags & EC_FLASH_PROTECT_RW_NOW) - printf(" rw_now"); + if (flags & EC_FLASH_PROTECT_ALL_NOW) + printf(" all_now"); if (flags & EC_FLASH_PROTECT_ERROR_STUCK) printf(" STUCK"); if (flags & EC_FLASH_PROTECT_ERROR_INCONSISTENT) @@ -615,8 +615,8 @@ int cmd_flash_protect(int argc, char *argv[]) p.mask = p.flags = 0; for (i = 1; i < argc; i++) { if (!strcasecmp(argv[i], "now")) { - p.mask |= EC_FLASH_PROTECT_RW_NOW; - p.flags |= EC_FLASH_PROTECT_RW_NOW; + p.mask |= EC_FLASH_PROTECT_ALL_NOW; + p.flags |= EC_FLASH_PROTECT_ALL_NOW; } else if (!strcasecmp(argv[i], "enable")) { p.mask |= EC_FLASH_PROTECT_RO_AT_BOOT; p.flags |= EC_FLASH_PROTECT_RO_AT_BOOT; -- cgit v1.2.1