OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [psim/] [startup/] [bspstart.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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
 *  All rights 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
 *  $Id: bspstart.c,v 1.2 2001-09-27 12:01:02 chris Exp $
16
 */
17
 
18
#include <bsp.h>
19
#include <rtems/libio.h>
20
 
21
#include <libcsupport.h>
22
 
23
#include <string.h>
24
#include <fcntl.h>
25
 
26
/*
27
 *  The original table from the application and our copy of it with
28
 *  some changes.
29
 */
30
 
31
extern rtems_configuration_table  Configuration;
32
rtems_configuration_table         BSP_Configuration;
33
 
34
rtems_cpu_table   Cpu_table;
35
rtems_unsigned32  bsp_isr_level;
36
 
37
/*
38
 *  Tells us where to put the workspace in case remote debugger is present.
39
 */
40
 
41
#if 0
42
extern rtems_unsigned32  rdb_start;
43
#endif
44
 
45
/*
46
 * Amount to increment itimer by each pass
47
 * It is a variable instead of a #define to allow the 'looptest'
48
 * script to bump it without recompiling rtems
49
 *
50
 *  NOTE:  This is based on the PA-RISC simulator.  I don't know if we
51
 *         can actually pull this trick on the PPC simulator.
52
 */
53
 
54
rtems_unsigned32 CPU_PPC_CLICKS_PER_TICK;
55
 
56
#if PSIM_FAST_IDLE
57
 
58
/*
59
 * Many of the tests are very slow on the simulator because they have
60
 * have 5 second delays hardwired in.
61
 *
62
 * Try to speed those tests up by speeding up the clock when in the idle task.
63
 *
64
 *  NOTE:  At the current setting, 5 second delays in the tests take
65
 *         approximately 5 seconds of wall time.
66
 */
67
 
68
rtems_extension fast_idle_switch_hook(
69
  rtems_tcb *current_task,
70
  rtems_tcb *heir_task
71
)
72
{
73
    static rtems_unsigned32 normal_clock = ~0;
74
    static rtems_unsigned32 fast_clock;
75
 
76
    /* init our params on first call */
77
    if (normal_clock == (rtems_unsigned32) ~0)
78
    {
79
        normal_clock = CPU_PPC_CLICKS_PER_TICK;
80
        fast_clock = 10000;
81
#if 0
82
        fast_clock = CPU_PPC_CLICKS_PER_TICK / 0x10 ;
83
#endif
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_PPC_CLICKS_PER_TICK = fast_clock;
94
    else if (current_task == _Thread_Idle)
95
        CPU_PPC_CLICKS_PER_TICK = normal_clock;
96
}
97
 
98
#endif
99
 
100
/*
101
 *  Use the shared implementations of the following routines
102
 */
103
 
104
void bsp_postdriver_hook(void);
105
void 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
 
114
void 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
#if PSIM_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) on the PA-RISC simulator
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
}
164
 
165
/*
166
 *  bsp_start
167
 *
168
 *  This routine does the bulk of the system initialization.
169
 */
170
 
171
void bsp_start( void )
172
{
173
  unsigned char *work_space_start;
174
 
175
#if 0
176
  /*
177
   * Set MSR to show vectors at 0 XXX
178
   */
179
  _CPU_MSR_Value( msr_value );
180
  msr_value &= ~PPC_MSR_EP;
181
  _CPU_MSR_SET( msr_value );
182
#endif
183
 
184
  /*
185
   * Set up our hooks
186
   * Make sure libc_init is done before drivers initialized so that
187
   * they can use atexit()
188
   */
189
 
190
  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
191
  Cpu_table.postdriver_hook = bsp_postdriver_hook;
192
 
193
  /*
194
   *  Is this true?
195
   *
196
   *  PSIM does zero out memory BUT only when IT begins execution.  Thus
197
   *  if we want to have a clean slate in the workspace each time we
198
   *  begin execution of OUR application, then we must zero the workspace.
199
   *
200
   *  It is true that it takes simulated time to clear the memory.
201
   */
202
 
203
  Cpu_table.do_zero_of_workspace = FALSE;
204
 
205
  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
206
 
207
  /*
208
   *  The monitor likes the exception table to be at 0x0.
209
   */
210
 
211
  Cpu_table.exceptions_in_RAM = TRUE;
212
 
213
/*
214
#if defined(RTEMS_POSIX_API)
215
  BSP_Configuration.work_space_size *= 3;
216
#endif
217
*/
218
 
219
  BSP_Configuration.work_space_size += 1024;
220
 
221
#if 0
222
  work_space_start =
223
    (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
224
#endif
225
 
226
  work_space_start =
227
    (unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
228
 
229
  if ( work_space_start <= (unsigned char *)&end ) {
230
    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
231
    bsp_cleanup();
232
  }
233
 
234
  BSP_Configuration.work_space_start = work_space_start;
235
 
236
#if PSIM_FAST_IDLE
237
  /*
238
   * Add 1 extension for fast idle
239
   */
240
 
241
  BSP_Configuration.maximum_extensions++;
242
#endif
243
 
244
  /*
245
   * Set the "clicks per tick" for the simulator
246
   *  used by XXX/clock/clock.c to schedule interrupts
247
   *
248
   *  NOTE: On psim, each click of the decrementer register corresponds
249
   *        to 1 instruction.  By setting this to 100, we are indicating
250
   *        that we are assuming it can execute 100 instructions per
251
   *        microsecond.  This corresponds to sustaining 1 instruction
252
   *        per cycle at 100 Mhz.  Whether this is a good guess or not
253
   *        is anyone's guess.
254
   */
255
 
256
  {
257
    extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
258
 
259
    CPU_PPC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick *
260
      (int) &PSIM_INSTRUCTIONS_PER_MICROSECOND;
261
  }
262
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.