source: rtems/cpukit/score/cpu/v850/cpu_asm.S @ 68e1ccc4

5
Last change on this file since 68e1ccc4 was 511dc4b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/19/18 at 07:09:51

Rework initialization and interrupt stack support

Statically initialize the interrupt stack area
(_Configuration_Interrupt_stack_area_begin,
_Configuration_Interrupt_stack_area_end, and
_Configuration_Interrupt_stack_size) via <rtems/confdefs.h>. Place the
interrupt stack area in a special section ".rtemsstack.interrupt". Let
BSPs define the optimal placement of this section in their linker
command files (e.g. in a fast on-chip memory).

This change makes makes the CPU_HAS_SOFTWARE_INTERRUPT_STACK and
CPU_HAS_HARDWARE_INTERRUPT_STACK CPU port defines superfluous, since the
low level initialization code has all information available via global
symbols.

This change makes the CPU_ALLOCATE_INTERRUPT_STACK CPU port define
superfluous, since the interrupt stacks are allocated by confdefs.h for
all architectures. There is no need for BSP-specific linker command
file magic (except the section placement), see previous ARM linker
command file as a bad example.

Remove _CPU_Install_interrupt_stack(). Initialize the hardware
interrupt stack in _CPU_Initialize() if necessary (e.g.
m68k_install_interrupt_stack()).

The optional _CPU_Interrupt_stack_setup() is still useful to customize
the registration of the interrupt stack area in the per-CPU information.

The initialization stack can reuse the interrupt stack, since

  • interrupts are disabled during the sequential system initialization, and
  • the boot_card() function does not return.

This stack resuse saves memory.

Changes per architecture:

arm:

  • Mostly replace the linker symbol based configuration of stacks with the standard <rtems/confdefs.h> configuration via CONFIGURE_INTERRUPT_STACK_SIZE. The size of the FIQ, ABT and UND mode stack is still defined via linker symbols. These modes are rarely used in applications and the default values provided by the BSP should be sufficient in most cases.
  • Remove the bsp_processor_count linker symbol hack used for the SMP support. This is possible since the interrupt stack area is now allocated by the linker and not allocated from the heap. This makes some configure.ac stuff obsolete. Remove the now superfluous BSP variants altcycv_devkit_smp and realview_pbx_a9_qemu_smp.

bfin:

  • Remove unused magic linker command file allocation of initialization stack. Maybe a previous linker command file copy and paste problem? In the start.S the initialization stack is set to a hard coded value.

lm32, m32c, mips, nios2, riscv, sh, v850:

  • Remove magic linker command file allocation of initialization stack. Reuse interrupt stack for initialization stack.

m68k:

  • Remove magic linker command file allocation of initialization stack. Reuse interrupt stack for initialization stack.

powerpc:

  • Remove magic linker command file allocation of initialization stack. Reuse interrupt stack for initialization stack.
  • Used dedicated memory region (REGION_RTEMSSTACK) for the interrupt stack on BSPs using the shared linkcmds.base (replacement for REGION_RWEXTRA).

sparc:

  • Remove the hard coded initialization stack. Use the interrupt stack for the initialization stack on the boot processor. This saves 16KiB of RAM.

