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

5
Last change on this file since 4191647 was 4191647, checked in by Cillian O'Donnell <cpodonnell8@…>, on 04/08/17 at 11:12:54

virtex4/startup/bspstart.c: Use %p to fix 11 warnings.

  • Property mode set to 100644
File size: 6.9 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
61#include <libcpu/cpuIdent.h>
62#include <libcpu/spr.h>
63
64#include <bsp.h>
65#include <bsp/vectors.h>
66#include <bsp/bootcard.h>
67#include <bsp/irq.h>
68
69#include <string.h>
70#include <fcntl.h>
71#include <inttypes.h>
72
73#define DO_DOWN_ALIGN(x,a) ((x) & ~((a)-1))
74
75#define DO_UP_ALIGN(x,a)   DO_DOWN_ALIGN(((x) + (a) - 1 ),a)
76
77#define CPU_DOWN_ALIGN(x)  DO_DOWN_ALIGN(x, CPU_ALIGNMENT)
78#define CPU_UP_ALIGN(x)    DO_UP_ALIGN(x, CPU_ALIGNMENT)
79
80
81/* Defined in linkcmds linker script */
82LINKER_SYMBOL(RamBase);
83LINKER_SYMBOL(RamSize);
84LINKER_SYMBOL(__bsp_ram_start);
85LINKER_SYMBOL(__bsp_ram_end);
86LINKER_SYMBOL(__rtems_end);
87LINKER_SYMBOL(_stack);
88LINKER_SYMBOL(StackSize);
89LINKER_SYMBOL(__stack_base);
90LINKER_SYMBOL(WorkAreaBase);
91LINKER_SYMBOL(MsgAreaBase);
92LINKER_SYMBOL(MsgAreaSize);
93LINKER_SYMBOL(__phy_ram_end);
94LINKER_SYMBOL(bsp_exc_vector_base);
95
96
97/* Expected by clock.c */
98uint32_t    bsp_clicks_per_usec;
99bool        bsp_timer_internal_clock;   /* true, when timer runs with CPU clk */
100uint32_t    bsp_timer_least_valid;
101uint32_t    bsp_timer_average_overhead;
102
103
104/*
105 * Provide weak aliases so that RTEMS distribution builds
106 */
107static void _noopfun(void) {}
108
109
110void app_bsp_start(void)
111__attribute__(( weak, alias("_noopfun") ));
112
113void app_bsp_predriver_hook(void)
114__attribute__(( weak, alias("_noopfun") ));
115
116
117static char* bspMsgBuffer = (char*)MsgAreaBase;
118
119static void __bsp_outchar_to_memory(char c)
120{
121  static char* msgBuffer = (char*)MsgAreaBase;
122  *msgBuffer++ = c;
123  if (msgBuffer >= &bspMsgBuffer[(int)MsgAreaSize])  msgBuffer = bspMsgBuffer;
124  *msgBuffer   = 0x00;                /* Overwrite next location to show EOM */
125}
126
127
128void BSP_ask_for_reset(void)
129{
130  printk("\nSystem stopped, issue RESET");
131
132  for(;;);
133}
134
135
136void BSP_panic(char *s)
137{
138  RTEMS_UNUSED rtems_interrupt_level level;
139
140  rtems_interrupt_disable(level);
141
142  printk("\n%s PANIC %s\n", rtems_get_version_string(), s);
143
144  BSP_ask_for_reset();
145}
146
147
148void _BSP_Fatal_error(unsigned int v)
149{
150  RTEMS_UNUSED rtems_interrupt_level level;
151
152  rtems_interrupt_disable(level);
153
154  printk("\n%s FATAL ERROR %x\n", rtems_get_version_string(), v);
155
156  BSP_ask_for_reset();
157}
158
159
160/*===================================================================*/
161
162/*
163 *  BSP start routine.  Called by boot_card().
164 *
165 *  This routine does the bulk of the system initialization.
166 */
167void bsp_start(void)
168{
169  uintptr_t          intrStackStart;
170  uintptr_t          intrStackSize;
171
172  ppc_cpu_id_t       myCpu;
173  ppc_cpu_revision_t myCpuRevision;
174
175  /* Set the character output function;  The application may override this */
176  BSP_output_char = __bsp_outchar_to_memory;
177
178  printk("RTEMS %s\n", rtems_get_version_string());
179
180  /*
181   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
182   * function stores the result in global variables so that it can be used later...
183   */
184  myCpu         = get_ppc_cpu_type();
185  myCpuRevision = get_ppc_cpu_revision();
186  printk("CPU: 0x%04x,  Revision: 0x%04x = %d,  Name: %s\n",
187         myCpu, myCpuRevision, myCpuRevision, get_ppc_cpu_type_name(myCpu));
188
189  /*
190   *  Initialize the device driver parameters
191   */
192
193  /* Timebase register ticks/microsecond;  The application may override these */
194  bsp_clicks_per_usec        = 350;
195  bsp_timer_internal_clock   = true;
196  bsp_timer_average_overhead = 2;
197  bsp_timer_least_valid      = 3;
198  rtems_counter_initialize_converter(bsp_clicks_per_usec * 1000000);
199
200  /*
201   * Initialize the interrupt related settings.
202   */
203  intrStackStart = CPU_UP_ALIGN((uint32_t)__bsp_ram_start);
204  intrStackSize  = rtems_configuration_get_interrupt_stack_size();
205
206  ppc_exc_initialize(intrStackStart, intrStackSize);
207
208  /* Let the user know what parameters we were compiled with */
209  printk("                  Base/Start     End         Size\n"
210         "RAM:              %p                    %p\n"
211         "RTEMS:                           %p\n"
212         "Interrupt Stack:  0x%08x              0x%x\n"
213         "Stack:            %p             %p          %p\n"
214         "Workspace:        %p             %p\n"
215         "MsgArea:          %p             %p\n"
216         "Physical RAM                     %p\n",
217         RamBase,        RamSize,
218         __rtems_end,
219         intrStackStart,                intrStackSize,
220         __stack_base,   _stack,        StackSize,
221         WorkAreaBase,   __bsp_ram_end,
222         MsgAreaBase,    MsgAreaSize,
223         __phy_ram_end);
224
225  /*
226   * Initialize RTEMS IRQ system
227   */
228  BSP_rtems_irq_mngt_init(0);
229
230  /* Continue with application-specific initialization */
231  app_bsp_start();
232}
233
234
235/*
236 *  BSP predriver hook.  Called by boot_card() just before drivers are
237 *  initialized.  Clear out any stale interrupts here.
238 */
239void bsp_predriver_hook(void)
240{
241  app_bsp_predriver_hook();
242}
Note: See TracBrowser for help on using the repository browser.