source: rtems/c/src/lib/libbsp/powerpc/virtex4/startup/bspstart.c @ 967278f

4.115
Last change on this file since 967278f was 967278f, checked in by Ric Claus <claus@…>, on 01/23/13 at 00:16:37

Fixed virtex4,5 BSP compile time warnings

  • Property mode set to 100644
File size: 7.5 KB
Line 
1/*  bsp_start()
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 *  INPUT:  NONE
9 *
10 *  OUTPUT: NONE
11 *
12 *  Author:     Thomas Doerfler <td@imd.m.isar.de>
13 *              IMD Ingenieurbuero fuer Microcomputertechnik
14 *
15 *  COPYRIGHT (c) 1998 by IMD
16 *
17 *  Changes from IMD are covered by the original distributions terms.
18 *  This file has been derived from the papyrus BSP:
19 *
20 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
21 *
22 *  COPYRIGHT (c) 1995 by i-cubed ltd.
23 *
24 *  To anyone who acknowledges that this file is provided "AS IS"
25 *  without any express or implied warranty:
26 *      permission to use, copy, modify, and distribute this file
27 *      for any purpose is hereby granted without fee, provided that
28 *      the above copyright notice and this notice appears in all
29 *      copies, and that the name of i-cubed limited not be used in
30 *      advertising or publicity pertaining to distribution of the
31 *      software without specific, written prior permission.
32 *      i-cubed limited makes no representations about the suitability
33 *      of this software for any purpose.
34 *
35 *  Modifications for spooling console driver and control of memory layout
36 *  with linker command file by
37 *              Thomas Doerfler <td@imd.m.isar.de>
38 *  for these modifications:
39 *  COPYRIGHT (c) 1997 by IMD, Puchheim, Germany.
40 *
41 *  To anyone who acknowledges that this file is provided "AS IS"
42 *  without any express or implied warranty:
43 *      permission to use, copy, modify, and distribute this file
44 *      for any purpose is hereby granted without fee, provided that
45 *      the above copyright notice and this notice appears in all
46 *      copies. IMD makes no representations about the suitability
47 *      of this software for any purpose.
48 *
49 *  Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c:
50 *
51 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
52 *  On-Line Applications Research Corporation (OAR).
53 *
54 *  Modifications for PPC405GP by Dennis Ehlin
55 *  Modifications for Virtex4 by Richard Claus <claus@slac.stanford.edu>
56 */
57#include <rtems.h>
58#include <rtems/config.h>
59#include <rtems/bspIo.h>
60#include <rtems/libio.h>
61#include <rtems/libcsupport.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
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;
100bool        bsp_timer_internal_clock;   /* true, when timer runs with CPU clk */
101uint32_t    bsp_timer_least_valid;
102uint32_t    bsp_timer_average_overhead;
103
104
105/*
106 * Provide weak aliases so that RTEMS distribution builds
107 */
108static void _noopfun(void) {}
109
110
111void app_bsp_start(void)
112__attribute__(( weak, alias("_noopfun") ));
113
114void app_bsp_pretasking_hook(void)
115__attribute__(( weak, alias("_noopfun") ));
116
117void app_bsp_predriver_hook(void)
118__attribute__(( weak, alias("_noopfun") ));
119
120
121static char* bspMsgBuffer = (char*)MsgAreaBase;
122
123static void __bsp_outchar_to_memory(char c)
124{
125  static char* msgBuffer = (char*)MsgAreaBase;
126  *msgBuffer++ = c;
127  if (msgBuffer >= &bspMsgBuffer[(int)MsgAreaSize])  msgBuffer = bspMsgBuffer;
128  *msgBuffer   = 0x00;                /* Overwrite next location to show EOM */
129}
130
131
132void BSP_ask_for_reset(void)
133{
134  printk("\nSystem stopped, issue RESET");
135
136  for(;;);
137}
138
139
140void BSP_panic(char *s)
141{
142  __attribute__((unused)) rtems_interrupt_level level;
143
144  rtems_interrupt_disable(level);
145
146  printk("\n%s PANIC %s\n", rtems_get_version_string(), s);
147
148  BSP_ask_for_reset();
149}
150
151
152void _BSP_Fatal_error(unsigned int v)
153{
154  __attribute__((unused)) rtems_interrupt_level level;
155
156  rtems_interrupt_disable(level);
157
158  printk("\n%s FATAL ERROR %x\n", rtems_get_version_string(), v);
159
160  BSP_ask_for_reset();
161}
162
163
164/*===================================================================*/
165
166/*
167 *  BSP start routine.  Called by boot_card().
168 *
169 *  This routine does the bulk of the system initialization.
170 */
171void bsp_start(void)
172{
173  uintptr_t          intrStackStart;
174  uintptr_t          intrStackSize;
175
176  ppc_cpu_id_t       myCpu;
177  ppc_cpu_revision_t myCpuRevision;
178
179  /* Set the character output function;  The application may override this */
180  BSP_output_char = __bsp_outchar_to_memory;
181
182  printk("RTEMS %s\n", rtems_get_version_string());
183
184  /*
185   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
186   * function stores the result in global variables so that it can be used later...
187   */
188  myCpu         = get_ppc_cpu_type();
189  myCpuRevision = get_ppc_cpu_revision();
190  printk("CPU: 0x%04x,  Revision: 0x%04x = %d,  Name: %s\n",
191         myCpu, myCpuRevision, myCpuRevision, get_ppc_cpu_type_name(myCpu));
192
193  /*
194   *  Initialize the device driver parameters
195   */
196
197  /* Timebase register ticks/microsecond;  The application may override these */
198  bsp_clicks_per_usec        = 350;
199  bsp_timer_internal_clock   = true;
200  bsp_timer_average_overhead = 2;
201  bsp_timer_least_valid      = 3;
202
203  /*
204   * Initialize the interrupt related settings.
205   */
206  intrStackStart = CPU_UP_ALIGN((uint32_t)__bsp_ram_start);
207  intrStackSize  = rtems_configuration_get_interrupt_stack_size();
208
209  ppc_exc_initialize(PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
210                     intrStackStart,
211                     intrStackSize);
212
213  /* Let the user know what parameters we were compiled with */
214  printk("                  Base/Start     End         Size\n"
215         "RAM:              0x%08x              0x%x\n"
216         "RTEMS:                        0x%08x\n"
217         "Interrupt Stack:  0x%08x              0x%x\n"
218         "Stack:            0x%08x  0x%08x  0x%x\n"
219         "Workspace:        0x%08x  0x%08x\n"
220         "MsgArea:          0x%08x              0x%x\n"
221         "Physical RAM                  0x%08x\n",
222         (uint32_t)RamBase,                               (uint32_t)RamSize,
223         (uint32_t)__rtems_end,
224         intrStackStart,                                  intrStackSize,
225         (uint32_t)__stack_base, (uint32_t)_stack,        (uint32_t)StackSize,
226         (uint32_t)WorkAreaBase, (uint32_t)__bsp_ram_end,
227         (uint32_t)MsgAreaBase,                           (uint32_t)MsgAreaSize,
228         (uint32_t)__phy_ram_end);
229
230  /*
231   * Initialize RTEMS IRQ system
232   */
233  BSP_rtems_irq_mngt_init(0);
234
235  /* Continue with application-specific initialization */
236  app_bsp_start();
237}
238
239
240/*
241 *  BSP pretasking hook.  Called just before drivers are initialized.
242 *  Used to setup libc and install any BSP extensions.
243 *
244 *  Must not use libc (to do io) from here, since drivers are not yet
245 *  initialized.
246 */
247
248void bsp_pretasking_hook(void)
249{
250  app_bsp_pretasking_hook();
251}
252
253
254/*
255 *  BSP predriver hook.  Called by boot_card() just before drivers are
256 *  initialized.  Clear out any stale interrupts here.
257 */
258void bsp_predriver_hook(void)
259{
260  app_bsp_predriver_hook();
261}
Note: See TracBrowser for help on using the repository browser.