summaryrefslogtreecommitdiff
path: root/board/reef_it8320
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2017-07-22 17:49:39 +0300
committerchrome-bot <chrome-bot@chromium.org>2017-08-28 10:55:41 -0700
commite5c69151dfd895162118023b6c591686dd49d4c9 (patch)
treeec08ccfd0dc61b12c305697db5f538e933a5f6da /board/reef_it8320
parent98405d4eaec40e1ac9b8f0344ea8ddbc2747a4c9 (diff)
downloadchrome-ec-e5c69151dfd895162118023b6c591686dd49d4c9.tar.gz
cortex-m0: Use assembly exception handlers for task switching
The way Cortex processors handle exceptions allows writing exception routines directly in C, as return from exception is handled by providing a special value for the link register. However, it is not safe to do this when doing context switching. In particular, C handlers may push some general-purpose registers that are used by the handler and pop them later, even when context switch has happened in the meantime. While the processor will restore {r0-r3} from the stack when returning from an exception, the C handler code may push, use and pop another register, such as r4. It turns out that GCC 4.8 would generally only use r3 in svc_handler and pendsv_handler, but newer versions tend to use r4, thus clobbering r4 that was restored from the context switch and leading up to a fault when r4 is used by the task code. An occurrence of this behaviour takes place with GCC > 4.8 in __wait_evt, where "me" is stored in r4, which gets clobbered after an exception triggers pendsv_handler. The exception handler uses r4 internally, does a context switch and then restores the previous value of r4, which is not restored by the processor's internal, thus clobbering r4. This ends up with the following assertion failure: 'tskid < TASK_ID_COUNT' in timer_cancel() at common/timer.c:137 For this reason, it is safer to have assembly routines for exception handlers that do context switching. BUG=chromium:631514 BRANCH=None TEST=Build and run speedy EC with a recent GCC version Change-Id: Ib068bc12ce2204aee3e0f563efcb94f15aa87013 Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-on: https://chromium-review.googlesource.com/362830 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'board/reef_it8320')
0 files changed, 0 insertions, 0 deletions