summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2012-07-23 18:25:15 +0800
committerGerrit <chrome-bot@google.com>2012-07-24 17:38:10 -0700
commit3ab8ed4124ec3feffb6a04ce86e2329467e8efc6 (patch)
treee5a0732d4634c11cf93c0ede70a6892a5892fab1
parent78848688465a4f85f7bbcb1b45449e0318583014 (diff)
downloadchrome-ec-3ab8ed4124ec3feffb6a04ce86e2329467e8efc6.tar.gz
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 <yjlou@chromium.org> Change-Id: I35ad1e0a49c95a2d6cffbe49b2013a1b8050aabc Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28166
-rw-r--r--common/flash_common.c31
-rw-r--r--include/ec_commands.h26
2 files changed, 57 insertions, 0 deletions
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 */