summaryrefslogtreecommitdiff
path: root/util/comm-dev.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-06-21 18:25:20 -0700
committerChromeBot <chrome-bot@google.com>2013-07-03 14:22:04 -0700
commit85a1941f9d166f964e5369e676378bfc7e5a0b4b (patch)
treeba88524801cd18535412203ac8988620c81fff10 /util/comm-dev.c
parent34e5148a45f33c41ded184660ce4f013592c46dc (diff)
downloadchrome-ec-85a1941f9d166f964e5369e676378bfc7e5a0b4b.tar.gz
Use EC_CMD_READ_MEMMAP on platforms without mapped memory.
LPC-based ECs provide a region of memory that is mapped into the AP's address space, making it easy to read. This CL uses an alternate EC host command to read that region, for those systems that don't have mapped memory. BUG=none BRANCH=none TEST=none I tested this by building a special command into ectool. Change-Id: If5cc52356f61522ae96e20d4c5d365accc299987 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/59662
Diffstat (limited to 'util/comm-dev.c')
-rw-r--r--util/comm-dev.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/util/comm-dev.c b/util/comm-dev.c
index 3e45ab866e..c6bd6b4176 100644
--- a/util/comm-dev.c
+++ b/util/comm-dev.c
@@ -55,12 +55,26 @@ static int ec_command_dev(int command, int version,
static int ec_readmem_dev(int offset, int bytes, void *dest)
{
struct cros_ec_readmem s_mem;
+ struct ec_params_read_memmap r_mem;
+ int r;
+ static int fake_it;
+
+ if (!fake_it) {
+ s_mem.offset = offset;
+ s_mem.bytes = bytes;
+ s_mem.buffer = dest;
+ r = ioctl(fd, CROS_EC_DEV_IOCRDMEM, &s_mem);
+ if (r < 0 && errno == ENOTTY)
+ fake_it = 1;
+ else
+ return r;
+ }
- s_mem.offset = offset;
- s_mem.bytes = bytes;
- s_mem.buffer = dest;
-
- return ioctl(fd, CROS_EC_DEV_IOCRDMEM, &s_mem);
+ r_mem.offset = offset;
+ r_mem.size = bytes;
+ return ec_command_dev(EC_CMD_READ_MEMMAP, 0,
+ &r_mem, sizeof(r_mem),
+ dest, bytes);
}
int comm_init_dev(void)
@@ -88,7 +102,8 @@ int comm_init_dev(void)
}
ec_command = ec_command_dev;
- if (ec_readmem_dev(EC_MEMMAP_ID, 2, version) == 2)
+ if (ec_readmem_dev(EC_MEMMAP_ID, 2, version) == 2 &&
+ version[0] == 'E' && version[1] == 'C')
ec_readmem = ec_readmem_dev;
/*