summaryrefslogtreecommitdiff
path: root/util/comm-lpc.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-06-27 14:42:39 -0700
committerChromeBot <chrome-bot@google.com>2013-07-01 16:14:15 -0700
commit2730daa5679bc0d2a048a60055a7dc89d060076e (patch)
tree8b8326fb10cf694ab551d955bd8c1bcb8ecff1cc /util/comm-lpc.c
parent267dbb74d28e4d5d13e892488563ab439398513d (diff)
downloadchrome-ec-2730daa5679bc0d2a048a60055a7dc89d060076e.tar.gz
Comm interface now provides max I/O sizes and preallocated buffers
The maximum packet / param size differs depending on interface and protocol version. Commands can now ask the comm interface what the limits are, and can use preallocated buffers to avoid needless malloc/free. BUG=chrome-os-partner:20571 BRANCH=none TEST=the following all work on link burn_my_ec ectool version ectool chargedump ectool console ectool i2cxfer 5 0x41 2 Change-Id: Ib847994da3f79721e7fb4e347231b9147a3f485f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60275
Diffstat (limited to 'util/comm-lpc.c')
-rw-r--r--util/comm-lpc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/util/comm-lpc.c b/util/comm-lpc.c
index 3290bc7c7c..f2c635770e 100644
--- a/util/comm-lpc.c
+++ b/util/comm-lpc.c
@@ -297,14 +297,21 @@ int comm_init_lpc(void)
if (i & EC_HOST_CMD_FLAG_VERSION_3) {
ec_command = ec_command_lpc_3;
+ ec_max_outsize = EC_LPC_HOST_PACKET_SIZE -
+ sizeof(struct ec_host_request);
+ ec_max_insize = EC_LPC_HOST_PACKET_SIZE -
+ sizeof(struct ec_host_response);
+
} else if (i & EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED) {
ec_command = ec_command_lpc;
+ ec_max_outsize = ec_max_insize = EC_HOST_PARAM_SIZE;
+
} else {
fprintf(stderr, "EC doesn't support protocols we need.\n");
return -5;
}
- /* Either one supports reading mapped memory directly */
+ /* Either one supports reading mapped memory directly. */
ec_readmem = ec_readmem_lpc;
return 0;
}