Update #3459.

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/**
2 * @file
3 *
4 *  This file contains the basic algorithms for all assembly code used
5 *  in an specific CPU port of RTEMS.  These algorithms must be implemented
6 *  in assembly language
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2012.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifdef HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#if 0
23/**
24 *  This routine is responsible for saving the FP context
25 *  at *fp_context_ptr.  If the point to load the FP context
26 *  from is changed then the pointer is modified by this routine.
27 *
28 *  Sometimes a macro implementation of this is in cpu.h which dereferences
29 *  the ** and a similarly named routine in this file is passed something
30 *  like a (Context_Control_fp *).  The general rule on making this decision
31 *  is to avoid writing assembly language.
32 *
33 *  v850 Specific Information:
34 *
35 *  The v850 appears to always have soft float.
36 */
37void _CPU_Context_save_fp(
38  Context_Control_fp **fp_context_ptr
39)
40{
41}
42
43/**
44 *  This routine is responsible for restoring the FP context
45 *  at *fp_context_ptr.  If the point to load the FP context
46 *  from is changed then the pointer is modified by this routine.
47 *
48 *  Sometimes a macro implementation of this is in cpu.h which dereferences
49 *  the ** and a similarly named routine in this file is passed something
50 *  like a (Context_Control_fp *).  The general rule on making this decision
51 *  is to avoid writing assembly language.
52 *
53 *  v850 Specific Information:
54 *
55 *  XXX document implementation including references if appropriate
56 */
57void _CPU_Context_restore_fp(
58  Context_Control_fp **fp_context_ptr
59)
60{
61}
62#endif
63
64/**
65 *  This routine performs a normal non-FP context switch.
66 *
67 *  v850 Specific Information:
68 *
69 *  + r6 - running thread
70 *  + r7 - heir thread
71 */
72#define V850_CONTEXT_CONTROL_R1_OFFSET   0
73#define V850_CONTEXT_CONTROL_R3_OFFSET   4
74#define V850_CONTEXT_CONTROL_R20_OFFSET  8
75#define V850_CONTEXT_CONTROL_R21_OFFSET 12
76#define V850_CONTEXT_CONTROL_R22_OFFSET 16
77#define V850_CONTEXT_CONTROL_R23_OFFSET 20
78#define V850_CONTEXT_CONTROL_R24_OFFSET 24
79#define V850_CONTEXT_CONTROL_R25_OFFSET 28
80#define V850_CONTEXT_CONTROL_R26_OFFSET 32
81#define V850_CONTEXT_CONTROL_R27_OFFSET 36
82#define V850_CONTEXT_CONTROL_R28_OFFSET 40
83#define V850_CONTEXT_CONTROL_R29_OFFSET 44
84#define V850_CONTEXT_CONTROL_R31_OFFSET 48
85#define V850_CONTEXT_CONTROL_PSW_OFFSET 52
86
87        .section .text
88        .global  __CPU_Context_switch
89        .type    __CPU_Context_switch, @function
90__CPU_Context_switch:
91        st.w     r1,V850_CONTEXT_CONTROL_R1_OFFSET[r6]
92        st.w     r3,V850_CONTEXT_CONTROL_R3_OFFSET[r6]
93        st.w     r20,V850_CONTEXT_CONTROL_R20_OFFSET[r6]
94        st.w     r21,V850_CONTEXT_CONTROL_R21_OFFSET[r6]
95        st.w     r22,V850_CONTEXT_CONTROL_R22_OFFSET[r6]
96        st.w     r23,V850_CONTEXT_CONTROL_R23_OFFSET[r6]
97        st.w     r24,V850_CONTEXT_CONTROL_R24_OFFSET[r6]
98        st.w     r25,V850_CONTEXT_CONTROL_R25_OFFSET[r6]
99        st.w     r26,V850_CONTEXT_CONTROL_R27_OFFSET[r6]
100        st.w     r27,V850_CONTEXT_CONTROL_R27_OFFSET[r6]
101        st.w     r28,V850_CONTEXT_CONTROL_R28_OFFSET[r6]
102        st.w     r29,V850_CONTEXT_CONTROL_R29_OFFSET[r6]
103        st.w     r31,V850_CONTEXT_CONTROL_R31_OFFSET[r6]
104        stsr     psw,r21
105        st.w     r21,V850_CONTEXT_CONTROL_PSW_OFFSET[r6]
106restore:
107        ld.w     V850_CONTEXT_CONTROL_R1_OFFSET[r7],r1
108        ld.w     V850_CONTEXT_CONTROL_R3_OFFSET[r7],r3
109        ld.w     V850_CONTEXT_CONTROL_R20_OFFSET[r7],r20
110        ld.w     V850_CONTEXT_CONTROL_R21_OFFSET[r7],r21
111        ld.w     V850_CONTEXT_CONTROL_R22_OFFSET[r7],r22
112        ld.w     V850_CONTEXT_CONTROL_R23_OFFSET[r7],r23
113        ld.w     V850_CONTEXT_CONTROL_R24_OFFSET[r7],r24
114        ld.w     V850_CONTEXT_CONTROL_R25_OFFSET[r7],r25
115        ld.w     V850_CONTEXT_CONTROL_R27_OFFSET[r7],r26
116        ld.w     V850_CONTEXT_CONTROL_R27_OFFSET[r7],r27
117        ld.w     V850_CONTEXT_CONTROL_R28_OFFSET[r7],r28
118        ld.w     V850_CONTEXT_CONTROL_R29_OFFSET[r7],r29
119        ld.w     V850_CONTEXT_CONTROL_R31_OFFSET[r7],r31
120        ld.w     V850_CONTEXT_CONTROL_PSW_OFFSET[r7],r7
121        ldsr     r7,psw
122        jmp      [r31]
123
124
125/**
126 *  This routine is generally used only to restart self in an
127 *  efficient manner.  It may simply be a label in _CPU_Context_switch.
128 *
129 *  NOTE: May be unnecessary to reload some registers.
130 *
131 *  v850 Specific Information:
132 *
133 *  Move second parameter to first and jump to normal restore
134 */
135        .section .text
136        .global  __CPU_Context_restore
137        .type    __CPU_Context_restore, @function
138__CPU_Context_restore:
139        mov      r6, r7         /* move to second parameter register */
140        br       restore
Note: See TracBrowser for help on using the repository browser.