summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-05-31 14:02:37 -0700
committerGerrit <chrome-bot@google.com>2012-05-31 15:03:17 -0700
commit11ab34a721aa40d8e891b6e1bab8e5633bfe8168 (patch)
tree957723a9743c2c4c8f4a3ab71f9144a7af19781b /core
parent53e8d3201ccd1b36ea739afdf8ac9b930bd4f23d (diff)
downloadchrome-ec-11ab34a721aa40d8e891b6e1bab8e5633bfe8168.tar.gz
Fix alignment of task scratchpad and system stack
Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:10042 TEST=boot system, ctrl+alt+F2, type on console; shouldn't crash Change-Id: I935bc141fbbc1e7d0d073f1754104808a24fe869 Reviewed-on: https://gerrit.chromium.org/gerrit/24232 Commit-Ready: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/cortex-m/ec.lds.S7
-rw-r--r--core/cortex-m/init.S5
-rw-r--r--core/cortex-m/task.c8
3 files changed, 14 insertions, 6 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index 4eee36f763..2b22a76809 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -101,9 +101,14 @@ SECTIONS
#endif
__ro_end = . ;
.bss : {
- . = ALIGN(4);
+ /* Stacks must be 64-bit aligned */
+ . = ALIGN(8);
__bss_start = .;
*(.bss.tasks)
+ *(.bss.task_scratchpad)
+ . = ALIGN(8);
+ *(.bss.system_stack)
+ /* Rest of .bss takes care of its own alignment */
*(.bss)
. = ALIGN(4);
__bss_end = .;
diff --git a/core/cortex-m/init.S b/core/cortex-m/init.S
index a2c0d0b71e..bef720d46c 100644
--- a/core/cortex-m/init.S
+++ b/core/cortex-m/init.S
@@ -390,11 +390,10 @@ __aeabi_unwind_cpp_pr1:
__aeabi_unwind_cpp_pr2:
bx lr
-.section .bss
-
/* Reserve space for system stack */
+.section .bss.system_stack
stack_start:
.space CONFIG_STACK_SIZE, 0
stack_end:
- .globl stack_end
+ .global stack_end
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c
index 41b0b7e39a..154994bccf 100644
--- a/core/cortex-m/task.c
+++ b/core/cortex-m/task.c
@@ -108,8 +108,12 @@ static const struct {
/* Contexts and stacks for all tasks. */
static task_ tasks[TASK_ID_COUNT] __attribute__((section(".bss.tasks")))
__attribute__((aligned(TASK_SIZE)));
-/* Reserve space to discard context on first context switch. */
-uint32_t scratchpad[17] __attribute__((section(".data.tasks")));
+/* Reserve space to discard context on first context switch. This must
+ * immediately follow tasks, so that it is start-aligned to TASK_SIZE so that
+ * __get_current(scratchpad) == scratchpad. Note that aligned(TASK_SIZE) also
+ * size-aligns it, which wastes (512 - 17*4) bytes of RAM, so we simply put it
+ * in its own section which immediately follows .bss.tasks in ec.lds.S. */
+uint32_t scratchpad[17] __attribute__((section(".bss.task_scratchpad")));
/* Should IRQs chain to svc_handler()? This should be set if either of the
* following is true: