source: rtems/bsps/powerpc/virtex4/start/bspstart.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: 6.3 KB
Line 
1/*
2 *  This routine starts the application.  It includes application,
3 *  board, and monitor specific initialization and configuration.
4 *  The generic CPU dependent initialization has been performed
5 *  before this routine is invoked.
6 */
7
8/*
9 *  Author:     Thomas Doerfler <td@imd.m.isar.de>
10 *              IMD Ingenieurbuero fuer Microcomputertechnik
11 *
12 *  COPYRIGHT (c) 1998 by IMD
13 *
14 *  Changes from IMD are covered by the original distributions terms.
15 *  This file has been derived from the papyrus BSP:
16 *
17 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
18 *
19 *  COPYRIGHT (c) 1995 by i-cubed ltd.
20 *
21 *  To anyone who acknowledges that this file is provided "AS IS"
22 *  without any express or implied warranty:
23 *      permission to use, copy, modify, and distribute this file
24 *      for any purpose is hereby granted without fee, provided that
25 *      the above copyright notice and this notice appears in all
26 *      copies, and that the name of i-cubed limited not be used in
27 *      advertising or publicity pertaining to distribution of the
28 *      software without specific, written prior permission.
29 *      i-cubed limited makes no representations about the suitability
30 *      of this software for any purpose.
31 *
32 *  Modifications for spooling console driver and control of memory layout
33 *  with linker command file by
34 *              Thomas Doerfler <td@imd.m.isar.de>
35 *  for these modifications:
36 *  COPYRIGHT (c) 1997 by IMD, Puchheim, Germany.
37 *
38 *  To anyone who acknowledges that this file is provided "AS IS"
39 *  without any express or implied warranty:
40 *      permission to use, copy, modify, and distribute this file
41 *      for any purpose is hereby granted without fee, provided that
42 *      the above copyright notice and this notice appears in all
43 *      copies. IMD makes no representations about the suitability
44 *      of this software for any purpose.
45 *
46 *  Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c:
47 *
48 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
49 *  On-Line Applications Research Corporation (OAR).
50 *
51 *  Modifications for PPC405GP by Dennis Ehlin
52 *  Modifications for Virtex4 by Richard Claus <claus@slac.stanford.edu>
53 */
54#include <rtems.h>
55#include <rtems/config.h>
56#include <rtems/bspIo.h>
57#include <rtems/counter.h>
58#include <rtems/libio.h>
59#include <rtems/libcsupport.h>
60#include <rtems/sysinit.h>
61
62#include <libcpu/cpuIdent.h>
63#include <libcpu/spr.h>
64
65#include <bsp.h>
66#include <bsp/vectors.h>
67#include <bsp/bootcard.h>
68#include <bsp/irq.h>
69
70#include <string.h>
71#include <fcntl.h>
72#include <inttypes.h>
73
74#define DO_DOWN_ALIGN(x,a) ((x) & ~((a)-1))
75
76#define DO_UP_ALIGN(x,a)   DO_DOWN_ALIGN(((x) + (a) - 1 ),a)
77
78#define CPU_DOWN_ALIGN(x)  DO_DOWN_ALIGN(x, CPU_ALIGNMENT)
79#define CPU_UP_ALIGN(x)    DO_UP_ALIGN(x, CPU_ALIGNMENT)
80
81
82/* Defined in linkcmds linker script */
83LINKER_SYMBOL(RamBase);
84LINKER_SYMBOL(RamSize);
85LINKER_SYMBOL(__bsp_ram_start);
86LINKER_SYMBOL(__bsp_ram_end);
87LINKER_SYMBOL(__rtems_end);
88LINKER_SYMBOL(WorkAreaBase);
89LINKER_SYMBOL(MsgAreaBase);
90LINKER_SYMBOL(MsgAreaSize);
91LINKER_SYMBOL(__phy_ram_end);
92LINKER_SYMBOL(bsp_exc_vector_base);
93
94
95/* Expected by clock.c */
96uint32_t    bsp_clicks_per_usec;
97
98
99/*
100 * Provide weak aliases so that RTEMS distribution builds
101 */
102static void _noopfun(void) {}
103
104
105void app_bsp_start(void)
106__attribute__(( weak, alias("_noopfun") ));
107
108void app_bsp_predriver_hook(void)
109__attribute__(( weak, alias("_noopfun") ));
110
111
112static char* bspMsgBuffer = (char*)MsgAreaBase;
113
114static void __bsp_outchar_to_memory(char c)
115{
116  static char* msgBuffer = (char*)MsgAreaBase;
117  *msgBuffer++ = c;
118  if (msgBuffer >= &bspMsgBuffer[(int)MsgAreaSize])  msgBuffer = bspMsgBuffer;
119  *msgBuffer   = 0x00;                /* Overwrite next location to show EOM */
120}
121
122
123void BSP_ask_for_reset(void)
124{
125  printk("\nSystem stopped, issue RESET");
126
127  for(;;);
128}
129
130uint32_t _CPU_Counter_frequency(void)
131{
132  return bsp_clicks_per_usec * 1000000;
133}
134
135/*===================================================================*/
136
137/*
138 *  BSP start routine.  Called by boot_card().
139 *
140 *  This routine does the bulk of the system initialization.
141 */
142void bsp_start(void)
143{
144  uintptr_t          intrStackStart;
145  uintptr_t          intrStackSize;
146
147  ppc_cpu_id_t       myCpu;
148  ppc_cpu_revision_t myCpuRevision;
149
150  /* Set the character output function;  The application may override this */
151  BSP_output_char = __bsp_outchar_to_memory;
152
153  printk("RTEMS %s\n", rtems_get_version_string());
154
155  /*
156   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
157   * function stores the result in global variables so that it can be used later...
158   */
159  myCpu         = get_ppc_cpu_type();
160  myCpuRevision = get_ppc_cpu_revision();
161  printk("CPU: 0x%04x,  Revision: 0x%04x = %d,  Name: %s\n",
162         myCpu, myCpuRevision, myCpuRevision, get_ppc_cpu_type_name(myCpu));
163
164  /*
165   *  Initialize the device driver parameters
166   */
167
168  /* Timebase register ticks/microsecond;  The application may override these */
169  bsp_clicks_per_usec        = 350;
170
171  /*
172   * Initialize the interrupt related settings.
173   */
174  intrStackStart = (uintptr_t) _Configuration_Interrupt_stack_area_begin;
175  intrStackSize  = rtems_configuration_get_interrupt_stack_size();
176
177  ppc_exc_initialize(intrStackStart, intrStackSize);
178
179  /* Let the user know what parameters we were compiled with */
180  printk("                  Base/Start     End         Size\n"
181         "RAM:              %p                    %p\n"
182         "RTEMS:                           %p\n"
183         "Interrupt Stack:  0x%08x              0x%x\n"
184         "Workspace:        %p             %p\n"
185         "MsgArea:          %p             %p\n"
186         "Physical RAM                     %p\n",
187         RamBase,        RamSize,
188         __rtems_end,
189         intrStackStart,                intrStackSize,
190         WorkAreaBase,   __bsp_ram_end,
191         MsgAreaBase,    MsgAreaSize,
192         __phy_ram_end);
193
194  /*
195   * Initialize RTEMS IRQ system
196   */
197  BSP_rtems_irq_mngt_init(0);
198
199  /* Continue with application-specific initialization */
200  app_bsp_start();
201}
202
203
204/*
205 *  BSP predriver hook.  Called by boot_card() just before drivers are
206 *  initialized.  Clear out any stale interrupts here.
207 */
208static void virtex4_pre_driver_hook(void)
209{
210  app_bsp_predriver_hook();
211}
212
213RTEMS_SYSINIT_ITEM(
214  virtex4_pre_driver_hook,
215  RTEMS_SYSINIT_BSP_PRE_DRIVERS,
216  RTEMS_SYSINIT_ORDER_MIDDLE
217);
Note: See TracBrowser for help on using the repository browser.