summaryrefslogtreecommitdiff
path: root/include/host_command.h
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 /include/host_command.h
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 'include/host_command.h')
-rw-r--r--include/host_command.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/include/host_command.h b/include/host_command.h
index 511e1369ee..b892a68ec8 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -11,14 +11,33 @@
#include "common.h"
#include "ec_commands.h"
+/* Args for host command handler */
+struct host_cmd_handler_args {
+ uint8_t command; /* Command (e.g., EC_CMD_FLASH_GET_INFO) */
+ uint8_t version; /* Version of command (0-31) */
+ const uint8_t *params; /* Input parameters */
+ uint8_t params_size; /* Size of input parameters in bytes */
+ /*
+ * Pointer to output response data buffer. On input to the handler,
+ * points to a EC_PARAM_SIZE-byte buffer. Command handler can change
+ * this to point to a different location instead of memcpy()'ing data
+ * into the provided buffer.
+ */
+ uint8_t *response;
+ uint8_t response_size; /* Size of data pointed to by resp_ptr */
+};
+
/* Host command */
struct host_command {
- /* Command code. */
+ /* Command code */
int command;
- /* Handler for the command; data points to parameters/response.
- * returns negative error code if case of failure (using EC_LPC_STATUS
- * codes). sets <response_size> if it returns a payload to the host. */
- int (*handler)(uint8_t *data, int *response_size);
+ /*
+ * Handler for the command. Args points to context for handler.
+ * Returns result status (EC_RES_*).
+ */
+ int (*handler)(struct host_cmd_handler_args *args);
+ /* Mask of supported versions */
+ int version_mask;
};
/**
@@ -94,9 +113,9 @@ void host_send_response(enum ec_status result, const uint8_t *data, int size);
uint8_t *host_get_buffer(void);
/* Register a host command handler */
-#define DECLARE_HOST_COMMAND(command, routine) \
+#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
const struct host_command __host_cmd_##command \
__attribute__((section(".rodata.hcmds"))) \
- = {command, routine}
+ = {command, routine, version_mask}
#endif /* __CROS_EC_HOST_COMMAND_H */