summaryrefslogtreecommitdiff
path: root/libcpu/m16c/m16c62p/context_gcc.S
blob: ca6fde33d9646b0eb62b398fa8977eb99df785d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Copyright (c) 2006-2022, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2010-04-09     fify         the first version
 * 2010-04-19     fify         rewrite rt_hw_interrupt_disable/enable fuction
 * 2010-04-20     fify         move peripheral ISR to bsp/interrupts.s34
 */

    .section .text

    .globl _rt_interrupt_from_thread
    .globl _rt_interrupt_to_thread
    .global _os_context_switch
    .type   _os_context_switch, @function
_os_context_switch:
    PUSHM   R0,R1,R2,R3,A0,A1,SB,FB

    MOV.W   _rt_interrupt_from_thread, A0
    STC     ISP, [A0]
    MOV.W   _rt_interrupt_to_thread, A0
    LDC     [A0], ISP

    POPM    R0,R1,R2,R3,A0,A1,SB,FB             ; Restore registers from the new task's stack
    REIT                                        ; Return from interrup

/*
 * void rt_hw_context_switch_to(rt_uint32 to);
 * this fucntion is used to perform the first thread switch
 */
    .global _rt_hw_context_switch_to
    .type   _rt_hw_context_switch_to, @function
_rt_hw_context_switch_to:
    ENTER   #0x0
    MOV.W   0x5[FB], A0
    LDC     [A0], ISP
    POPM    R0,R1,R2,R3,A0,A1,SB,FB
    REIT

    .end