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