summaryrefslogtreecommitdiff
path: root/common/vboot_hash.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-11 11:18:17 -0700
committerGerrit <chrome-bot@google.com>2012-07-11 14:46:30 -0700
commit07ca0977fe554696288048c5c691aa5b9cfa7ac8 (patch)
treeaade5d33536338c2baa869c1865e4eb11b390e3e /common/vboot_hash.c
parent61e0e5508a559cc9935951be4f68455809300a2e (diff)
downloadchrome-ec-07ca0977fe554696288048c5c691aa5b9cfa7ac8.tar.gz
Refactor API for host commands, and handle variable length data better
Added version mask field to DECLARE_HOST_COMMAND() because it's convenient to do so when I'm touching all host command implementations, but all commands simply declare version 0 and nothing checks it yet. Will add version support in a followup CL. This change is internal to the EC; it does not change the data sent over the host interface. BUG=chrome-os-partner:11275 TEST=manual ectool version && ectool echash; should get sane data from both ectool flashread 0x80 0x40 /tmp/foo && od -tx1 /tmp/foo should match data from offset 0x80 of ec.bin (od -j128 -n64 -tx1 ec.bin) Change-Id: I5699f72b8d5e1ac23929353c9a34158d76c44206 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27172 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/vboot_hash.c')
-rw-r--r--common/vboot_hash.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/common/vboot_hash.c b/common/vboot_hash.c
index fc801a2e98..47b860111c 100644
--- a/common/vboot_hash.c
+++ b/common/vboot_hash.c
@@ -5,7 +5,7 @@
/* Verified boot hash computing module for Chrome EC */
-#include "config.h"
+#include "common.h"
#include "console.h"
#include "cryptolib.h"
#include "hooks.h"
@@ -243,18 +243,18 @@ static void fill_response(struct ec_response_vboot_hash *r)
r->status = EC_VBOOT_HASH_STATUS_NONE;
}
-
-static int host_command_vboot_hash(uint8_t *data, int *resp_size)
+static int host_command_vboot_hash(struct host_cmd_handler_args *args)
{
- struct ec_params_vboot_hash *p = (struct ec_params_vboot_hash *)data;
+ const struct ec_params_vboot_hash *p =
+ (const struct ec_params_vboot_hash *)args->params;
struct ec_response_vboot_hash *r =
- (struct ec_response_vboot_hash *)data;
+ (struct ec_response_vboot_hash *)args->response;
int rv;
switch (p->cmd) {
case EC_VBOOT_HASH_GET:
fill_response(r);
- *resp_size = sizeof(struct ec_response_vboot_hash);
+ args->response_size = sizeof(*r);
return EC_RES_SUCCESS;
case EC_VBOOT_HASH_ABORT:
@@ -295,11 +295,13 @@ static int host_command_vboot_hash(uint8_t *data, int *resp_size)
usleep(1000);
fill_response(r);
- *resp_size = sizeof(struct ec_response_vboot_hash);
+ args->response_size = sizeof(*r);
return EC_RES_SUCCESS;
default:
return EC_RES_INVALID_PARAM;
}
}
-DECLARE_HOST_COMMAND(EC_CMD_VBOOT_HASH, host_command_vboot_hash);
+DECLARE_HOST_COMMAND(EC_CMD_VBOOT_HASH,
+ host_command_vboot_hash,
+ EC_VER_MASK(0));