summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2013-08-09 13:45:13 -0700
committerChromeBot <chrome-bot@google.com>2013-08-09 13:51:55 -0700
commit3e384c1a23471bd7d9c2eee680e0c138b56241cd (patch)
treeebf92af5260486ad091255fb87ad6055d894beeb
parent70b3c702391c91a88d2442ab856a5b897daf3da5 (diff)
downloadchrome-ec-3e384c1a23471bd7d9c2eee680e0c138b56241cd.tar.gz
Word-align the host memory map
This fixes unaligned access exceptions when totally-unrelated code changes happen to move around host_command.c's global variables. BUG=chrome-os-partner:21578 BRANCH=none TEST=add a ccprintf() call to host_command.c; no longer causes an exception Original-Change-Id: I5407e5631a08ea647dc40e5bd9c7bd101868ced0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/64233 Reviewed-by: Bill Richardson <wfrichar@chromium.org> (cherry picked from commit bebfb9431ed973703df03c8e2da11cf280315272) Change-Id: Ifff687a36fdaafce179be3e8b3ab040944712757 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/65362
-rw-r--r--common/host_command.c6
-rw-r--r--include/common.h9
2 files changed, 12 insertions, 3 deletions
diff --git a/common/host_command.c b/common/host_command.c
index c6f7ff1dc4..489ae7b35f 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -28,7 +28,11 @@
static struct host_cmd_handler_args *pending_args;
#ifndef CONFIG_LPC
-static uint8_t host_memmap[EC_MEMMAP_SIZE];
+/*
+ * Simulated memory map. Must be word-aligned, because some of the elements
+ * in the memory map are words.
+ */
+static uint8_t host_memmap[EC_MEMMAP_SIZE] __aligned(4);
#endif
static enum {
diff --git a/include/common.h b/include/common.h
index c6eeb11fef..235540d220 100644
--- a/include/common.h
+++ b/include/common.h
@@ -32,9 +32,14 @@
#define REG16(addr) (*(volatile uint16_t *)(addr))
/*
- * Define __packed if someone hasn't beat us to it. Linux kernel style
- * checking prefers __packed over __attribute__((packed)).
+ * Define __aligned(n) and __packed if someone hasn't beat us to it. Linux
+ * kernel style checking prefers these over __attribute__((packed)) and
+ * __attribute__((aligned(n))).
*/
+#ifndef __aligned
+#define __aligned(n) __attribute__((aligned(n)))
+#endif
+
#ifndef __packed
#define __packed __attribute__((packed))
#endif