source: rtems/c/src/lib/libbsp/powerpc/virtex5/startup/bspstart.c @ bb22a3f3

5
Last change on this file since bb22a3f3 was bb22a3f3, checked in by Sebastian Huber <sebastian.huber@…>, on 03/21/18 at 05:27:24

bsp/powerpc: Move libcpu timer to bsps

Use only one timer driver variant based on the standard PowerPC time
base.

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 6.8 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
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 * Bus Frequency
103 */
104unsigned int BSP_bus_frequency;
105/*
106 * processor clock frequency
107 */
108unsigned int BSP_processor_frequency;
109
110/*
111 * Time base divisior (bus freq / TB clock)
112 */
113unsigned int BSP_time_base_divisor;
114
115/*
116 * Provide weak aliases so that RTEMS distribution builds
117 */
118static void _noopfun(void) {}
119
120
121void app_bsp_start(void)
122__attribute__(( weak, alias("_noopfun") ));
123
124void app_bsp_predriver_hook(void)
125__attribute__(( weak, alias("_noopfun") ));
126
127
128static char* bspMsgBuffer = (char*)MsgAreaBase;
129
130static void __bsp_outchar_to_memory(char c)
131{
132  static char* msgBuffer = (char*)MsgAreaBase;
133  *msgBuffer++ = c;
134  if (msgBuffer >= &bspMsgBuffer[(int)MsgAreaSize])  msgBuffer = bspMsgBuffer;
135  *msgBuffer   = 0x00;                /* Overwrite next location to show EOM */
136}
137
138
139void BSP_ask_for_reset(void)
140{
141  printk("\nSystem stopped, issue RESET");
142
143  for(;;);
144}
145
146
147/*===================================================================*/
148
149/*
150 *  BSP start routine.  Called by boot_card().
151 *
152 *  This routine does the bulk of the system initialization.
153 */
154void bsp_start(void)
155{
156  uintptr_t          intrStackStart;
157  uintptr_t          intrStackSize;
158
159  ppc_cpu_id_t       myCpu;
160  ppc_cpu_revision_t myCpuRevision;
161
162  /* Set the character output function;  The application may override this */
163  BSP_output_char = __bsp_outchar_to_memory;
164
165  printk("RTEMS %s\n", rtems_get_version_string());
166
167  /*
168   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
169   * function stores the result in global variables so that it can be used later...
170   */
171  myCpu         = get_ppc_cpu_type();
172  myCpuRevision = get_ppc_cpu_revision();
173  printk("CPU: 0x%04x,  Revision: 0x%04x = %d,  Name: %s\n",
174         myCpu, myCpuRevision, myCpuRevision, get_ppc_cpu_type_name(myCpu));
175
176  /*
177   *  Initialize the device driver parameters
178   */
179
180  /* For mpc6xx clock driver: */
181  BSP_bus_frequency       = 465000000;
182  BSP_processor_frequency = 465000000;  /* Measured with a DPM 440 2012/8/13 */
183  BSP_time_base_divisor   = 1000;
184
185  /* Timebase register ticks/microsecond;  The application may override these */
186  bsp_clicks_per_usec        = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
187  rtems_counter_initialize_converter(
188    BSP_bus_frequency / (BSP_time_base_divisor / 1000)
189  );
190
191  /*
192   * Initialize the interrupt related settings.
193   */
194  intrStackStart = CPU_UP_ALIGN((uint32_t)__bsp_ram_start);
195  intrStackSize  = rtems_configuration_get_interrupt_stack_size();
196
197  ppc_exc_initialize(intrStackStart, intrStackSize);
198
199  /* Let the user know what parameters we were compiled with */
200  printk("                  Base/Start     End         Size\n"
201         "RAM:              %p                    %p\n"
202         "RTEMS:                           %p\n"
203         "Interrupt Stack:  0x%08x              0x%x\n"
204         "Stack:            %p             %p          %p\n"
205         "Workspace:        %p             %p\n"
206         "MsgArea:          %p             %p\n"
207         "Physical RAM                     %p\n",
208         RamBase,        RamSize,
209         __rtems_end,
210         intrStackStart,                intrStackSize,
211         __stack_base,   _stack,        StackSize,
212         WorkAreaBase,   __bsp_ram_end,
213         MsgAreaBase,    MsgAreaSize,
214         __phy_ram_end);
215
216  /*
217   * Initialize RTEMS IRQ system
218   */
219  BSP_rtems_irq_mngt_init(0);
220
221  /* Continue with application-specific initialization */
222  app_bsp_start();
223}
224
225
226/*
227 *  BSP predriver hook.  Called by boot_card() just before drivers are
228 *  initialized.  Clear out any stale interrupts here.
229 */
230void bsp_predriver_hook(void)
231{
232  app_bsp_predriver_hook();
233}
Note: See TracBrowser for help on using the repository browser.