source: rtems/cpukit/score/cpu/no_cpu/cpu_asm.c @ 511dc4b

5
Last change on this file since 511dc4b 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: 5.1 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief No CPU Assembly File
5 */
6
7/*  cpu_asm.c  ===> cpu_asm.S or cpu_asm.s
8 *
9 *  This file contains the basic algorithms for all assembly code used
10 *  in an specific CPU port of RTEMS.  These algorithms must be implemented
11 *  in assembly language
12 *
13 *  NOTE:  This is supposed to be a .S or .s file NOT a C file.
14 *
15 *  COPYRIGHT (c) 1989-1999.
16 *  On-Line Applications Research Corporation (OAR).
17 *
18 *  The license and distribution terms for this file may be
19 *  found in the file LICENSE in this distribution or at
20 *  http://www.rtems.org/license/LICENSE.
21 */
22
23/*
24 *  This is supposed to be an assembly file.  This means that system.h
25 *  and cpu.h should not be included in a "real" cpu_asm file.  An
26 *  implementation in assembly should include "cpu_asm.h>
27 */
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include <rtems/system.h>
34#include <rtems/score/cpu.h>
35/* #include "cpu_asm.h> */
36
37/*
38 *  _CPU_Context_save_fp_context
39 *
40 *  This routine is responsible for saving the FP context
41 *  at *fp_context_ptr.  If the point to load the FP context
42 *  from is changed then the pointer is modified by this routine.
43 *
44 *  Sometimes a macro implementation of this is in cpu.h which dereferences
45 *  the ** and a similarly named routine in this file is passed something
46 *  like a (Context_Control_fp *).  The general rule on making this decision
47 *  is to avoid writing assembly language.
48 *
49 *  NO_CPU Specific Information:
50 *
51 *  XXX document implementation including references if appropriate
52 */
53
54void _CPU_Context_save_fp(
55  Context_Control_fp **fp_context_ptr
56)
57{
58}
59
60/*
61 *  _CPU_Context_restore_fp_context
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 *  NO_CPU Specific Information:
73 *
74 *  XXX document implementation including references if appropriate
75 */
76
77void _CPU_Context_restore_fp(
78  Context_Control_fp **fp_context_ptr
79)
80{
81}
82
83/*  _CPU_Context_switch
84 *
85 *  This routine performs a normal non-FP context switch.
86 *
87 *  NO_CPU Specific Information:
88 *
89 *  XXX document implementation including references if appropriate
90 */
91
92void _CPU_Context_switch(
93  Context_Control  *run,
94  Context_Control  *heir
95)
96{
97}
98
99/*
100 *  _CPU_Context_restore
101 *
102 *  This routine is generally used only to restart self in an
103 *  efficient manner.  It may simply be a label in _CPU_Context_switch.
104 *
105 *  NOTE: May be unnecessary to reload some registers.
106 *
107 *  NO_CPU Specific Information:
108 *
109 *  XXX document implementation including references if appropriate
110 */
111
112void _CPU_Context_restore(
113  Context_Control *new_context
114)
115{
116}
117
118/*  void __ISR_Handler()
119 *
120 *  This routine provides the RTEMS interrupt management.
121 *
122 *  NO_CPU Specific Information:
123 *
124 *  XXX document implementation including references if appropriate
125 */
126
127void _ISR_Handler(void)
128{
129   /*
130    *  This discussion ignores a lot of the ugly details in a real
131    *  implementation such as saving enough registers/state to be
132    *  able to do something real.  Keep in mind that the goal is
133    *  to invoke a user's ISR handler which is written in C and
134    *  uses a certain set of registers.
135    *
136    *  Also note that the exact order is to a large extent flexible.
137    *  Hardware will dictate a sequence for a certain subset of
138    *  _ISR_Handler while requirements for setting
139    */
140
141  /*
142   *  At entry to "common" _ISR_Handler, the vector number must be
143   *  available.  On some CPUs the hardware puts either the vector
144   *  number or the offset into the vector table for this ISR in a
145   *  known place.  If the hardware does not give us this information,
146   *  then the assembly portion of RTEMS for this port will contain
147   *  a set of distinct interrupt entry points which somehow place
148   *  the vector number in a known place (which is safe if another
149   *  interrupt nests this one) and branches to _ISR_Handler.
150   *
151   *  save some or all context on stack
152   *  may need to save some special interrupt information for exit
153   *
154   *  if ( _ISR_Nest_level == 0 )
155   *    switch to software interrupt stack
156   *
157   *  _ISR_Nest_level++;
158   *
159   *  _Thread_Dispatch_disable_level++;
160   *
161   *  (*_ISR_Vector_table[ vector ])( vector );
162   *
163   *  _Thread_Dispatch_disable_level--;
164   *
165   *  --_ISR_Nest_level;
166   *
167   *  if ( _ISR_Nest_level )
168   *    goto the label "exit interrupt (simple case)"
169   *
170   *  if ( _Thread_Dispatch_disable_level )
171   *    goto the label "exit interrupt (simple case)"
172   *
173   *  if ( _Thread_Dispatch_necessary ) {
174   *    call _Thread_Dispatch() or prepare to return to _ISR_Dispatch
175   *    prepare to get out of interrupt
176   *    return from interrupt  (maybe to _ISR_Dispatch)
177   *
178   *  LABEL "exit interrupt (simple case):
179   *  if outermost interrupt
180   *    restore stack
181   *  prepare to get out of interrupt
182   *  return from interrupt
183   */
184}
Note: See TracBrowser for help on using the repository browser.