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

4.104.114.84.95
Last change on this file since 3eec211 was 3eec211, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 13, 2000 at 10:31:22 PM

2000-11-13 Jiri Gaisler <jgais@…>

  • ChangeLog?, .cvsignore, Makefile.am, bspclean.c, bspstart.c, gnatcommon.c, start.S: New files. Largely moved from ERC32 BSP to be able to be shared with LEON and other SPARC BSPs.
  • Property mode set to 100644
File size: 5.8 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/* 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 rtems_unsigned32  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 *  NOTE:  This is based on the PA-RISC simulator.  I don't know if we
55 *         can actually pull this trick on the SPARC simulator.
56 */
57
58rtems_unsigned32 CPU_SPARC_CLICKS_PER_TICK;
59
60#if SIMSPARC_FAST_IDLE
61
62/*
63 * Many of the tests are very slow on the simulator because they have
64 * have 5 second delays hardwired in.
65 *
66 * Try to speed those tests up by speeding up the clock when in the idle task.
67 *
68 *  NOTE:  At the current setting, 5 second delays in the tests take
69 *         approximately 5 seconds of wall time.
70 */
71
72rtems_extension fast_idle_switch_hook(
73  rtems_tcb *current_task,
74  rtems_tcb *heir_task
75)
76{
77    static rtems_unsigned32 normal_clock = ~0;
78    static rtems_unsigned32 fast_clock;
79
80    /* init our params on first call */
81    if (normal_clock == ~0)
82    {
83        normal_clock = CPU_SPARC_CLICKS_PER_TICK;
84        fast_clock = CPU_SPARC_CLICKS_PER_TICK / 0x08;
85        if (fast_clock == 0)    /* handle pathological case */
86            fast_clock++;
87    }
88
89    /*
90     * Run the clock faster when idle is in place.
91     */
92
93    if (heir_task == _Thread_Idle)
94        CPU_SPARC_CLICKS_PER_TICK = fast_clock;
95    else if (current_task == _Thread_Idle)
96        CPU_SPARC_CLICKS_PER_TICK = normal_clock;
97}
98
99#endif
100
101/*
102 *  Use the shared implementations of the following routines
103 */
104 
105void bsp_postdriver_hook(void);
106void bsp_libc_init( void *, unsigned32, int );
107extern void bsp_spurious_initialize();
108
109/*
110 *  bsp_pretasking_hook
111 *
112 *  BSP pretasking hook.  Called just before drivers are initialized.
113 *  Used to setup libc and install any BSP extensions.
114 */
115
116void bsp_pretasking_hook(void)
117{
118  extern int end;
119  rtems_unsigned32 heap_start;
120  rtems_unsigned32 heap_size;
121
122  heap_start = (rtems_unsigned32) &end;
123  if (heap_start & (CPU_ALIGNMENT-1))
124    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
125
126  heap_size = BSP_Configuration.work_space_start - (void *)&end - STACK_SIZE;
127  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
128
129  bsp_libc_init((void *) heap_start, heap_size, 0);
130
131
132#if SIMSPARC_FAST_IDLE
133  /*
134   *  Install the fast idle task switch extension
135   *
136   *  On MP systems, might not want to do this; it confuses at least
137   *  one test (mp06) on the PA-RISC simulator
138   */
139
140#if 0
141  if (BSP_Configuration.User_multiprocessing_table == 0)
142#endif
143  {
144    rtems_extensions_table  fast_idle_extension;
145    rtems_id                extension_id;
146    rtems_status_code       rc;
147
148    memset(&fast_idle_extension, 0, sizeof(fast_idle_extension));
149
150    fast_idle_extension.thread_switch  = fast_idle_switch_hook;
151
152    rc = rtems_extension_create(
153      rtems_build_name('F', 'D', 'L', 'E'),
154      &fast_idle_extension, 
155      &extension_id
156    );
157    if (rc != RTEMS_SUCCESSFUL)
158      rtems_fatal_error_occurred(rc);
159  }
160#endif
161
162#ifdef RTEMS_DEBUG
163  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
164#endif
165
166  bsp_spurious_initialize();
167}
168
169/*
170 *  bsp_start
171 *
172 *  This routine does the bulk of the system initialization.
173 */
174
175void bsp_start( void )
176{
177  unsigned char *work_space_start;
178
179  /*
180   * Set up our hooks
181   * Make sure libc_init is done before drivers initialized so that
182   * they can use atexit()
183   */
184
185  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
186  Cpu_table.postdriver_hook = bsp_postdriver_hook;
187
188  /*
189   *  SIS does zero out memory BUT only when IT begins execution.  Thus
190   *  if we want to have a clean slate in the workspace each time we
191   *  begin execution of OUR application, then we must zero the workspace.
192   */
193  Cpu_table.do_zero_of_workspace = TRUE;
194
195  /*
196   *  This should be enough interrupt stack.
197   */
198
199  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
200
201  work_space_start = 
202    (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
203
204  if ( work_space_start <= (unsigned char *)&end ) {
205    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
206    BSP_fatal_return();
207  }
208
209  BSP_Configuration.work_space_start = work_space_start;
210
211#if SIMSPARC_FAST_IDLE
212  /*
213   * Add 1 extension for fast idle
214   */
215
216  BSP_Configuration.maximum_extensions++;
217#endif
218
219  /*
220   * Add 1 extension for MPCI_fatal
221   */
222
223  if (BSP_Configuration.User_multiprocessing_table)
224    BSP_Configuration.maximum_extensions++;
225
226  /*
227   * Set the "clicks per tick" for the simulator
228   *  used by XXX/clock/clock.c to schedule interrupts
229   */
230
231  CPU_SPARC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick;
232}
Note: See TracBrowser for help on using the repository browser.