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/ec.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/ec/google/chromeec/ec.h') diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index a1c59b8dc5..e0db8c17ee 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -69,10 +69,23 @@ struct chromeec_command { * actual received size out */ }; -/* internal standard implementation for EC command protocols. */ -typedef int (*crosec_io_t)(uint8_t *write_bytes, size_t write_size, - uint8_t *read_bytes, size_t read_size, - void *context); +/* + * There are transport level constraints for sending protov3 packets. Because + * of this provide a way for the generic protocol layer to request buffers + * so that there is zero copying being done through the layers. + * + * Request the buffer provided the size. If 'req' is non-zero then the + * buffer requested is for EC requests. Otherwise it's for responses. Return + * non-NULL on success, NULL on error. + */ +void *crosec_get_buffer(size_t size, int req); + +/* + * The lower level transport works on the buffers handed out to the + * upper level. Therefore, only the size of the request and response + * are required. + */ +typedef int (*crosec_io_t)(size_t req_size, size_t resp_size, void *context); int crosec_command_proto(struct chromeec_command *cec_command, crosec_io_t crosec_io, void *context); -- cgit v1.2.3