source: rtems/cpukit/score/cpu/v850/cpu_asm.S

Last change on this file was c0ec0b29, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 22:51:18

score/cpu/v850: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 *  This file contains the basic algorithms for all assembly code used
7 *  in an specific CPU port of RTEMS.  These algorithms must be implemented
8 *  in assembly language
9 */
10
11/*
12 *  COPYRIGHT (c) 1989-2012.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 *    notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 *    notice, this list of conditions and the following disclaimer in the
22 *    documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifdef HAVE_CONFIG_H
38#include "config.h"
39#endif
40
41#if 0
42/**
43 *  This routine is responsible for saving the FP context
44 *  at *fp_context_ptr.  If the point to load the FP context
45 *  from is changed then the pointer is modified by this routine.
46 *
47 *  Sometimes a macro implementation of this is in cpu.h which dereferences
48 *  the ** and a similarly named routine in this file is passed something
49 *  like a (Context_Control_fp *).  The general rule on making this decision
50 *  is to avoid writing assembly language.
51 *
52 *  v850 Specific Information:
53 *
54 *  The v850 appears to always have soft float.
55 */
56void _CPU_Context_save_fp(
57  Context_Control_fp **fp_context_ptr
58)
59{
60}
61
62/**
63 *  This routine is responsible for restoring the FP context
64 *  at *fp_context_ptr.  If the point to load the FP context
65 *  from is changed then the pointer is modified by this routine.
66 *
67 *  Sometimes a macro implementation of this is in cpu.h which dereferences
68 *  the ** and a similarly named routine in this file is passed something
69 *  like a (Context_Control_fp *).  The general rule on making this decision
70 *  is to avoid writing assembly language.
71 *
72 *  v850 Specific Information:
73 *
74 *  XXX document implementation including references if appropriate
75 */
76void _CPU_Context_restore_fp(
77  Context_Control_fp **fp_context_ptr
78)
79{
80}
81#endif
82
83/**
84 *  This routine performs a normal non-FP context switch.
85 *
86 *  v850 Specific Information:
87 *
88 *  + r6 - running thread
89 *  + r7 - heir thread
90 */
91#define V850_CONTEXT_CONTROL_R1_OFFSET   0
92#define V850_CONTEXT_CONTROL_R3_OFFSET   4
93#define V850_CONTEXT_CONTROL_R20_OFFSET  8
94#define V850_CONTEXT_CONTROL_R21_OFFSET 12
95#define V850_CONTEXT_CONTROL_R22_OFFSET 16
96#define V850_CONTEXT_CONTROL_R23_OFFSET 20
97#define V850_CONTEXT_CONTROL_R24_OFFSET 24
98#define V850_CONTEXT_CONTROL_R25_OFFSET 28
99#define V850_CONTEXT_CONTROL_R26_OFFSET 32
100#define V850_CONTEXT_CONTROL_R27_OFFSET 36
101#define V850_CONTEXT_CONTROL_R28_OFFSET 40
102#define V850_CONTEXT_CONTROL_R29_OFFSET 44
103#define V850_CONTEXT_CONTROL_R31_OFFSET 48
104#define V850_CONTEXT_CONTROL_PSW_OFFSET 52
105
106        .section .text
107        .global  __CPU_Context_switch
108        .type    __CPU_Context_switch, @function
109__CPU_Context_switch:
110        st.w     r1,V850_CONTEXT_CONTROL_R1_OFFSET[r6]
111        st.w     r3,V850_CONTEXT_CONTROL_R3_OFFSET[r6]
112        st.w     r20,V850_CONTEXT_CONTROL_R20_OFFSET[r6]
113        st.w     r21,V850_CONTEXT_CONTROL_R21_OFFSET[r6]
114        st.w     r22,V850_CONTEXT_CONTROL_R22_OFFSET[r6]
115        st.w     r23,V850_CONTEXT_CONTROL_R23_OFFSET[r6]
116        st.w     r24,V850_CONTEXT_CONTROL_R24_OFFSET[r6]
117        st.w     r25,V850_CONTEXT_CONTROL_R25_OFFSET[r6]
118        st.w     r26,V850_CONTEXT_CONTROL_R27_OFFSET[r6]
119        st.w     r27,V850_CONTEXT_CONTROL_R27_OFFSET[r6]
120        st.w     r28,V850_CONTEXT_CONTROL_R28_OFFSET[r6]
121        st.w     r29,V850_CONTEXT_CONTROL_R29_OFFSET[r6]
122        st.w     r31,V850_CONTEXT_CONTROL_R31_OFFSET[r6]
123        stsr     psw,r21
124        st.w     r21,V850_CONTEXT_CONTROL_PSW_OFFSET[r6]
125restore:
126        ld.w     V850_CONTEXT_CONTROL_R1_OFFSET[r7],r1
127        ld.w     V850_CONTEXT_CONTROL_R3_OFFSET[r7],r3
128        ld.w     V850_CONTEXT_CONTROL_R20_OFFSET[r7],r20
129        ld.w     V850_CONTEXT_CONTROL_R21_OFFSET[r7],r21
130        ld.w     V850_CONTEXT_CONTROL_R22_OFFSET[r7],r22
131        ld.w     V850_CONTEXT_CONTROL_R23_OFFSET[r7],r23
132        ld.w     V850_CONTEXT_CONTROL_R24_OFFSET[r7],r24
133        ld.w     V850_CONTEXT_CONTROL_R25_OFFSET[r7],r25
134        ld.w     V850_CONTEXT_CONTROL_R27_OFFSET[r7],r26
135        ld.w     V850_CONTEXT_CONTROL_R27_OFFSET[r7],r27
136        ld.w     V850_CONTEXT_CONTROL_R28_OFFSET[r7],r28
137        ld.w     V850_CONTEXT_CONTROL_R29_OFFSET[r7],r29
138        ld.w     V850_CONTEXT_CONTROL_R31_OFFSET[r7],r31
139        ld.w     V850_CONTEXT_CONTROL_PSW_OFFSET[r7],r7
140        ldsr     r7,psw
141        jmp      [r31]
142
143
144/**
145 *  This routine is generally used only to restart self in an
146 *  efficient manner.  It may simply be a label in _CPU_Context_switch.
147 *
148 *  NOTE: May be unnecessary to reload some registers.
149 *
150 *  v850 Specific Information:
151 *
152 *  Move second parameter to first and jump to normal restore
153 */
154        .section .text
155        .global  __CPU_Context_restore
156        .type    __CPU_Context_restore, @function
157__CPU_Context_restore:
158        mov      r6, r7         /* move to second parameter register */
159        br       restore
Note: See TracBrowser for help on using the repository browser.