From: arighi Date: Wed, 31 Mar 2010 14:41:57 +0000 (+0000) Subject: CM3: introduce asm_switch_context(). X-Git-Tag: 2.5.0~549 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=1f76d634a67342dafc47d5c075310407740d11f1;p=bertos.git CM3: introduce asm_switch_context(). git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3359 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/cortex-m3/hw/switch_ctx_cm3.S b/bertos/cpu/cortex-m3/hw/switch_ctx_cm3.S new file mode 100644 index 00000000..bda6793c --- /dev/null +++ b/bertos/cpu/cortex-m3/hw/switch_ctx_cm3.S @@ -0,0 +1,54 @@ +/** + * \file + * + * + * \brief Cortex-M3 context switch + * + * \author Andrea Righi + */ + +.syntax unified + +/* void asm_switch_context(void **new_sp [r0], void **save_sp [r1]) */ +.global asm_switch_context +.thumb_func +asm_switch_context: + mrs r12, msp + /* Save registers */ + stmdb r12!, {r4-r11, lr} + /* Save old stack pointer */ + str r12, [r1] + /* Load new stack pointer */ + ldr r12, [r0] + /* Load new registers */ + ldmia r12!, {r4-r11, lr} + msr msp, r12 + bx lr