From 1f76d634a67342dafc47d5c075310407740d11f1 Mon Sep 17 00:00:00 2001 From: arighi Date: Wed, 31 Mar 2010 14:41:57 +0000 Subject: [PATCH] CM3: introduce asm_switch_context(). git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3359 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/cortex-m3/hw/switch_ctx_cm3.S | 54 ++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 bertos/cpu/cortex-m3/hw/switch_ctx_cm3.S 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 -- 2.25.1