source: rtems/c/src/lib/libbsp/sparc/shared/bspstart.c @ 206e590

4.104.114.84.95
Last change on this file since 206e590 was e7d03cbc, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/31/04 at 05:18:13

2004-03-31 Ralf Corsepius <ralf_corsepius@…>

  • bspstart.c, gnatcommon.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 5.6 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-2003.
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 *  Ported to ERC32 implementation of the SPARC by On-Line Applications
15 *  Research Corporation (OAR) under contract to the European Space
16 *  Agency (ESA).
17 *
18 *  ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995.
19 *  European Space Agency.
20 *
21 *  $Id$
22 */
23
24/* must be identical to STACK_SIZE in start.S */
25#define STACK_SIZE 16 * 1024
26
27#include <string.h>
28
29#include <bsp.h>
30#include <rtems/libio.h>
31#include <rtems/libcsupport.h>
32 
33/*
34 *  The original table from the application and our copy of it with
35 *  some changes.
36 */
37 
38extern rtems_configuration_table  Configuration;
39rtems_configuration_table         BSP_Configuration;
40
41rtems_cpu_table   Cpu_table;
42
43/*
44 *  Tells us where to put the workspace in case remote debugger is present.
45 */
46
47extern uint32_t          rdb_start;
48
49/*
50 * Amount to increment itimer by each pass
51 * It is a variable instead of a #define to allow the 'looptest'
52 * script to bump it without recompiling rtems
53 */
54
55uint32_t         CPU_SPARC_CLICKS_PER_TICK;
56
57#if SIMSPARC_FAST_IDLE
58
59/*
60 * Many of the tests are very slow on the simulator because they have
61 * have 5 second delays hardwired in.
62 *
63 * Try to speed those tests up by speeding up the clock when in the idle task.
64 *
65 *  NOTE:  At the current setting, 5 second delays in the tests take
66 *         approximately 5 seconds of wall time.
67 */
68
69rtems_extension fast_idle_switch_hook(
70  rtems_tcb *current_task,
71  rtems_tcb *heir_task
72)
73{
74    static uint32_t         normal_clock = ~0;
75    static uint32_t         fast_clock;
76
77    /* init our params on first call */
78    if (normal_clock == ~0)
79    {
80        normal_clock = CPU_SPARC_CLICKS_PER_TICK;
81        fast_clock = CPU_SPARC_CLICKS_PER_TICK / 0x08;
82        if (fast_clock == 0)    /* handle pathological case */
83            fast_clock++;
84    }
85
86    /*
87     * Run the clock faster when idle is in place.
88     */
89
90    if (heir_task == _Thread_Idle)
91        CPU_SPARC_CLICKS_PER_TICK = fast_clock;
92    else if (current_task == _Thread_Idle)
93        CPU_SPARC_CLICKS_PER_TICK = normal_clock;
94}
95
96#endif
97
98/*
99 *  Use the shared implementations of the following routines
100 */
101 
102void bsp_postdriver_hook(void);
103void bsp_libc_init( void *, uint32_t, int );
104extern void bsp_spurious_initialize();
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  uint32_t         heap_start;
117  uint32_t         heap_size;
118
119  heap_start = (uint32_t) &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 - STACK_SIZE;
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
129#if SIMSPARC_FAST_IDLE
130  /*
131   *  Install the fast idle task switch extension
132   *
133   *  On MP systems, might not want to do this; it confuses at least
134   *  one test (mp06) if the simulators are running too far from real time.
135   */
136
137#if 0
138  if (BSP_Configuration.User_multiprocessing_table == 0)
139#endif
140  {
141    rtems_extensions_table  fast_idle_extension;
142    rtems_id                extension_id;
143    rtems_status_code       rc;
144
145    memset(&fast_idle_extension, 0, sizeof(fast_idle_extension));
146
147    fast_idle_extension.thread_switch  = fast_idle_switch_hook;
148
149    rc = rtems_extension_create(
150      rtems_build_name('F', 'D', 'L', 'E'),
151      &fast_idle_extension,
152      &extension_id
153    );
154    if (rc != RTEMS_SUCCESSFUL)
155      rtems_fatal_error_occurred(rc);
156  }
157#endif
158
159#ifdef RTEMS_DEBUG
160  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
161#endif
162
163  bsp_spurious_initialize();
164}
165
166/*
167 *  bsp_start
168 *
169 *  This routine does the bulk of the system initialization.
170 */
171
172void bsp_start( void )
173{
174  unsigned char *work_space_start;
175
176  /*
177   * Set up our hooks
178   * Make sure libc_init is done before drivers initialized so that
179   * they can use atexit()
180   */
181
182  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
183  Cpu_table.postdriver_hook = bsp_postdriver_hook;
184
185  /*
186   *  SIS does zero out memory BUT only when IT begins execution.  Thus
187   *  if we want to have a clean slate in the workspace each time we
188   *  begin execution of OUR application, then we must zero the workspace.
189   */
190  Cpu_table.do_zero_of_workspace = TRUE;
191
192  /*
193   *  This should be enough interrupt stack.
194   */
195
196  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
197
198  work_space_start =
199    (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
200
201  if ( work_space_start <= (unsigned char *)&end ) {
202    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
203    BSP_fatal_return();
204  }
205
206  BSP_Configuration.work_space_start = work_space_start;
207
208#if SIMSPARC_FAST_IDLE
209  /*
210   * Add 1 extension for fast idle
211   */
212
213  BSP_Configuration.maximum_extensions++;
214#endif
215
216  /*
217   * Add 1 extension for MPCI_fatal
218   */
219
220  if (BSP_Configuration.User_multiprocessing_table)
221    BSP_Configuration.maximum_extensions++;
222
223  /*
224   * Set the "clicks per tick" for the simulator
225   *  used by XXX/clock/clock.c to schedule interrupts
226   */
227
228  CPU_SPARC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick;
229}
Note: See TracBrowser for help on using the repository browser.