xref: /nrf52832-nimble/rt-thread/libcpu/m16c/m16c62p/context_gcc.S (revision 104654410c56c573564690304ae786df310c91fc)
1*10465441SEvalZero/*
2*10465441SEvalZero * File      : context.asm
3*10465441SEvalZero * This file is part of RT-Thread RTOS
4*10465441SEvalZero * COPYRIGHT (C) 2009, RT-Thread Development Team
5*10465441SEvalZero *
6*10465441SEvalZero * The license and distribution terms for this file may be
7*10465441SEvalZero * found in the file LICENSE in this distribution or at
8*10465441SEvalZero * http://www.rt-thread.org/license/LICENSE
9*10465441SEvalZero *
10*10465441SEvalZero * Change Logs:
11*10465441SEvalZero * Date           Author       Notes
12*10465441SEvalZero * 2010-04-09     fify         the first version
13*10465441SEvalZero * 2010-04-19     fify         rewrite rt_hw_interrupt_disable/enable fuction
14*10465441SEvalZero * 2010-04-20     fify         move peripheral ISR to bsp/interrupts.s34
15*10465441SEvalZero */
16*10465441SEvalZero
17*10465441SEvalZero    .section .text
18*10465441SEvalZero
19*10465441SEvalZero    .globl _rt_interrupt_from_thread
20*10465441SEvalZero    .globl _rt_interrupt_to_thread
21*10465441SEvalZero    .global	_os_context_switch
22*10465441SEvalZero    .type	_os_context_switch, @function
23*10465441SEvalZero_os_context_switch:
24*10465441SEvalZero    PUSHM   R0,R1,R2,R3,A0,A1,SB,FB
25*10465441SEvalZero
26*10465441SEvalZero    MOV.W   _rt_interrupt_from_thread, A0
27*10465441SEvalZero    STC     ISP, [A0]
28*10465441SEvalZero    MOV.W   _rt_interrupt_to_thread, A0
29*10465441SEvalZero    LDC     [A0], ISP
30*10465441SEvalZero
31*10465441SEvalZero    POPM    R0,R1,R2,R3,A0,A1,SB,FB             ; Restore registers from the new task's stack
32*10465441SEvalZero    REIT                                        ; Return from interrup
33*10465441SEvalZero
34*10465441SEvalZero/*
35*10465441SEvalZero * void rt_hw_context_switch_to(rt_uint32 to);
36*10465441SEvalZero * this fucntion is used to perform the first thread switch
37*10465441SEvalZero */
38*10465441SEvalZero    .global	_rt_hw_context_switch_to
39*10465441SEvalZero    .type	_rt_hw_context_switch_to, @function
40*10465441SEvalZero_rt_hw_context_switch_to:
41*10465441SEvalZero    ENTER   #0x0
42*10465441SEvalZero    MOV.W   0x5[FB], A0
43*10465441SEvalZero    LDC     [A0], ISP
44*10465441SEvalZero    POPM    R0,R1,R2,R3,A0,A1,SB,FB
45*10465441SEvalZero    REIT
46*10465441SEvalZero
47*10465441SEvalZero    .end
48