summaryrefslogtreecommitdiff
path: root/common/host_command.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-03 14:45:59 -0700
committerGerrit <chrome-bot@google.com>2012-07-07 17:14:18 -0700
commit7f5f7be3e5df92ec2e9447b3d5d0b8ddeb96c9a0 (patch)
treef58e23fa5d053e31163faf8279882f0d9891c1fe /common/host_command.c
parent0e42faf85b3a4adbc83cb087e0bdab7641df9f1b (diff)
downloadchrome-ec-7f5f7be3e5df92ec2e9447b3d5d0b8ddeb96c9a0.tar.gz
Add memory-mapped data support for I2C and SPI protocols
And fix returning memory-mapped string length on LPC as well. BUG=chrome-os-partner:11090 TEST=manual from EC, 'hostevent set 0x40000' from host, 'ectool eventget' --> should print 0x40000 Signed-off-by: Randall Spangler <rspangler@chromium.org> Change-Id: I9edbd0a1468b5d4160ce67c471332226e51fa868 Reviewed-on: https://gerrit.chromium.org/gerrit/26719 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/host_command.c')
-rw-r--r--common/host_command.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/common/host_command.c b/common/host_command.c
index cc7de1e473..3647e50cda 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -23,6 +23,18 @@
static int host_command[2];
+#ifndef CONFIG_LPC
+static uint8_t host_memmap[EC_MEMMAP_SIZE];
+#endif
+
+uint8_t *host_get_memmap(int offset)
+{
+#ifdef CONFIG_LPC
+ return lpc_get_memmap_range() + offset;
+#else
+ return host_memmap + offset;
+#endif
+}
void host_command_received(int slot, int command)
{
@@ -93,6 +105,32 @@ static int host_command_read_test(uint8_t *data, int *resp_size)
}
DECLARE_HOST_COMMAND(EC_CMD_READ_TEST, host_command_read_test);
+#ifndef CONFIG_LPC
+/*
+ * Host command to read memory map is not needed on LPC, because LPC can
+ * directly map the data to the host's memory space.
+ */
+static int host_command_read_memmap(uint8_t *data, int *resp_size)
+{
+ struct ec_params_read_memmap *p = (struct ec_params_read_memmap *)data;
+ struct ec_response_read_memmap *r =
+ (struct ec_response_read_memmap *)data;
+
+ /* Copy params out of data before we overwrite it with output */
+ uint8_t offset = p->offset;
+ uint8_t size = p->size;
+
+ if (size > sizeof(r->data) || offset > EC_MEMMAP_SIZE ||
+ offset + size > EC_MEMMAP_SIZE)
+ return EC_RES_INVALID_PARAM;
+
+ memcpy(r->data, host_get_memmap(offset), size);
+
+ *resp_size = size;
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_READ_MEMMAP, host_command_read_memmap);
+#endif
#ifdef CONFIG_LPC
/* ACPI query event handler. Note that the returned value is NOT actually
@@ -114,7 +152,7 @@ static int host_command_acpi_query_event(uint8_t *data, int *resp_size)
return 0;
}
DECLARE_HOST_COMMAND(EC_CMD_ACPI_QUERY_EVENT, host_command_acpi_query_event);
-#endif
+#endif /* CONFIG_LPC */
/* Finds a command by command number. Returns the command structure, or NULL if