source: rtems/bsps/mips/csb350/start/start.S @ e9f15be

5
Last change on this file since e9f15be 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: 3.0 KB
Line 
1/*
2 * start.S -- startup file for Cogent CSB350 Au1100 based board
3 *
4 *  Copyright (c) 2005 by Cogent Computer Systems
5 *  Written by Jay Monkman <jtm@lopingdog.com>
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.org/license/LICENSE.
10 *
11 */
12
13#include <rtems/asm.h>
14#include <bsp/regs.h>
15
16        .text
17        .align  2
18
19/* Without the following nop, GDB thinks _start is a data variable.
20 * This is probably a bug in GDB in handling a symbol that is at the
21 * start of the .text section.
22 */
23        nop
24
25        .globl  _start
26        .ent    _start
27_start:
28        .set    noreorder
29
30        /* Get the address of start into $5 in a position independent
31         * fashion. This lets us know whether we have been relocated or not.
32         */
33        $LF1 = . + 8
34        bal     $LF1
35        nop
36_branch:
37        move    $5, $31                 /* $5 == where are we */
38        li      $6, 0x8800000c          /* $6 == where we want to be */
39
40        li      v0, SR_CU1|SR_PE|SR_FR|SR_KX|SR_SX|SR_UX
41        mtc0    v0, C0_SR
42        mtc0    zero, C0_CAUSE
43
441:
45        li      v0, SR_PE|SR_FR|SR_KX|SR_SX|SR_UX
46        mtc0    v0, C0_SR
472:
48/* Fix high bits, if any, of the PC so that exception handling
49   doesn't get confused.  */
50        la v0, 3f
51        jr      v0
52        nop
533:
54        la gp, _gp                      /* set the global data pointer */
55        .end _start
56
57/*
58 * zero out the bss section.
59 */
60        .globl  zerobss
61        .ent    zerobss
62zerobss:
63        la v0, _fbss
64        la v1, _end
653:
66        sw      zero,0(v0)
67        bltu    v0,v1,3b
68        addiu   v0,v0,4                 /* executed in delay slot */
69
70        la      t0, _Configuration_Interrupt_stack_area_end /* initialize stack so we */
71        /* We must subtract 24 bytes for the 3 8 byte arguments to main, in
72           case main wants to write them back to the stack.  The caller is
73           supposed to allocate stack space for parameters in registers in
74           the old MIPS ABIs.  We must do this even though we aren't passing
75           arguments, because main might be declared to have them.
76
77           Some ports need a larger alignment for the stack, so we subtract
78           32, which satisifes the stack for the arguments and keeps the
79           stack pointer better aligned.  */
80        subu    t0,t0,32
81        move    sp,t0                   /* set stack pointer */
82        .end    zerobss
83
84        .globl  exit .text
85        .globl  init
86        .ent    init
87init:
88
89        move    a0,zero                 /* set command line to 0 */
90        jal     boot_card               /* call the program start function */
91        nop
92
93        /* fall through to the "exit" routine */
94        jal     _sys_exit               /* call libc exit to run the G++ */
95                                        /* destructors */
96        move    a0,v0                   /* pass through the exit code */
97        .end    init
98
99/*
100 * _sys_exit -- Exit from the application. Normally we cause a user trap
101 *          to return to the ROM monitor for another run. NOTE: This is
102 *          the only other routine we provide in the crt0.o object, since
103 *          it may be tied to the "_start" routine. It also allows
104 *          executables that contain a complete world to be linked with
105 *          just the crt0.o object.
106 */
107        .globl  _sys_exit
108        .ent _sys_exit
109_sys_exit:
1107:
111#ifdef GCRT0
112        jal     _mcleanup
113        nop
114#endif
115        /* break inst. can cope with 0xfffff, but GAS limits the range: */
116        break   1023
117        nop
118        b       7b                      /* but loop back just in-case */
119        nop
120        .end _sys_exit
121
122/* EOF crt0.S */
Note: See TracBrowser for help on using the repository browser.