From 3ab8ed4124ec3feffb6a04ce86e2329467e8efc6 Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Mon, 23 Jul 2012 18:25:15 +0800 Subject: [PATCH] Add RW offset query interface (EC_CMD_FLASH_RW_OFFSET). BUG=chrome-os-partner:11149 TEST=build only. Originally-Signed-off-by: Louis Yung-Chieh Lo Change-Id: I35ad1e0a49c95a2d6cffbe49b2013a1b8050aabc Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/28166 --- common/flash_common.c | 31 +++++++++++++++++++++++++++++++ include/ec_commands.h | 26 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/common/flash_common.c b/common/flash_common.c index f09868431b..fac124701a 100644 --- a/common/flash_common.c +++ b/common/flash_common.c @@ -332,3 +332,34 @@ static int flash_command_protect(struct host_cmd_handler_args *args) DECLARE_HOST_COMMAND(EC_CMD_FLASH_PROTECT, flash_command_protect, EC_VER_MASK(1)); + +static int flash_command_region_info(struct host_cmd_handler_args *args) +{ + struct ec_params_flash_region_info *p = + (struct ec_params_flash_region_info *)args->params; + struct ec_response_flash_region_info *r = + (struct ec_response_flash_region_info *)args->response; + + switch (p->region) { + case EC_FLASH_REGION_RO: + r->offset = CONFIG_SECTION_RO_OFF; + r->size = CONFIG_SECTION_RO_SIZE; + break; + case EC_FLASH_REGION_RW: + r->offset = CONFIG_SECTION_RW_OFF; + r->size = CONFIG_SECTION_RW_SIZE; + break; + case EC_FLASH_REGION_WP_RO: + r->offset = CONFIG_SECTION_RO_OFF; + r->size = CONFIG_SECTION_RO_SIZE; + break; + default: + return EC_RES_INVALID_PARAM; + } + + args->response_size = sizeof(*r); + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_FLASH_REGION_INFO, + flash_command_region_info, + EC_VER_MASK(EC_VER_FLASH_REGION_INFO)); diff --git a/include/ec_commands.h b/include/ec_commands.h index d6337a20ae..f6680ca8b0 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -501,6 +501,32 @@ struct ec_response_flash_protect { * write protect. These commands may be reused with version > 0. */ +/* Get the region offset/size */ +#define EC_CMD_FLASH_REGION_INFO 0x16 +#define EC_VER_FLASH_REGION_INFO 1 + +enum ec_flash_region { + /* Region which holds read-only EC image */ + EC_FLASH_REGION_RO, + /* Region which holds rewritable EC image */ + EC_FLASH_REGION_RW, + /* + * Region which should be write-protected in the factory (a superset of + * EC_FLASH_REGION_RO) + */ + EC_FLASH_REGION_WP_RO, +}; + +struct ec_params_flash_region_info { + uint32_t region; /* enum ec_flash_region */ +} __packed; + +struct ec_response_flash_region_info { + uint32_t offset; + uint32_t size; +} __packed; + + /*****************************************************************************/ /* PWM commands */