source: rtems/bsps/powerpc/psim/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: 3.4 KB
Line 
1/*
2 * This is based on the mvme-crt0.S file from libgloss/rs6000.
3 * crt0.S -- startup file for PowerPC systems.
4 *
5 * Copyright (c) 1995 Cygnus Support
6 *
7 * The authors hereby grant permission to use, copy, modify, distribute,
8 * and license this software and its documentation for any purpose, provided
9 * that existing copyright notices are retained in all copies and that this
10 * notice is included verbatim in any distributions. No written agreement,
11 * license, or royalty fee is required for any of the authorized uses.
12 * Modifications to this software may be copyrighted by their authors
13 * and need not follow the licensing terms described here, provided that
14 * the new terms are clearly indicated on the first page of each file where
15 * they apply.
16 */
17
18#include <rtems/asm.h>
19#include <rtems/score/cpu.h>
20#include <libcpu/io.h>
21#include "ppc-asm.h"
22
23        .section ".got2","aw"
24        .align  2
25
26.LCTOC1 = .+32768
27
28        .extern FUNC_NAME(atexit)
29        .globl  FUNC_NAME(__atexit)
30        .section ".sdata","aw"
31        .align  2
32FUNC_NAME(__atexit):                    /* tell C's eabi-ctor's we have an atexit function */
33        .long   FUNC_NAME(atexit)@fixup /* and that it is to register __do_global_dtors */
34
35        .section ".fixup","aw"
36        .align  2
37        .long   FUNC_NAME(__atexit)
38
39        .section ".got2","aw"
40.Ltable = .-.LCTOC1
41        .long   .LCTOC1                 /* address we think .LCTOC1 is loaded at */
42
43.Lbss_start = .-.LCTOC1
44        .long   bsp_section_sbss_begin
45
46.Lend = .-.LCTOC1
47        .long   bsp_section_bss_end
48
49.Lstack = .-.LCTOC1                     /* stack address if set by user */
50        .long   _Configuration_Interrupt_stack_area_end
51
52        .text
53.Lptr:
54        .long .LCTOC1-.Laddr
55
56        .globl  __rtems_entry_point
57        .type   __rtems_entry_point,@function
58__rtems_entry_point:
59#if 1
60        .globl  _start
61        .type   _start,@function
62_start:
63#endif
64        bl      .Laddr                  /* get current address */
65.Laddr:
66        mflr    r4                      /* real address of .Laddr */
67        lwz     r5,(.Lptr-.Laddr)(r4)   /* linker generated address of .LCTOC1 */
68        add     r5,r5,r4                /* correct to real pointer */
69        lwz     r4,.Ltable(r5)          /* get linker's idea of where .Laddr is */
70        subf    r4,r4,r5                /* calculate difference between where linked and current */
71
72        /* clear bss */
73        lwz     r6,.Lbss_start(r5)      /* calculate beginning of the BSS */
74        lwz     r7,.Lend(r5)            /* calculate end of the BSS */
75        add     r6,r6,r4                /* adjust pointers */
76        add     r7,r7,r4
77
78        cmplw   1,r6,r7
79        bc      4,4,.Ldone
80
81        subf    r8,r6,r7                /* number of bytes to zero */
82        srwi    r9,r8,2                 /* number of words to zero */
83        mtctr   r9
84        li      r0,0                    /* zero to clear memory */
85        addi    r6,r6,-4                /* adjust so we can use stwu */
86.Lloop:
87        stwu    r0,4(r6)                /* zero bss */
88        bdnz    .Lloop
89
90.Ldone:
91
92        lwz     r0,.Lstack(r5)  /* stack area or 0 */
93        cmplwi  1,r0,0                  /* equal to 0? */
94        bc      12,6,.Lnostack          /* use default stack if == 0 */
95        mr      sp,r0                   /* use user defined stack */
96
97.Lnostack:
98#ifdef __ALTIVEC__
99        /* enable altivec; this requires the ALTIVEC user
100         * extension to be installed in the user extension
101         * slot 0!
102         */
103        mfmsr r0
104        oris  r0, r0, (1<<(31-16-6))
105        mtmsr r0
106        isync
107        /*
108         * set vscr and vrsave to known values
109         */
110        li    r0, 0
111        mtvrsave r0
112        vxor   0,0,0
113        mtvscr 0
114#endif
115        /* set up initial stack frame */
116        addi    sp,sp,-4                /* make sure we don't overwrite debug mem */
117        /* align */
118        li  r3, CPU_STACK_ALIGNMENT-1
119        andc    sp, sp, r3
120        lis     r0,0
121        stw     r0,0(sp)                /* clear back chain */
122        stwu    sp,-CPU_STACK_ALIGNMENT(sp)             /* push another stack frame */
123        bl  FUNC_NAME(__eabi)
124
125        /* Let her rip */
126        li      r3, 0                   /* command line */
127        bl      FUNC_NAME(boot_card)
128
129       .globl  FUNC_NAME(bsp_reset)
130FUNC_NAME(bsp_reset):
131        li  10,99                       /* 0x63 */
132        sc
133
134.Lstart:
135        .size   _start,.Lstart-_start
Note: See TracBrowser for help on using the repository browser.