source: rtems/c/src/lib/libbsp/sparc/erc32/startup/bspstart.c @ df49c60

4.104.114.84.95
Last change on this file since df49c60 was df49c60, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 12, 2000 at 3:00:15 PM

Merged from 4.5.0-beta3a

  • Property mode set to 100644
File size: 6.0 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.OARcorp.com/rtems/license.html.
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#include <bsp.h>
25#include <rtems/libio.h>
26
27#include <libcsupport.h>
28
29#include <string.h>
30
31/*
32 *  The original table from the application and our copy of it with
33 *  some changes.
34 */
35 
36extern rtems_configuration_table  Configuration;
37rtems_configuration_table         BSP_Configuration;
38
39rtems_cpu_table   Cpu_table;
40
41/*
42 *  Tells us where to put the workspace in case remote debugger is present.
43 */
44
45extern rtems_unsigned32  rdb_start;
46
47/*
48 * Amount to increment itimer by each pass
49 * It is a variable instead of a #define to allow the 'looptest'
50 * script to bump it without recompiling rtems
51 *
52 *  NOTE:  This is based on the PA-RISC simulator.  I don't know if we
53 *         can actually pull this trick on the SPARC simulator.
54 */
55
56rtems_unsigned32 CPU_SPARC_CLICKS_PER_TICK;
57
58#if SIMSPARC_FAST_IDLE
59
60/*
61 * Many of the tests are very slow on the simulator because they have
62 * have 5 second delays hardwired in.
63 *
64 * Try to speed those tests up by speeding up the clock when in the idle task.
65 *
66 *  NOTE:  At the current setting, 5 second delays in the tests take
67 *         approximately 5 seconds of wall time.
68 */
69
70rtems_extension fast_idle_switch_hook(
71  rtems_tcb *current_task,
72  rtems_tcb *heir_task
73)
74{
75    static rtems_unsigned32 normal_clock = ~0;
76    static rtems_unsigned32 fast_clock;
77
78    /* init our params on first call */
79    if (normal_clock == ~0)
80    {
81        normal_clock = CPU_SPARC_CLICKS_PER_TICK;
82        fast_clock = CPU_SPARC_CLICKS_PER_TICK / 0x08;
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_SPARC_CLICKS_PER_TICK = fast_clock;
93    else if (current_task == _Thread_Idle)
94        CPU_SPARC_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 );
105extern void bsp_spurious_initialize();
106
107/*
108 *  bsp_pretasking_hook
109 *
110 *  BSP pretasking hook.  Called just before drivers are initialized.
111 *  Used to setup libc and install any BSP extensions.
112 */
113
114void bsp_pretasking_hook(void)
115{
116  extern int end;
117  rtems_unsigned32 heap_start;
118  rtems_unsigned32 heap_size;
119
120  heap_start = (rtems_unsigned32) &end;
121  if (heap_start & (CPU_ALIGNMENT-1))
122    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
123
124  heap_size = BSP_Configuration.work_space_start - (void *)&end;
125  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
126
127  bsp_libc_init((void *) heap_start, heap_size, 0);
128
129
130#if SIMSPARC_FAST_IDLE
131  /*
132   *  Install the fast idle task switch extension
133   *
134   *  On MP systems, might not want to do this; it confuses at least
135   *  one test (mp06) on the PA-RISC simulator
136   */
137
138#if 0
139  if (BSP_Configuration.User_multiprocessing_table == 0)
140#endif
141  {
142    rtems_extensions_table  fast_idle_extension;
143    rtems_id                extension_id;
144    rtems_status_code       rc;
145
146    memset(&fast_idle_extension, 0, sizeof(fast_idle_extension));
147
148    fast_idle_extension.thread_switch  = fast_idle_switch_hook;
149
150    rc = rtems_extension_create(
151      rtems_build_name('F', 'D', 'L', 'E'),
152      &fast_idle_extension, 
153      &extension_id
154    );
155    if (rc != RTEMS_SUCCESSFUL)
156      rtems_fatal_error_occurred(rc);
157  }
158#endif
159
160#ifdef RTEMS_DEBUG
161  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
162#endif
163
164  bsp_spurious_initialize();
165}
166
167/*
168 *  bsp_start
169 *
170 *  This routine does the bulk of the system initialization.
171 */
172
173void bsp_start( void )
174{
175  unsigned char *work_space_start;
176
177  /* Check if MEC is initialised */
178
179  if (!(ERC32_MEC.Control & 0xfe080000)) {
180
181  /*
182   *  DISABLE THE HARDWARE WATCHDOG!!!
183   */
184
185    ERC32_MEC.Watchdog_Trap_Door_Set = 0;          /* value is irrelevant */
186
187  /*
188   *  Reduce the number of wait states to 0 for all memory areas.
189   */
190
191    ERC32_MEC.Wait_State_Configuration = 0; 
192
193  }
194 
195  /*
196   * Set up our hooks
197   * Make sure libc_init is done before drivers initialized so that
198   * they can use atexit()
199   */
200
201  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
202  Cpu_table.postdriver_hook = bsp_postdriver_hook;
203
204  /*
205   *  SIS does zero out memory BUT only when IT begins execution.  Thus
206   *  if we want to have a clean slate in the workspace each time we
207   *  begin execution of OUR application, then we must zero the workspace.
208   */
209  Cpu_table.do_zero_of_workspace = TRUE;
210
211  /*
212   *  This should be enough interrupt stack.
213   */
214
215  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
216
217  work_space_start = 
218    (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
219
220  if ( work_space_start <= (unsigned char *)&end ) {
221    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
222    BSP_fatal_return();
223  }
224
225  BSP_Configuration.work_space_start = work_space_start;
226
227#if SIMSPARC_FAST_IDLE
228  /*
229   * Add 1 extension for fast idle
230   */
231
232  BSP_Configuration.maximum_extensions++;
233#endif
234
235  /*
236   * Add 1 extension for MPCI_fatal
237   */
238
239  if (BSP_Configuration.User_multiprocessing_table)
240    BSP_Configuration.maximum_extensions++;
241
242  /*
243   * Set the "clicks per tick" for the simulator
244   *  used by XXX/clock/clock.c to schedule interrupts
245   */
246
247  CPU_SPARC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick;
248}
Note: See TracBrowser for help on using the repository browser.