1/*
2 * Copyright (c) 2006-2021, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date           Author       Notes
8 * 2010-04-20     fify         the first version
9 *
10 * For       : Renesas M16C
11 * Toolchain : IAR's EW for M16C v3.401
12 */
13
14    .text
15
16    .globl  _rt_hw_context_switch_interrupt_do
17    .type   _rt_hw_context_switch_interrupt_do, #function
18_rt_hw_context_switch_interrupt_do:
19    MOV.B   #0, _rt_thread_switch_interrupt_flag
20    MOV.W   _rt_interrupt_from_thread, A0
21    STC     ISP, [A0]
22
23    MOV.W   _rt_interrupt_to_thread, A0
24    LDC     [A0], ISP
25    POPM    R0,R1,R2,R3,A0,A1,SB,FB             ; Restore all processor registers from the new task's stack
26    REIT
27
28    .text
29    .globl  _rt_hw_timer_handler
30    .type   _rt_hw_timer_handler, #function
31_rt_hw_timer_handler:
32    PUSHM   R0,R1,R2,R3,A0,A1,SB,FB             ; Save current task's registers
33    jsr.a     _rt_interrupt_enter
34    jsr.a     _rt_tick_increase
35    jsr.a     _rt_interrupt_leave
36
37    CMP.B   #1, _rt_thread_switch_interrupt_flag
38    JEQ     _rt_hw_context_switch_interrupt_do
39
40    POPM    R0,R1,R2,R3,A0,A1,SB,FB             ; Restore current task's registers
41    REIT                                        ; Return from interrup
42
43    .text
44    .globl  _rt_hw_uart0_receive_handler
45    .type   _rt_hw_uart0_receive_handler, #function
46_rt_hw_uart0_receive_handler:
47    PUSHM   R0,R1,R2,R3,A0,A1,SB,FB             ; Save current task's registers
48    jsr.a     _rt_interrupt_enter
49    jsr.a     _u0rec_handler
50    jsr.a     _rt_interrupt_leave
51
52    CMP.B   #1, _rt_thread_switch_interrupt_flag
53    JEQ     _rt_hw_context_switch_interrupt_do
54
55    POPM    R0,R1,R2,R3,A0,A1,SB,FB             ; Restore current task's registers
56    REIT                                        ; Return from interrup
57
58