source: rtems/bsps/m32c/m32cbsp/start/start.S @ 511dc4b

Last change on this file since 511dc4b 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: 4.1 KB
Line 
1/*
2
3Copyright (c) 2005 Red Hat Incorporated.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9    Redistributions of source code must retain the above copyright
10    notice, this list of conditions and the following disclaimer.
11
12    Redistributions in binary form must reproduce the above copyright
13    notice, this list of conditions and the following disclaimer in the
14    documentation and/or other materials provided with the distribution.
15
16    The name of Red Hat Incorporated may not be used to endorse
17    or promote products derived from this software without specific
18    prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23DISCLAIMED.  IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
24DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31*/
32
33#if defined(__r8c_cpu__) || defined(__m16c_cpu__)
34#define A16
35#define A(n,w) n
36#define W w
37#define ALIGN 1
38#else
39#define A24
40#define A(n,w) w
41#define W l
42#define ALIGN 2
43#endif
44
45        .text
46
47        .global _start
48_start:
49.LFB2:
50        fset    U       /* User stack */
51        ldc     #__Configuration_Interrupt_stack_area_end,sp
52
53#ifdef A16
54        mov.b   #%hi8(__romdatastart),r1h
55        mov.w   #%lo16(__romdatastart),a0
56        mov.w   #__datastart,a1
57#else
58        mov.l   #__romdatastart,a0
59        mov.l   #__datastart,a1
60#endif
61        mov.w   #__romdatacopysize,r3
62        shl.w   #-1,r3
63        smovf.w
64
65#ifdef A16
66        mov.w   #__bssstart,a1
67#else
68        mov.l   #__bssstart,a1
69#endif
70        mov.w   #__bsssize,r3
71        shl.w   #-1,r3
72        mov.w   #0,r0
73        sstr.w
74
75        /* jsr.a        __m32c_init */
76
77        jsr.a   _boot_card
78.LFE2:
79
80#ifdef A24
81        /* rv in r0, ok for arg0 */
82#else
83        mov.w   r0,r1
84#endif
85
86        .global _bsp_reset
87_bsp_reset:
88        jsr.a   _sys_exit
89
90        .text
91
92        .global _m32c_run_preinit_array
93        .type   _m32c_run_preinit_array,@function
94_m32c_run_preinit_array:
95        mov.W   #__preinit_array_start,a0
96        mov.W   #__preinit_array_end,a1
97        jmp.w   _m32c_run_inilist
98
99        .global _m32c_run_init_array
100        .type   _m32c_run_init_array,@function
101_m32c_run_init_array:
102        mov.W   #__init_array_start,a0
103        mov.W   #__init_array_end,a1
104        jmp.w   _m32c_run_inilist
105
106        .global _m32c_run_fini_array
107        .type   _m32c_run_fini_array,@function
108_m32c_run_fini_array:
109        mov.W   #__fini_array_start,a0
110        mov.W   #__fini_array_end,a1
111        /* fall through */
112
113_m32c_run_inilist:
114next_inilist:
115        cmp.W   a0,a1
116        jeq     done_inilist
117        pushm   a0,a1
118        mov.W   [a0],a0
119#ifdef A16
120        mov.b:s #0,a1   /* zero extends */
121        jsri.a  a1a0
122#else
123        jsri.a  a0
124#endif
125        popm    a0,a1
126        add.W   A(#2,#4),a0
127        jmp.b   next_inilist
128done_inilist:
129        rts
130
131        .section        .init,"ax",@progbits
132
133        .global __init
134        .global __m32c_init
135__init:
136__m32c_init:
137        enter   #0
138        exitd
139
140        .section        .fini,"ax",@progbits
141
142        .global __fini
143        .global __m32c_fini
144__fini:
145__m32c_fini:
146        enter   #0
147        jsr.a   _m32c_run_fini_array
148        exitd
149
150
151;;; Provide Dwarf unwinding information that will help GDB stop
152;;; backtraces at the right place.  This is stolen from assembly
153;;; code generated by GCC with -dA.
154        .section        .debug_frame,"",@progbits
155.Lframe0:
156        .4byte  .LECIE0-.LSCIE0 ; Length of Common Information Entry
157.LSCIE0:
158        .4byte  0xffffffff      ; CIE Identifier Tag
159        .byte   0x1     ; CIE Version
160        .ascii "\0"     ; CIE Augmentation
161        .uleb128 0x1    ; CIE Code Alignment Factor
162        .sleb128 -1     ; CIE Data Alignment Factor
163        .byte   0xd     ; CIE RA Column
164        .byte   0xc     ; DW_CFA_def_cfa
165        .uleb128 0xc
166        .uleb128 0x3
167        .byte   0x8d    ; DW_CFA_offset, column 0xd
168        .uleb128 0x3
169        .p2align ALIGN
170.LECIE0:
171.LSFDE0:
172        .4byte  .LEFDE0-.LASFDE0        ; FDE Length
173.LASFDE0:
174        .4byte  .Lframe0        ; FDE CIE offset
175        .4byte  .LFB2           ; FDE initial location
176        .4byte  .LFE2-.LFB2     ; FDE address range
177        .byte   0xf             ; DW_CFA_def_cfa_expression
178        .uleb128 1              ; length of expression
179        .byte   0x30            ; DW_OP_lit0
180        .p2align ALIGN
181.LEFDE0:
182
183        .text
Note: See TracBrowser for help on using the repository browser.