summaryrefslogtreecommitdiff
path: root/common/host_event_commands.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-03-02 10:16:43 -0800
committerRandall Spangler <rspangler@chromium.org>2012-03-05 09:23:51 -0800
commit2464e96469a816cf4144da4f0e7b957372181325 (patch)
treecb53b80bc76a6536cade7283891aaeff3e3264fc /common/host_event_commands.c
parent2ae113da5510fed2f0f24743802f5de023473256 (diff)
downloadchrome-ec-2464e96469a816cf4144da4f0e7b957372181325.tar.gz
Add SMI/SCI support
BUG=chrome-os-partner:8277 TEST=manual On EC console: hostevent set 0x1e From root shell: ectool eventget --> should return 0x1e ectool eventclear 0x02 ectool eventget --> should return 0x1c ectool queryec --> should return event 3 ectool queryec --> should return event 4 ectool queryec --> should return event 5 ectool queryec --> should return no event pending ectool eventsetsmimask 0x1200 ectool eventsetscimask 0x0034 ectool eventgetsmimask --> should return 0x1200 ectool eventgetscimask --> should return 0x0034 On EC console: hostevent --> should show raw=0 SMI mask = 0x1200 SCI mask = 0x34 Change-Id: I33042fa80c0b148cd63209a94a184af493e25ed3
Diffstat (limited to 'common/host_event_commands.c')
-rw-r--r--common/host_event_commands.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/common/host_event_commands.c b/common/host_event_commands.c
new file mode 100644
index 0000000000..058234ad6c
--- /dev/null
+++ b/common/host_event_commands.c
@@ -0,0 +1,113 @@
+/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Host event commands for Chrome EC */
+
+#include "console.h"
+#include "host_command.h"
+#include "lpc.h"
+#include "uart.h"
+#include "util.h"
+
+/*****************************************************************************/
+/* Console commands */
+
+static int command_host_event(int argc, char **argv)
+{
+ /* Handle sub-commands */
+ if (argc == 3) {
+ char *e;
+ int i = strtoi(argv[2], &e, 0);
+ if (*e) {
+ uart_puts("Invalid event mask\n");
+ return EC_ERROR_INVAL;
+ }
+
+ if (!strcasecmp(argv[1], "set")) {
+ uart_printf("Setting host event mask 0x%08x\n", i);
+ lpc_set_host_events(i);
+ } else if (!strcasecmp(argv[1], "clear")) {
+ uart_printf("Clearing host event mask 0x%08x\n", i);
+ lpc_clear_host_events(i);
+ } else if (!strcasecmp(argv[1], "smi")) {
+ uart_printf("Setting SMI mask to 0x%08x\n", i);
+ lpc_set_host_event_mask(0, i);
+ } else if (!strcasecmp(argv[1], "sci")) {
+ uart_printf("Setting SCI mask to 0x%08x\n", i);
+ lpc_set_host_event_mask(1, i);
+ } else {
+ uart_puts("Unknown sub-command\n");
+ return EC_ERROR_INVAL;
+ }
+ }
+
+ /* Print current SMI/SCI status */
+ uart_printf("Raw host events: 0x%08x\n", lpc_get_host_events());
+ uart_printf("SMI mask: 0x%08x\n", lpc_get_host_event_mask(0));
+ uart_printf("SCI mask: 0x%08x\n", lpc_get_host_event_mask(1));
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(hostevent, command_host_event);
+
+/*****************************************************************************/
+/* Host commands */
+
+static enum lpc_status host_event_get_smi_mask(uint8_t *data)
+{
+ struct lpc_response_host_event_get_smi_mask *r =
+ (struct lpc_response_host_event_get_smi_mask *)data;
+
+ r->mask = lpc_get_host_event_mask(0);
+ return EC_LPC_RESULT_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_LPC_COMMAND_HOST_EVENT_GET_SMI_MASK,
+ host_event_get_smi_mask);
+
+
+static enum lpc_status host_event_get_sci_mask(uint8_t *data)
+{
+ struct lpc_response_host_event_get_sci_mask *r =
+ (struct lpc_response_host_event_get_sci_mask *)data;
+
+ r->mask = lpc_get_host_event_mask(1);
+ return EC_LPC_RESULT_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_LPC_COMMAND_HOST_EVENT_GET_SCI_MASK,
+ host_event_get_sci_mask);
+
+
+static enum lpc_status host_event_set_smi_mask(uint8_t *data)
+{
+ const struct lpc_params_host_event_set_smi_mask *p =
+ (const struct lpc_params_host_event_set_smi_mask *)data;
+
+ lpc_set_host_event_mask(0, p->mask);
+ return EC_LPC_RESULT_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_LPC_COMMAND_HOST_EVENT_SET_SMI_MASK,
+ host_event_set_smi_mask);
+
+
+static enum lpc_status host_event_set_sci_mask(uint8_t *data)
+{
+ const struct lpc_params_host_event_set_sci_mask *p =
+ (const struct lpc_params_host_event_set_sci_mask *)data;
+
+ lpc_set_host_event_mask(1, p->mask);
+ return EC_LPC_RESULT_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_LPC_COMMAND_HOST_EVENT_SET_SCI_MASK,
+ host_event_set_sci_mask);
+
+
+static enum lpc_status host_event_clear(uint8_t *data)
+{
+ const struct lpc_params_host_event_clear *p =
+ (const struct lpc_params_host_event_clear *)data;
+
+ lpc_clear_host_events(p->mask);
+ return EC_LPC_RESULT_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_LPC_COMMAND_HOST_EVENT_CLEAR, host_event_clear);