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

4.104.114.84.95
Last change on this file since cba119c9 was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on Apr 21, 2004 at 4:01:48 PM

Remove duplicate white lines.

  • 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#if SIMSPARC_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) if the simulators are running too far from real time.
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  bsp_spurious_initialize();
163}
164
165/*
166 *  bsp_start
167 *
168 *  This routine does the bulk of the system initialization.
169 */
170
171void bsp_start( void )
172{
173  unsigned char *work_space_start;
174
175  /*
176   * Set up our hooks
177   * Make sure libc_init is done before drivers initialized so that
178   * they can use atexit()
179   */
180
181  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
182  Cpu_table.postdriver_hook = bsp_postdriver_hook;
183
184  /*
185   *  SIS does zero out memory BUT only when IT begins execution.  Thus
186   *  if we want to have a clean slate in the workspace each time we
187   *  begin execution of OUR application, then we must zero the workspace.
188   */
189  Cpu_table.do_zero_of_workspace = TRUE;
190
191  /*
192   *  This should be enough interrupt stack.
193   */
194
195  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
196
197  work_space_start =
198    (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
199
200  if ( work_space_start <= (unsigned char *)&end ) {
201    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
202    BSP_fatal_return();
203  }
204
205  BSP_Configuration.work_space_start = work_space_start;
206
207#if SIMSPARC_FAST_IDLE
208  /*
209   * Add 1 extension for fast idle
210   */
211
212  BSP_Configuration.maximum_extensions++;
213#endif
214
215  /*
216   * Add 1 extension for MPCI_fatal
217   */
218
219  if (BSP_Configuration.User_multiprocessing_table)
220    BSP_Configuration.maximum_extensions++;
221
222  /*
223   * Set the "clicks per tick" for the simulator
224   *  used by XXX/clock/clock.c to schedule interrupts
225   */
226
227  CPU_SPARC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick;
228}
Note: See TracBrowser for help on using the repository browser.