From 828272767d067cc215ff6c7dc93bd731a1a61765 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Wed, 6 Aug 2014 14:34:57 -0500 Subject: chromeec: allow transport implementation to provide buffers for proto v3 Depending on the transport mechanism for proto v3 different bytes need to be send and/or read before the request and response. Depending on the software and/or controller interface that requirement leads to needing to copy data into temporary buffers. Avoid this by allowing the transport mechanism to provide the request and response buffers. BUG=chrome-os-partner:31148 BRANCH=None TEST=Built for rush and ryu. Ran on ryu with i2c implementation. Also built for rambi to check x86 systems. Change-Id: I35d4d69bd1fa900fc0cfe3822496f381405bdcb1 Signed-off-by: Patrick Georgi Original-Commit-Id: c7224426e1d0bcf06ed010131a2462a6ca201d8b Original-Change-Id: Iad6cce566a253ca72e6f5009a97235ece0a6c1b5 Original-Signed-off-by: Aaron Durbin Original-Reviewed-on: https://chromium-review.googlesource.com/211138 Original-Reviewed-by: Furquan Shaikh Reviewed-on: http://review.coreboot.org/8827 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/ec/google/chromeec/crosec_proto.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/ec/google/chromeec/crosec_proto.c') diff --git a/src/ec/google/chromeec/crosec_proto.c b/src/ec/google/chromeec/crosec_proto.c index 42c7c2e35d..55a707db17 100644 --- a/src/ec/google/chromeec/crosec_proto.c +++ b/src/ec/google/chromeec/crosec_proto.c @@ -27,6 +27,11 @@ #include "ec_message.h" /* Common utilities */ +void * __attribute__((weak)) crosec_get_buffer(size_t size, int req) +{ + printk(BIOS_DEBUG, "crosec_get_buffer() implementation required.\n"); + return NULL; +} /* Dumps EC command / response data into debug output. * @@ -208,23 +213,27 @@ static int send_command_proto3(struct chromeec_command *cec_command, { int out_bytes, in_bytes; int rv; - struct ec_command_v3 cmd = { {0}, }; - struct ec_response_v3 resp = { {0}, }; + struct ec_command_v3 *cmd; + struct ec_response_v3 *resp; + + if ((cmd = crosec_get_buffer(sizeof(*cmd), 1)) == NULL) + return -EC_RES_ERROR; + if ((resp = crosec_get_buffer(sizeof(*resp), 0)) == NULL) + return -EC_RES_ERROR; /* Create request packet */ - out_bytes = create_proto3_request(cec_command, &cmd); + out_bytes = create_proto3_request(cec_command, cmd); if (out_bytes < 0) { return out_bytes; } /* Prepare response buffer */ - in_bytes = prepare_proto3_response_buffer(cec_command, &resp); + in_bytes = prepare_proto3_response_buffer(cec_command, resp); if (in_bytes < 0) { return in_bytes; } - rv = crosec_io((uint8_t *)&cmd, out_bytes, (uint8_t *)&resp, in_bytes, - context); + rv = crosec_io(out_bytes, in_bytes, context); if (rv != 0) { printk(BIOS_ERR, "%s: failed to complete I/O: Err = %#x.", __func__, rv >= 0 ? rv : -rv); @@ -232,7 +241,7 @@ static int send_command_proto3(struct chromeec_command *cec_command, } /* Process the response */ - return handle_proto3_response(&resp, cec_command); + return handle_proto3_response(resp, cec_command); } static int crosec_command_proto_v3(struct chromeec_command *cec_command, -- cgit v1.2.3