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

4.104.114.84.9
Last change on this file since bd9c3d1 was bd9c3d1, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 15, 1998 at 8:50:31 PM

Numerous changes which in total greatly reduced the amount of source
code in each BSP's bspstart.c. These changes were:

+ confdefs.h now knows libio's semaphore requirements
+ shared/main.c now copies Configuration to BSP_Configuration
+ shared/main.c fills in the Cpu_table with default values

This removed the need for rtems_libio_config() and the constant
BSP_LIBIO_MAX_FDS in every BSP. Plus now the maximum number of open
files can now be set on the gcc command line.

  • Property mode set to 100644
File size: 6.1 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-1998.
8 *  On-Line Applications Research Corporation (OAR).
9 *  Copyright 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 *  Ported to ERC32 implementation of the SPARC by On-Line Applications
16 *  Research Corporation (OAR) under contract to the European Space
17 *  Agency (ESA).
18 *
19 *  ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995.
20 *  European Space Agency.
21 *
22 *  $Id$
23 */
24
25#include <bsp.h>
26#include <rtems/libio.h>
27
28#include <libcsupport.h>
29
30#include <string.h>
31
32/*
33 *  The original table from the application and our copy of it with
34 *  some changes.
35 */
36 
37extern rtems_configuration_table  Configuration;
38rtems_configuration_table         BSP_Configuration;
39
40rtems_cpu_table   Cpu_table;
41
42/*
43 *  Tells us where to put the workspace in case remote debugger is present.
44 */
45
46extern rtems_unsigned32  rdb_start;
47
48/*
49 * Amount to increment itimer by each pass
50 * It is a variable instead of a #define to allow the 'looptest'
51 * script to bump it without recompiling rtems
52 *
53 *  NOTE:  This is based on the PA-RISC simulator.  I don't know if we
54 *         can actually pull this trick on the SPARC simulator.
55 */
56
57rtems_unsigned32 CPU_SPARC_CLICKS_PER_TICK;
58
59#if SIMSPARC_FAST_IDLE
60
61/*
62 * Many of the tests are very slow on the simulator because they have
63 * have 5 second delays hardwired in.
64 *
65 * Try to speed those tests up by speeding up the clock when in the idle task.
66 *
67 *  NOTE:  At the current setting, 5 second delays in the tests take
68 *         approximately 5 seconds of wall time.
69 */
70
71rtems_extension fast_idle_switch_hook(
72  rtems_tcb *current_task,
73  rtems_tcb *heir_task
74)
75{
76    static rtems_unsigned32 normal_clock = ~0;
77    static rtems_unsigned32 fast_clock;
78
79    /* init our params on first call */
80    if (normal_clock == ~0)
81    {
82        normal_clock = CPU_SPARC_CLICKS_PER_TICK;
83        fast_clock = CPU_SPARC_CLICKS_PER_TICK / 0x08;
84        if (fast_clock == 0)    /* handle pathological case */
85            fast_clock++;
86    }
87
88    /*
89     * Run the clock faster when idle is in place.
90     */
91
92    if (heir_task == _Thread_Idle)
93        CPU_SPARC_CLICKS_PER_TICK = fast_clock;
94    else if (current_task == _Thread_Idle)
95        CPU_SPARC_CLICKS_PER_TICK = normal_clock;
96}
97
98#endif
99
100/*
101 *  Use the shared implementations of the following routines
102 */
103 
104void bsp_postdriver_hook(void);
105void bsp_libc_init( void *, unsigned32, int );
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}
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  /* Check if MEC is initialised */
177
178  if (!(ERC32_MEC.Control & 0xfe080000)) {
179
180  /*
181   *  DISABLE THE HARDWARE WATCHDOG!!!
182   */
183
184    ERC32_MEC.Watchdog_Trap_Door_Set = 0;          /* value is irrelevant */
185
186  /*
187   *  Reduce the number of wait states to 0 for all memory areas.
188   */
189
190    ERC32_MEC.Wait_State_Configuration = 0; 
191
192  }
193 
194  /*
195   * Set up our hooks
196   * Make sure libc_init is done before drivers initialized so that
197   * they can use atexit()
198   */
199
200  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
201  Cpu_table.postdriver_hook = bsp_postdriver_hook;
202
203  /*
204   *  SIS does zero out memory BUT only when IT begins execution.  Thus
205   *  if we want to have a clean slate in the workspace each time we
206   *  begin execution of OUR application, then we must zero the workspace.
207   */
208  Cpu_table.do_zero_of_workspace = TRUE;
209
210  /*
211   *  This should be enough interrupt stack.
212   */
213
214  Cpu_table.interrupt_stack_size = (24 * 1024);
215
216#if defined(RTEMS_POSIX_API)
217  BSP_Configuration.work_space_size *= 3;
218#endif
219
220  work_space_start = 
221    (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
222
223  if ( work_space_start <= (unsigned char *)&end ) {
224    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
225    BSP_fatal_return();
226  }
227
228  BSP_Configuration.work_space_start = work_space_start;
229
230  /*
231   *  Account for the console's resources
232   */
233
234  console_reserve_resources( &BSP_Configuration );
235
236#if SIMSPARC_FAST_IDLE
237  /*
238   * Add 1 extension for fast idle
239   */
240
241  BSP_Configuration.maximum_extensions++;
242#endif
243
244  /*
245   * Add 1 extension for MPCI_fatal
246   */
247
248  if (BSP_Configuration.User_multiprocessing_table)
249    BSP_Configuration.maximum_extensions++;
250
251  /*
252   * Set the "clicks per tick" for the simulator
253   *  used by XXX/clock/clock.c to schedule interrupts
254   */
255
256  CPU_SPARC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick;
257}
Note: See TracBrowser for help on using the repository browser.