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

4.104.114.84.95
Last change on this file since eba2e4f was eba2e4f, checked in by Joel Sherrill <joel.sherrill@…>, on 11/01/00 at 21:19:23

2000-11-01 Joel Sherrill <joel@…>

  • startup/bspstart.c: assoc.h, error.h, libio_.h, libio.h, and libcsupport.h moved from libc to lib/include/rtems and now must be referenced as <rtems/XXX.h>. Header file order was cleaned up while doing this.
  • Property mode set to 100644
File size: 6.4 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 *  All rights assigned to U.S. Government, 1994.
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.OARcorp.com/rtems/license.html.
14 *
15 *  $Id$
16 */
17
18#include <string.h>
19#include <fcntl.h>
20
21#include <bsp.h>
22#include <rtems/libio.h>
23#include <rtems/libcsupport.h>
24
25/*
26 *  The original table from the application and our copy of it with
27 *  some changes.
28 */
29 
30extern rtems_configuration_table  Configuration;
31rtems_configuration_table         BSP_Configuration;
32
33rtems_cpu_table   Cpu_table;
34rtems_unsigned32  bsp_isr_level;
35
36/*
37 *  Tells us where to put the workspace in case remote debugger is present.
38 */
39
40#if 0
41extern rtems_unsigned32  rdb_start;
42#endif
43
44/*
45 * Amount to increment itimer by each pass
46 * It is a variable instead of a #define to allow the 'looptest'
47 * script to bump it without recompiling rtems
48 *
49 *  NOTE:  This is based on the PA-RISC simulator.  I don't know if we
50 *         can actually pull this trick on the PPC simulator.
51 */
52
53rtems_unsigned32 CPU_PPC_CLICKS_PER_TICK;
54
55#if PSIM_FAST_IDLE
56
57/*
58 * Many of the tests are very slow on the simulator because they have
59 * have 5 second delays hardwired in.
60 *
61 * Try to speed those tests up by speeding up the clock when in the idle task.
62 *
63 *  NOTE:  At the current setting, 5 second delays in the tests take
64 *         approximately 5 seconds of wall time.
65 */
66
67rtems_extension fast_idle_switch_hook(
68  rtems_tcb *current_task,
69  rtems_tcb *heir_task
70)
71{
72    static rtems_unsigned32 normal_clock = ~0;
73    static rtems_unsigned32 fast_clock;
74
75    /* init our params on first call */
76    if (normal_clock == (rtems_unsigned32) ~0)
77    {
78        normal_clock = CPU_PPC_CLICKS_PER_TICK;
79        fast_clock = 10000;
80#if 0
81        fast_clock = CPU_PPC_CLICKS_PER_TICK / 0x10 ;
82#endif
83        if (fast_clock == 0)    /* handle pathological case */
84            fast_clock++;
85    }
86
87    /*
88     * Run the clock faster when idle is in place.
89     */
90
91    if (heir_task == _Thread_Idle)
92        CPU_PPC_CLICKS_PER_TICK = fast_clock;
93    else if (current_task == _Thread_Idle)
94        CPU_PPC_CLICKS_PER_TICK = normal_clock;
95}
96
97#endif
98
99/*
100 *  Use the shared implementations of the following routines
101 */
102 
103void bsp_postdriver_hook(void);
104void bsp_libc_init( void *, unsigned32, int );
105
106/*
107 *  bsp_pretasking_hook
108 *
109 *  BSP pretasking hook.  Called just before drivers are initialized.
110 *  Used to setup libc and install any BSP extensions.
111 */
112
113void bsp_pretasking_hook(void)
114{
115  extern int end;
116  rtems_unsigned32 heap_start;
117  rtems_unsigned32 heap_size;
118
119  heap_start = (rtems_unsigned32) &end;
120  if (heap_start & (CPU_ALIGNMENT-1))
121    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
122
123  heap_size = BSP_Configuration.work_space_start - (void *)&end;
124  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
125
126  bsp_libc_init((void *) heap_start, heap_size, 0);
127
128#if PSIM_FAST_IDLE
129  /*
130   *  Install the fast idle task switch extension
131   *
132   *  On MP systems, might not want to do this; it confuses at least
133   *  one test (mp06) on the PA-RISC simulator
134   */
135
136#if 0
137  if (BSP_Configuration.User_multiprocessing_table == 0)
138#endif
139  {
140    rtems_extensions_table  fast_idle_extension;
141    rtems_id                extension_id;
142    rtems_status_code       rc;
143
144    memset(&fast_idle_extension, 0, sizeof(fast_idle_extension));
145
146    fast_idle_extension.thread_switch  = fast_idle_switch_hook;
147
148    rc = rtems_extension_create(
149      rtems_build_name('F', 'D', 'L', 'E'),
150      &fast_idle_extension,
151      &extension_id
152    );
153    if (rc != RTEMS_SUCCESSFUL)
154      rtems_fatal_error_occurred(rc);
155  }
156#endif
157
158#ifdef RTEMS_DEBUG
159  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
160#endif
161
162}
163
164/*
165 *  bsp_start
166 *
167 *  This routine does the bulk of the system initialization.
168 */
169
170void bsp_start( void )
171{
172  unsigned char *work_space_start;
173
174#if 0
175  /*
176   * Set MSR to show vectors at 0 XXX
177   */
178  _CPU_MSR_Value( msr_value );
179  msr_value &= ~PPC_MSR_EP;
180  _CPU_MSR_SET( msr_value );
181#endif
182
183  /*
184   * Set up our hooks
185   * Make sure libc_init is done before drivers initialized so that
186   * they can use atexit()
187   */
188
189  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
190  Cpu_table.postdriver_hook = bsp_postdriver_hook;
191
192  /*
193   *  Is this true?
194   *
195   *  PSIM does zero out memory BUT only when IT begins execution.  Thus
196   *  if we want to have a clean slate in the workspace each time we
197   *  begin execution of OUR application, then we must zero the workspace.
198   *
199   *  It is true that it takes simulated time to clear the memory.
200   */
201
202  Cpu_table.do_zero_of_workspace = FALSE;
203
204  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
205
206  /*
207   *  The monitor likes the exception table to be at 0x0.
208   */
209
210  Cpu_table.exceptions_in_RAM = TRUE;
211
212/*
213#if defined(RTEMS_POSIX_API)
214  BSP_Configuration.work_space_size *= 3;
215#endif
216*/
217
218  BSP_Configuration.work_space_size += 1024;
219
220#if 0
221  work_space_start =
222    (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
223#endif
224
225  work_space_start =
226    (unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
227
228  if ( work_space_start <= (unsigned char *)&end ) {
229    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
230    bsp_cleanup();
231  }
232
233  BSP_Configuration.work_space_start = work_space_start;
234
235#if PSIM_FAST_IDLE
236  /*
237   * Add 1 extension for fast idle
238   */
239
240  BSP_Configuration.maximum_extensions++;
241#endif
242
243  /*
244   * Set the "clicks per tick" for the simulator
245   *  used by XXX/clock/clock.c to schedule interrupts
246   *
247   *  NOTE: On psim, each click of the decrementer register corresponds
248   *        to 1 instruction.  By setting this to 100, we are indicating
249   *        that we are assuming it can execute 100 instructions per
250   *        microsecond.  This corresponds to sustaining 1 instruction
251   *        per cycle at 100 Mhz.  Whether this is a good guess or not
252   *        is anyone's guess.
253   */
254
255  {
256    extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
257
258    CPU_PPC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick *
259      (int) &PSIM_INSTRUCTIONS_PER_MICROSECOND;
260  }
261}
Note: See TracBrowser for help on using the repository browser.