source: rtems/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c @ 561f53b

Last change on this file since 561f53b was 561f53b, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/22/04 at 22:30:59

2004-11-22 Jennifer Averett <jennifer@…>

PR 581/bsps

  • Makefile.am, bsp_specs, configure.ac, clock/Makefile.am, include/bsp.h, start/Makefile.am, start/start.S, startup/Makefile.am, startup/bspstart.c, startup/linkcmds, vectors/Makefile.am, vectors/vectors.S, wrapup/Makefile.am: Convert PSIM to new exception model.
  • irq/Makefile.am, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c: New files.
  • clock/clock.c: Removed.
  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*
2 *  This set of routines 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 any of these are invoked.
6 *
7 *  COPYRIGHT (c) 1989-1999.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 *  $Id$
15 */
16
17#include <string.h>
18#include <fcntl.h>
19#include <bsp.h>
20#include <bsp/irq.h>
21#include <rtems/libio.h>
22#include <rtems/libcsupport.h>
23#include <rtems/bspIo.h>
24#include <libcpu/cpuIdent.h>
25#include <libcpu/spr.h>
26
27SPR_RW(SPRG0)
28SPR_RW(SPRG1)
29
30
31extern unsigned long __rtems_end[];
32
33void  initialize_exceptions(void);
34
35/*  On psim, each click of the decrementer register corresponds
36 *  to 1 instruction.  By setting this to 100, we are indicating
37 *  that we are assuming it can execute 100 instructions per
38 *  microsecond.  This corresponds to sustaining 1 instruction
39 *  per cycle at 100 Mhz.  Whether this is a good guess or not
40 *  is anyone's guess.
41 */
42
43extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
44
45/*
46 *  The original table from the application and our copy of it with
47 *  some changes.
48 */
49
50extern rtems_configuration_table  Configuration;
51rtems_configuration_table         BSP_Configuration;
52rtems_cpu_table   Cpu_table;
53
54/*
55 *  Tells us where to put the workspace in case remote debugger is present.
56 */
57
58#if 0
59extern uint32_t          rdb_start;
60#endif
61
62/*
63 * PCI Bus Frequency
64 */
65 unsigned int BSP_bus_frequency;
66 /*
67  *  * Time base divisior (how many tick for 1 second).
68  *   */
69 unsigned int BSP_time_base_divisor;
70
71
72
73/*
74 *  Use the shared implementations of the following routines
75 */
76
77void bsp_postdriver_hook(void);
78void bsp_libc_init( void *, uint32_t, int );
79
80/*
81 * system init stack and soft ir stack size
82 */
83#define INIT_STACK_SIZE 0x1000
84#define INTR_STACK_SIZE CONFIGURE_INTERRUPT_STACK_MEMORY
85
86
87void BSP_panic(char *s)
88{
89    printk("%s PANIC %s\n",_RTEMS_version, s);
90      __asm__ __volatile ("sc");
91}
92
93void _BSP_Fatal_error(unsigned int v)
94{
95    printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
96      __asm__ __volatile ("sc");
97}
98
99/*
100 *  bsp_pretasking_hook
101 *
102 *  BSP pretasking hook.  Called just before drivers are initialized.
103 *  Used to setup libc and install any BSP extensions.
104 */
105
106void bsp_pretasking_hook(void)
107{
108  extern int end;
109  uint32_t         heap_start;
110  uint32_t         heap_size;
111
112  heap_start = (uint32_t) &end;
113  if (heap_start & (CPU_ALIGNMENT-1))
114    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
115
116  heap_size = BSP_Configuration.work_space_start - (void *)&end;
117  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
118
119  bsp_libc_init((void *) heap_start, heap_size, 0);
120
121#ifdef RTEMS_DEBUG
122  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
123#endif
124
125}
126
127/*
128 *  bsp_start
129 *
130 *  This routine does the bulk of the system initialization.
131 */
132
133void bsp_start( void )
134{
135  unsigned char     *work_space_start;
136  register uint32_t  intrStack;
137  register uint32_t *intrStackPtr;
138
139  /*
140   * Note we can not get CPU identification dynamically, so force current_ppc_cpu.
141   */
142  current_ppc_cpu = PPC_PSIM;
143
144  /*
145   * Set up our hooks
146   * Make sure libc_init is done before drivers initialized so that
147   * they can use atexit()
148   */
149
150  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
151  Cpu_table.postdriver_hook = bsp_postdriver_hook;
152
153  /*
154   *  Is this true?
155   *
156   *  PSIM does zero out memory BUT only when IT begins execution.  Thus
157   *  if we want to have a clean slate in the workspace each time we
158   *  begin execution of OUR application, then we must zero the workspace.
159   *
160   *  It is true that it takes simulated time to clear the memory.
161   */
162
163  Cpu_table.do_zero_of_workspace = FALSE;
164
165  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
166
167  BSP_bus_frequency        = (unsigned int)&PSIM_INSTRUCTIONS_PER_MICROSECOND;
168  BSP_time_base_divisor    = 1;
169
170  /*
171   *  The simulator likes the exception table to be at 0xfff00000.
172   */
173
174  Cpu_table.exceptions_in_RAM = FALSE;
175
176  BSP_Configuration.work_space_size += 1024;
177
178  work_space_start =
179    (unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
180
181  if ( work_space_start <= (unsigned char *)&end ) {
182    printk( "bspstart: Not enough RAM!!!\n" );
183    bsp_cleanup();
184  }
185
186  BSP_Configuration.work_space_start = work_space_start;
187
188  /*
189   * Initialize the interrupt related settings
190   * SPRG1 = software managed IRQ stack
191   *
192   * This could be done latter (e.g in IRQ_INIT) but it helps to understand
193   * some settings below...
194   */
195  intrStack = ((uint32_t) __rtems_end) +
196          INIT_STACK_SIZE + INTR_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE;
197
198  /* make sure it's properly aligned */
199  intrStack &= ~(CPU_STACK_ALIGNMENT-1);
200
201  /* tag the bottom (T. Straumann 6/36/2001 <strauman@slac.stanford.edu>) */
202  intrStackPtr = (uint32_t*) intrStack;
203  *intrStackPtr = 0;
204
205  _write_SPRG1(intrStack);
206
207  /* signal them that we have fixed PR288 - eventually, this should go away */
208  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
209
210  /*
211   * Initialize default raw exception hanlders. See vectors/vectors_init.c
212   */
213  initialize_exceptions();
214
215  /*
216   * Initalize RTEMS IRQ system
217   */
218  BSP_rtems_irq_mng_init(0);
219
220}
Note: See TracBrowser for help on using the repository browser.