summaryrefslogtreecommitdiff
path: root/common/host_event_commands.c
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 /common/host_event_commands.c
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 'common/host_event_commands.c')
-rw-r--r--common/host_event_commands.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/common/host_event_commands.c b/common/host_event_commands.c
index 0d87fcac38..3242a6de83 100644
--- a/common/host_event_commands.c
+++ b/common/host_event_commands.c
@@ -5,6 +5,7 @@
/* Host event commands for Chrome EC */
+#include "common.h"
#include "console.h"
#include "host_command.h"
#include "lpc.h"
@@ -93,83 +94,94 @@ DECLARE_CONSOLE_COMMAND(hostevent, command_host_event,
#ifdef CONFIG_LPC
-static int host_event_get_smi_mask(uint8_t *data, int *resp_size)
+static int host_event_get_smi_mask(struct host_cmd_handler_args *args)
{
struct ec_response_host_event_mask *r =
- (struct ec_response_host_event_mask *)data;
+ (struct ec_response_host_event_mask *)args->response;
r->mask = lpc_get_host_event_mask(LPC_HOST_EVENT_SMI);
- *resp_size = sizeof(struct ec_response_host_event_mask);
+ args->response_size = sizeof(*r);
+
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_GET_SMI_MASK,
- host_event_get_smi_mask);
+ host_event_get_smi_mask,
+ EC_VER_MASK(0));
-static int host_event_get_sci_mask(uint8_t *data, int *resp_size)
+static int host_event_get_sci_mask(struct host_cmd_handler_args *args)
{
struct ec_response_host_event_mask *r =
- (struct ec_response_host_event_mask *)data;
+ (struct ec_response_host_event_mask *)args->response;
r->mask = lpc_get_host_event_mask(LPC_HOST_EVENT_SCI);
- *resp_size = sizeof(struct ec_response_host_event_mask);
+ args->response_size = sizeof(*r);
+
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_GET_SCI_MASK,
- host_event_get_sci_mask);
+ host_event_get_sci_mask,
+ EC_VER_MASK(0));
-static int host_event_get_wake_mask(uint8_t *data, int *resp_size)
+static int host_event_get_wake_mask(struct host_cmd_handler_args *args)
{
struct ec_response_host_event_mask *r =
- (struct ec_response_host_event_mask *)data;
+ (struct ec_response_host_event_mask *)args->response;
r->mask = lpc_get_host_event_mask(LPC_HOST_EVENT_WAKE);
- *resp_size = sizeof(struct ec_response_host_event_mask);
+ args->response_size = sizeof(*r);
+
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_GET_WAKE_MASK,
- host_event_get_wake_mask);
+ host_event_get_wake_mask,
+ EC_VER_MASK(0));
-static int host_event_set_smi_mask(uint8_t *data, int *resp_size)
+static int host_event_set_smi_mask(struct host_cmd_handler_args *args)
{
const struct ec_params_host_event_mask *p =
- (const struct ec_params_host_event_mask *)data;
+ (const struct ec_params_host_event_mask *)args->params;
lpc_set_host_event_mask(LPC_HOST_EVENT_SMI, p->mask);
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_SET_SMI_MASK,
- host_event_set_smi_mask);
+ host_event_set_smi_mask,
+ EC_VER_MASK(0));
-static int host_event_set_sci_mask(uint8_t *data, int *resp_size)
+static int host_event_set_sci_mask(struct host_cmd_handler_args *args)
{
const struct ec_params_host_event_mask *p =
- (const struct ec_params_host_event_mask *)data;
+ (const struct ec_params_host_event_mask *)args->params;
lpc_set_host_event_mask(LPC_HOST_EVENT_SCI, p->mask);
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_SET_SCI_MASK,
- host_event_set_sci_mask);
+ host_event_set_sci_mask,
+ EC_VER_MASK(0));
-static int host_event_set_wake_mask(uint8_t *data, int *resp_size)
+static int host_event_set_wake_mask(struct host_cmd_handler_args *args)
{
const struct ec_params_host_event_mask *p =
- (const struct ec_params_host_event_mask *)data;
+ (const struct ec_params_host_event_mask *)args->params;
lpc_set_host_event_mask(LPC_HOST_EVENT_WAKE, p->mask);
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_SET_WAKE_MASK,
- host_event_set_wake_mask);
+ host_event_set_wake_mask,
+ EC_VER_MASK(0));
#endif /* CONFIG_LPC */
-static int host_event_clear(uint8_t *data, int *resp_size)
+static int host_event_clear(struct host_cmd_handler_args *args)
{
const struct ec_params_host_event_mask *p =
- (const struct ec_params_host_event_mask *)data;
+ (const struct ec_params_host_event_mask *)args->params;
host_clear_events(p->mask);
return EC_RES_SUCCESS;
}
-DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_CLEAR, host_event_clear);
+DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_CLEAR,
+ host_event_clear,
+ EC_VER_MASK(0));