source: rtems/cpukit/score/src/percpuasm.c

Last change on this file was 511dc4b, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 19, 2018 at 7:09:51 AM

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: 3.0 KB
Line 
1/*
2 * Copyright (c) 2012, 2016 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/score/cpu.h>
20
21#define _RTEMS_PERCPU_DEFINE_OFFSETS
22#include <rtems/score/percpu.h>
23
24/*
25 * In case a CPU port needs another alignment, then add this here and make sure
26 * it is a power of two greater than or equal to two.
27 */
28RTEMS_STATIC_ASSERT(
29  CPU_ALIGNMENT == 2
30    || CPU_ALIGNMENT == 4
31    || CPU_ALIGNMENT == 8
32    || CPU_ALIGNMENT == 16
33    || CPU_ALIGNMENT == 32,
34  CPU_ALIGNMENT
35);
36
37/*
38 * In case a CPU port needs another heap alignment, then add this here and make
39 * sure it is a power of two greater than or equal to two.
40 */
41RTEMS_STATIC_ASSERT(
42  CPU_HEAP_ALIGNMENT == 2
43    || CPU_HEAP_ALIGNMENT == 4
44    || CPU_HEAP_ALIGNMENT == 8
45    || CPU_HEAP_ALIGNMENT == 16
46    || CPU_HEAP_ALIGNMENT == 32,
47  CPU_HEAP_ALIGNMENT_0
48);
49
50RTEMS_STATIC_ASSERT(
51  CPU_HEAP_ALIGNMENT >= CPU_ALIGNMENT,
52  CPU_HEAP_ALIGNMENT_1
53);
54
55RTEMS_STATIC_ASSERT(
56  sizeof(void *) == CPU_SIZEOF_POINTER,
57  CPU_SIZEOF_POINTER
58);
59
60#if defined( __SIZEOF_POINTER__ )
61  RTEMS_STATIC_ASSERT(
62    CPU_SIZEOF_POINTER == __SIZEOF_POINTER__,
63    __SIZEOF_POINTER__
64  );
65#endif
66
67#if CPU_PER_CPU_CONTROL_SIZE > 0
68  RTEMS_STATIC_ASSERT(
69    sizeof( CPU_Per_CPU_control ) == CPU_PER_CPU_CONTROL_SIZE,
70    CPU_PER_CPU_CONTROL_SIZE
71  );
72#endif
73
74#if defined( RTEMS_SMP )
75  RTEMS_STATIC_ASSERT(
76    sizeof( Per_CPU_Control_envelope ) == PER_CPU_CONTROL_SIZE,
77    PER_CPU_CONTROL_SIZE
78  );
79#endif
80
81RTEMS_STATIC_ASSERT(
82  offsetof(Per_CPU_Control, isr_nest_level) == PER_CPU_ISR_NEST_LEVEL,
83  PER_CPU_ISR_NEST_LEVEL
84);
85
86RTEMS_STATIC_ASSERT(
87  offsetof(Per_CPU_Control, isr_dispatch_disable)
88    == PER_CPU_ISR_DISPATCH_DISABLE,
89  PER_CPU_ISR_DISPATCH_DISABLE
90);
91
92RTEMS_STATIC_ASSERT(
93  offsetof(Per_CPU_Control, thread_dispatch_disable_level)
94    == PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL,
95  PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL
96);
97
98RTEMS_STATIC_ASSERT(
99  offsetof(Per_CPU_Control, executing) == PER_CPU_OFFSET_EXECUTING,
100  PER_CPU_OFFSET_EXECUTING
101);
102
103RTEMS_STATIC_ASSERT(
104  offsetof(Per_CPU_Control, heir) == PER_CPU_OFFSET_HEIR,
105  PER_CPU_OFFSET_HEIR
106);
107
108RTEMS_STATIC_ASSERT(
109  offsetof(Per_CPU_Control, dispatch_necessary) == PER_CPU_DISPATCH_NEEDED,
110  PER_CPU_DISPATCH_NEEDED
111);
112
113#if defined(RTEMS_SMP)
114RTEMS_STATIC_ASSERT(
115  offsetof(Per_CPU_Control, Interrupt_frame) == PER_CPU_INTERRUPT_FRAME_AREA,
116  PER_CPU_INTERRUPT_FRAME_AREA
117);
118
119RTEMS_STATIC_ASSERT(
120  sizeof( CPU_Interrupt_frame ) == CPU_INTERRUPT_FRAME_SIZE,
121  CPU_INTERRUPT_FRAME_SIZE
122);
123#endif
124
125RTEMS_STATIC_ASSERT(
126  offsetof(Per_CPU_Control, interrupt_stack_low)
127    == PER_CPU_INTERRUPT_STACK_LOW,
128  PER_CPU_INTERRUPT_STACK_LOW
129);
130
131RTEMS_STATIC_ASSERT(
132  offsetof(Per_CPU_Control, interrupt_stack_high)
133    == PER_CPU_INTERRUPT_STACK_HIGH,
134  PER_CPU_INTERRUPT_STACK_HIGH
135);
Note: See TracBrowser for help on using the repository browser.