cpu: cortexm_common: explicitly define isr_pendsv and isr_svc

This commit is contained in:
Kaspar Schleiser 2016-08-10 16:04:56 +02:00
parent 25a6ef5273
commit 0bd2805b0c

View File

@ -296,17 +296,12 @@ void thread_arch_yield(void)
SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk; SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;
} }
__attribute__((naked)) void arch_context_switch(void) void __attribute__((naked)) __attribute__((used)) isr_pendsv(void) {
{
__asm__ volatile ( __asm__ volatile (
/* PendSV handler entry point */ /* PendSV handler entry point */
".global isr_pendsv \n"
".thumb_func \n"
"isr_pendsv: \n"
/* save context by pushing unsaved registers to the stack */ /* save context by pushing unsaved registers to the stack */
/* {r0-r3,r12,LR,PC,xPSR} are saved automatically on exception entry */ /* {r0-r3,r12,LR,PC,xPSR} are saved automatically on exception entry */
".thumb_func \n" ".thumb_func \n"
"context_save:"
"mrs r0, psp \n" /* get stack pointer from user mode */ "mrs r0, psp \n" /* get stack pointer from user mode */
#if defined(CPU_ARCH_CORTEX_M0) || defined(CPU_ARCH_CORTEX_M0PLUS) #if defined(CPU_ARCH_CORTEX_M0) || defined(CPU_ARCH_CORTEX_M0PLUS)
"mov r12, sp \n" /* remember the exception SP */ "mov r12, sp \n" /* remember the exception SP */
@ -332,11 +327,15 @@ __attribute__((naked)) void arch_context_switch(void)
"ldr r1, =sched_active_thread \n" /* load address of current tcb */ "ldr r1, =sched_active_thread \n" /* load address of current tcb */
"ldr r1, [r1] \n" /* dereference pdc */ "ldr r1, [r1] \n" /* dereference pdc */
"str r0, [r1] \n" /* write r0 to pdc->sp */ "str r0, [r1] \n" /* write r0 to pdc->sp */
"bl isr_svc \n" /* continue with svc */
);
}
void __attribute__((naked)) __attribute__((used)) isr_svc(void) {
__asm__ volatile (
/* SVC handler entry point */ /* SVC handler entry point */
/* PendSV will continue from above and through this part as well */ /* PendSV will continue here as well (via jump) */
".global isr_svc \n"
".thumb_func \n" ".thumb_func \n"
"isr_svc: \n"
/* perform scheduling */ /* perform scheduling */
"bl sched_run \n" "bl sched_run \n"
/* restore context and return from exception */ /* restore context and return from exception */