From c3adc315b3ba724bccafe7c97e2c1b8ab6120cf9 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Thu, 25 Dec 2014 17:18:23 +0800 Subject: Support command versioning of new host command range We've extended host command range from 8-bit to 16-bit. Extend EC_CMD_GET_CMD_VERSIONS so that the host may query supported command versions of the new host commands. BRANCH=All BUG=chrome-os-partner:26577 TEST=Extend 'usbpd' to version 1. Test that we can check its version. TEST=Run 'ectool gpioget' with new ectool and old EC. TEST=Run 'ectool gpioget' with old ectool and new EC. Change-Id: I1651aaf21ac2604aea101244b5e53713ead8c1af Signed-off-by: Vic Yang Reviewed-on: https://chromium-review.googlesource.com/237622 Reviewed-by: Randall Spangler --- common/host_command.c | 7 +++++-- include/ec_commands.h | 4 ++++ util/misc_util.c | 11 +++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/common/host_command.c b/common/host_command.c index a036c184e6..51d1a9cf97 100644 --- a/common/host_command.c +++ b/common/host_command.c @@ -505,9 +505,12 @@ DECLARE_HOST_COMMAND(EC_CMD_READ_MEMMAP, static int host_command_get_cmd_versions(struct host_cmd_handler_args *args) { const struct ec_params_get_cmd_versions *p = args->params; + const struct ec_params_get_cmd_versions_v1 *p_v1 = args->params; struct ec_response_get_cmd_versions *r = args->response; - const struct host_command *cmd = find_host_command(p->cmd); + const struct host_command *cmd = + (args->version == 1) ? find_host_command(p_v1->cmd) : + find_host_command(p->cmd); if (!cmd) return EC_RES_INVALID_PARAM; @@ -520,7 +523,7 @@ static int host_command_get_cmd_versions(struct host_cmd_handler_args *args) } DECLARE_HOST_COMMAND(EC_CMD_GET_CMD_VERSIONS, host_command_get_cmd_versions, - EC_VER_MASK(0)); + EC_VER_MASK(0) | EC_VER_MASK(1)); /** * Print debug output for the host command request, before it's processed. diff --git a/include/ec_commands.h b/include/ec_commands.h index 0a6858e2f2..c06e3464a0 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -617,6 +617,10 @@ struct ec_params_get_cmd_versions { uint8_t cmd; /* Command to check */ } __packed; +struct ec_params_get_cmd_versions_v1 { + uint16_t cmd; /* Command to check */ +} __packed; + struct ec_response_get_cmd_versions { /* * Mask of supported versions; use EC_VER_MASK() to compare with a diff --git a/util/misc_util.c b/util/misc_util.c index 005c84e50c..9699ac4a61 100644 --- a/util/misc_util.c +++ b/util/misc_util.c @@ -93,16 +93,23 @@ int is_string_printable(const char *buf) */ int ec_get_cmd_versions(int cmd, uint32_t *pmask) { + struct ec_params_get_cmd_versions_v1 pver_v1; struct ec_params_get_cmd_versions pver; struct ec_response_get_cmd_versions rver; int rv; *pmask = 0; - pver.cmd = cmd; - rv = ec_command(EC_CMD_GET_CMD_VERSIONS, 0, &pver, sizeof(pver), + pver_v1.cmd = cmd; + rv = ec_command(EC_CMD_GET_CMD_VERSIONS, 1, &pver_v1, sizeof(pver_v1), &rver, sizeof(rver)); + if (rv == -EECRESULT - EC_RES_INVALID_VERSION) { + pver.cmd = cmd; + rv = ec_command(EC_CMD_GET_CMD_VERSIONS, 0, &pver, sizeof(pver), + &rver, sizeof(rver)); + } + if (rv < 0) return rv; -- cgit v1.2.1