Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:26

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  *  This file contains the basic algorithms for all assembly code used
0007  *  in an specific CPU port of RTEMS.  These algorithms must be implemented
0008  *  in assembly language
0009  */
0010 
0011 /*
0012  *  COPYRIGHT (c) 1989-2012.
0013  *  On-Line Applications Research Corporation (OAR).
0014  *
0015  * Redistribution and use in source and binary forms, with or without
0016  * modification, are permitted provided that the following conditions
0017  * are met:
0018  * 1. Redistributions of source code must retain the above copyright
0019  *    notice, this list of conditions and the following disclaimer.
0020  * 2. Redistributions in binary form must reproduce the above copyright
0021  *    notice, this list of conditions and the following disclaimer in the
0022  *    documentation and/or other materials provided with the distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 #ifdef HAVE_CONFIG_H
0038 #include "config.h"
0039 #endif
0040 
0041 #if 0
0042 /**
0043  *  This routine is responsible for saving the FP context
0044  *  at *fp_context_ptr.  If the point to load the FP context
0045  *  from is changed then the pointer is modified by this routine.
0046  *
0047  *  Sometimes a macro implementation of this is in cpu.h which dereferences
0048  *  the ** and a similarly named routine in this file is passed something
0049  *  like a (Context_Control_fp *).  The general rule on making this decision
0050  *  is to avoid writing assembly language.
0051  *
0052  *  v850 Specific Information:
0053  *
0054  *  The v850 appears to always have soft float.
0055  */
0056 void _CPU_Context_save_fp(
0057   Context_Control_fp **fp_context_ptr
0058 )
0059 {
0060 }
0061 
0062 /**
0063  *  This routine is responsible for restoring the FP context
0064  *  at *fp_context_ptr.  If the point to load the FP context
0065  *  from is changed then the pointer is modified by this routine.
0066  *
0067  *  Sometimes a macro implementation of this is in cpu.h which dereferences
0068  *  the ** and a similarly named routine in this file is passed something
0069  *  like a (Context_Control_fp *).  The general rule on making this decision
0070  *  is to avoid writing assembly language.
0071  *
0072  *  v850 Specific Information:
0073  *
0074  *  XXX document implementation including references if appropriate
0075  */
0076 void _CPU_Context_restore_fp(
0077   Context_Control_fp **fp_context_ptr
0078 )
0079 {
0080 }
0081 #endif
0082 
0083 /**
0084  *  This routine performs a normal non-FP context switch.
0085  *
0086  *  v850 Specific Information:
0087  *
0088  *  + r6 - running thread
0089  *  + r7 - heir thread
0090  */
0091 #define V850_CONTEXT_CONTROL_R1_OFFSET   0
0092 #define V850_CONTEXT_CONTROL_R3_OFFSET   4
0093 #define V850_CONTEXT_CONTROL_R20_OFFSET  8
0094 #define V850_CONTEXT_CONTROL_R21_OFFSET 12
0095 #define V850_CONTEXT_CONTROL_R22_OFFSET 16
0096 #define V850_CONTEXT_CONTROL_R23_OFFSET 20
0097 #define V850_CONTEXT_CONTROL_R24_OFFSET 24
0098 #define V850_CONTEXT_CONTROL_R25_OFFSET 28
0099 #define V850_CONTEXT_CONTROL_R26_OFFSET 32
0100 #define V850_CONTEXT_CONTROL_R27_OFFSET 36
0101 #define V850_CONTEXT_CONTROL_R28_OFFSET 40
0102 #define V850_CONTEXT_CONTROL_R29_OFFSET 44
0103 #define V850_CONTEXT_CONTROL_R31_OFFSET 48
0104 #define V850_CONTEXT_CONTROL_PSW_OFFSET 52
0105 
0106         .section .text
0107         .global  __CPU_Context_switch
0108         .type    __CPU_Context_switch, @function
0109 __CPU_Context_switch:
0110         st.w     r1,V850_CONTEXT_CONTROL_R1_OFFSET[r6]
0111         st.w     r3,V850_CONTEXT_CONTROL_R3_OFFSET[r6]
0112         st.w     r20,V850_CONTEXT_CONTROL_R20_OFFSET[r6]
0113         st.w     r21,V850_CONTEXT_CONTROL_R21_OFFSET[r6]
0114         st.w     r22,V850_CONTEXT_CONTROL_R22_OFFSET[r6]
0115         st.w     r23,V850_CONTEXT_CONTROL_R23_OFFSET[r6]
0116         st.w     r24,V850_CONTEXT_CONTROL_R24_OFFSET[r6]
0117         st.w     r25,V850_CONTEXT_CONTROL_R25_OFFSET[r6]
0118         st.w     r26,V850_CONTEXT_CONTROL_R27_OFFSET[r6]
0119         st.w     r27,V850_CONTEXT_CONTROL_R27_OFFSET[r6]
0120         st.w     r28,V850_CONTEXT_CONTROL_R28_OFFSET[r6]
0121         st.w     r29,V850_CONTEXT_CONTROL_R29_OFFSET[r6]
0122         st.w     r31,V850_CONTEXT_CONTROL_R31_OFFSET[r6]
0123     stsr     psw,r21
0124         st.w     r21,V850_CONTEXT_CONTROL_PSW_OFFSET[r6]
0125 restore:
0126         ld.w     V850_CONTEXT_CONTROL_R1_OFFSET[r7],r1
0127         ld.w     V850_CONTEXT_CONTROL_R3_OFFSET[r7],r3
0128         ld.w     V850_CONTEXT_CONTROL_R20_OFFSET[r7],r20
0129         ld.w     V850_CONTEXT_CONTROL_R21_OFFSET[r7],r21
0130         ld.w     V850_CONTEXT_CONTROL_R22_OFFSET[r7],r22
0131         ld.w     V850_CONTEXT_CONTROL_R23_OFFSET[r7],r23
0132         ld.w     V850_CONTEXT_CONTROL_R24_OFFSET[r7],r24
0133         ld.w     V850_CONTEXT_CONTROL_R25_OFFSET[r7],r25
0134         ld.w     V850_CONTEXT_CONTROL_R27_OFFSET[r7],r26
0135         ld.w     V850_CONTEXT_CONTROL_R27_OFFSET[r7],r27
0136         ld.w     V850_CONTEXT_CONTROL_R28_OFFSET[r7],r28
0137         ld.w     V850_CONTEXT_CONTROL_R29_OFFSET[r7],r29
0138         ld.w     V850_CONTEXT_CONTROL_R31_OFFSET[r7],r31
0139         ld.w     V850_CONTEXT_CONTROL_PSW_OFFSET[r7],r7
0140     ldsr     r7,psw
0141         jmp      [r31]
0142 
0143 
0144 /**
0145  *  This routine is generally used only to restart self in an
0146  *  efficient manner.  It may simply be a label in _CPU_Context_switch.
0147  *
0148  *  NOTE: May be unnecessary to reload some registers.
0149  *
0150  *  v850 Specific Information:
0151  *
0152  *  Move second parameter to first and jump to normal restore
0153  */
0154         .section .text
0155         .global  __CPU_Context_restore
0156         .type    __CPU_Context_restore, @function
0157 __CPU_Context_restore:
0158         mov      r6, r7         /* move to second parameter register */
0159         br       restore