diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-06-26 16:02:02 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-01 16:14:16 -0700 |
commit | 177dc398d39c1156182cb8e59a4092bd8a18ad93 (patch) | |
tree | dcaac91130b259baafa19e9fc26d07c815f0c4ce /common | |
parent | 2730daa5679bc0d2a048a60055a7dc89d060076e (diff) | |
download | chrome-ec-177dc398d39c1156182cb8e59a4092bd8a18ad93.tar.gz |
Allow bigger flash write commands
Version 1 of EC_CMD_FLASH_WRITE will use as big a write as possible given
the available command parameter space. Falls back to 64 byte writes on old
platforms.
BUG=chrome-os-partner:20571
BRANCH=none
TEST=Copy burn_my_ec onto a link and run it. Write size should be 64 bytes
for the first half of the update (since the old EC doesn't support ver.1
of the write command) and 240 bytes for the second half of the update.
Change-Id: I5900de3a5700d7c82a2e0c3cf9921b7ced1c0343
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60511
Diffstat (limited to 'common')
-rw-r--r-- | common/flash_common.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/common/flash_common.c b/common/flash_common.c index 1f8c199cbd..d9834bfea2 100644 --- a/common/flash_common.c +++ b/common/flash_common.c @@ -496,6 +496,12 @@ DECLARE_HOST_COMMAND(EC_CMD_FLASH_READ, flash_command_read, EC_VER_MASK(0)); +/** + * Flash write command + * + * Version 0 and 1 are equivalent from the EC-side; the only difference is + * that the host can only send 64 bytes of data at a time in version 0. + */ static int flash_command_write(struct host_cmd_handler_args *args) { const struct ec_params_flash_write *p = args->params; @@ -503,20 +509,20 @@ static int flash_command_write(struct host_cmd_handler_args *args) if (flash_get_protect() & EC_FLASH_PROTECT_ALL_NOW) return EC_RES_ACCESS_DENIED; - if (p->size > sizeof(p->data)) + if (p->size + sizeof(*p) > args->params_size) return EC_RES_INVALID_PARAM; if (system_unsafe_to_overwrite(p->offset, p->size)) return EC_RES_ACCESS_DENIED; - if (flash_write(p->offset, p->size, p->data)) + if (flash_write(p->offset, p->size, (const uint8_t *)(p + 1))) return EC_RES_ERROR; return EC_RES_SUCCESS; } DECLARE_HOST_COMMAND(EC_CMD_FLASH_WRITE, flash_command_write, - EC_VER_MASK(0)); + EC_VER_MASK(0) | EC_VER_MASK(EC_VER_FLASH_WRITE)); static int flash_command_erase(struct host_cmd_handler_args *args) { |