summaryrefslogtreecommitdiff
path: root/util/cros_ec_dev.h
diff options
context:
space:
mode:
authorGuenter Roeck <groeck@chromium.org>2016-04-07 14:40:40 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-12 19:00:36 -0700
commit7ce63a09f9137bb6e5edd19e506ed98e9967884c (patch)
tree81a12f598f2ecb5983401c9be30e5dbf5cc44e3c /util/cros_ec_dev.h
parent66af587cbcbc5e3075cd003db6032dd54ac6e8a2 (diff)
downloadchrome-ec-7ce63a09f9137bb6e5edd19e506ed98e9967884c.tar.gz
ectool: Upgrade to improved ioctl format
Support both old and new ioctl formats at the same time. Auto-detect the ioctl format used by the kernel. BUG=chromium:481710 BRANCH=None TEST=Work on Samus with kernel 4.4 and 3.8/3.14/3.18 Change-Id: I31d7ce5b517b4b5af8e2b617e386c3cfd3276f20 Signed-off-by: Guenter Roeck <groeck@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/331830 Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'util/cros_ec_dev.h')
-rw-r--r--util/cros_ec_dev.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/util/cros_ec_dev.h b/util/cros_ec_dev.h
index 89a54b9e80..65c112c3b2 100644
--- a/util/cros_ec_dev.h
+++ b/util/cros_ec_dev.h
@@ -8,11 +8,11 @@
#include <linux/ioctl.h>
#include <linux/types.h>
+#include "include/ec_commands.h"
#define CROS_EC_DEV_NAME "cros_ec"
#define CROS_EC_DEV_VERSION "1.0.0"
-
/*
* @version: Command version number (often 0)
* @command: Command to send (EC_CMD_...)
@@ -50,4 +50,40 @@ struct cros_ec_readmem {
#define CROS_EC_DEV_IOCXCMD _IOWR(':', 0, struct cros_ec_command)
#define CROS_EC_DEV_IOCRDMEM _IOWR(':', 1, struct cros_ec_readmem)
+/*
+ * @version: Command version number (often 0)
+ * @command: Command to send (EC_CMD_...)
+ * @outsize: Outgoing length in bytes
+ * @insize: Max number of bytes to accept from EC
+ * @result: EC's response to the command (separate from communication failure)
+ * @data: Where to put the incoming data from EC and outgoing data to EC
+ */
+struct cros_ec_command_v2 {
+ uint32_t version;
+ uint32_t command;
+ uint32_t outsize;
+ uint32_t insize;
+ uint32_t result;
+ uint8_t data[0];
+};
+
+/*
+ * @offset: within EC_LPC_ADDR_MEMMAP region
+ * @bytes: number of bytes to read. zero means "read a string" (including '\0')
+ * (at most only EC_MEMMAP_SIZE bytes can be read)
+ * @buffer: where to store the result
+ * ioctl returns the number of bytes read, negative on error
+ */
+struct cros_ec_readmem_v2 {
+ uint32_t offset;
+ uint32_t bytes;
+ uint8_t buffer[EC_MEMMAP_SIZE];
+};
+
+#define CROS_EC_DEV_IOC_V2 0xEC
+#define CROS_EC_DEV_IOCXCMD_V2 _IOWR(CROS_EC_DEV_IOC_V2, 0, \
+ struct cros_ec_command_v2)
+#define CROS_EC_DEV_IOCRDMEM_V2 _IOWR(CROS_EC_DEV_IOC_V2, 1, \
+ struct cros_ec_readmem_v2)
+
#endif /* __UTIL_CROS_EC_DEV_H */