source: rtems/bsps/powerpc/virtex4/start/bspstart.c @ 8f8ccee

5
Last change on this file since 8f8ccee was 9964895, checked in by Sebastian Huber <sebastian.huber@…>, on 04/20/18 at 08:35:35

bsps: Move startup files to bsps

Adjust build support files to new directory layout.

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 6.4 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(_stack);
89LINKER_SYMBOL(StackSize);
90LINKER_SYMBOL(__stack_base);
91LINKER_SYMBOL(WorkAreaBase);
92LINKER_SYMBOL(MsgAreaBase);
93LINKER_SYMBOL(MsgAreaSize);
94LINKER_SYMBOL(__phy_ram_end);
95LINKER_SYMBOL(bsp_exc_vector_base);
96
97
98/* Expected by clock.c */
99uint32_t    bsp_clicks_per_usec;
100
101
102/*
103 * Provide weak aliases so that RTEMS distribution builds
104 */
105static void _noopfun(void) {}
106
107
108void app_bsp_start(void)
109__attribute__(( weak, alias("_noopfun") ));
110
111void app_bsp_predriver_hook(void)
112__attribute__(( weak, alias("_noopfun") ));
113
114
115static char* bspMsgBuffer = (char*)MsgAreaBase;
116
117static void __bsp_outchar_to_memory(char c)
118{
119  static char* msgBuffer = (char*)MsgAreaBase;
120  *msgBuffer++ = c;
121  if (msgBuffer >= &bspMsgBuffer[(int)MsgAreaSize])  msgBuffer = bspMsgBuffer;
122  *msgBuffer   = 0x00;                /* Overwrite next location to show EOM */
123}
124
125
126void BSP_ask_for_reset(void)
127{
128  printk("\nSystem stopped, issue RESET");
129
130  for(;;);
131}
132
133
134/*===================================================================*/
135
136/*
137 *  BSP start routine.  Called by boot_card().
138 *
139 *  This routine does the bulk of the system initialization.
140 */
141void bsp_start(void)
142{
143  uintptr_t          intrStackStart;
144  uintptr_t          intrStackSize;
145
146  ppc_cpu_id_t       myCpu;
147  ppc_cpu_revision_t myCpuRevision;
148
149  /* Set the character output function;  The application may override this */
150  BSP_output_char = __bsp_outchar_to_memory;
151
152  printk("RTEMS %s\n", rtems_get_version_string());
153
154  /*
155   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
156   * function stores the result in global variables so that it can be used later...
157   */
158  myCpu         = get_ppc_cpu_type();
159  myCpuRevision = get_ppc_cpu_revision();
160  printk("CPU: 0x%04x,  Revision: 0x%04x = %d,  Name: %s\n",
161         myCpu, myCpuRevision, myCpuRevision, get_ppc_cpu_type_name(myCpu));
162
163  /*
164   *  Initialize the device driver parameters
165   */
166
167  /* Timebase register ticks/microsecond;  The application may override these */
168  bsp_clicks_per_usec        = 350;
169  rtems_counter_initialize_converter(bsp_clicks_per_usec * 1000000);
170
171  /*
172   * Initialize the interrupt related settings.
173   */
174  intrStackStart = CPU_UP_ALIGN((uint32_t)__bsp_ram_start);
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         "Stack:            %p             %p          %p\n"
185         "Workspace:        %p             %p\n"
186         "MsgArea:          %p             %p\n"
187         "Physical RAM                     %p\n",
188         RamBase,        RamSize,
189         __rtems_end,
190         intrStackStart,                intrStackSize,
191         __stack_base,   _stack,        StackSize,
192         WorkAreaBase,   __bsp_ram_end,
193         MsgAreaBase,    MsgAreaSize,
194         __phy_ram_end);
195
196  /*
197   * Initialize RTEMS IRQ system
198   */
199  BSP_rtems_irq_mngt_init(0);
200
201  /* Continue with application-specific initialization */
202  app_bsp_start();
203}
204
205
206/*
207 *  BSP predriver hook.  Called by boot_card() just before drivers are
208 *  initialized.  Clear out any stale interrupts here.
209 */
210static void virtex4_pre_driver_hook(void)
211{
212  app_bsp_predriver_hook();
213}
214
215RTEMS_SYSINIT_ITEM(
216  virtex4_pre_driver_hook,
217  RTEMS_SYSINIT_BSP_PRE_DRIVERS,
218  RTEMS_SYSINIT_ORDER_MIDDLE
219);
Note: See TracBrowser for help on using the repository browser.