source: rtems/c/src/lib/libbsp/hppa1.1/simhppa/startup/bspstart.c @ c244a9ee

4.104.114.84.9
Last change on this file since c244a9ee was c244a9ee, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 14, 1998 at 9:32:12 PM

Stack checker extension now accounted for in confdefs.h

  • Property mode set to 100644
File size: 8.4 KB
Line 
1/*  bsp_start()
2 *
3 *  This routine starts the application.  It includes application,
4 *  board, and monitor specific initialization and configuration.
5 *  The generic CPU dependent initialization has been performed
6 *  before this routine is invoked.
7 *
8 *  Called by RTEMS::RTEMS constructor in startup-ctor.cc
9 *
10 *  INPUT:  NONE
11 *
12 *  OUTPUT: NONE
13 *
14 *  COPYRIGHT (c) 1989-1998.
15 *  On-Line Applications Research Corporation (OAR).
16 *  Copyright assigned to U.S. Government, 1994.
17 *
18 *  The license and distribution terms for this file may be
19 *  found in the file LICENSE in this distribution or at
20 *  http://www.OARcorp.com/rtems/license.html.
21 *
22 *  $Id$
23 */
24
25#include <rtems.h>
26#include <bsp.h>
27#include <rtems/libio.h>
28
29#include <libcsupport.h>
30
31#include <string.h>
32
33#ifdef STACK_CHECKER_ON
34#include <stackchk.h>
35#endif
36
37extern rtems_configuration_table  Configuration;
38
39rtems_configuration_table BSP_Configuration;
40rtems_cpu_table           Cpu_table;
41
42int cpu_number;
43
44#define WORKSPACE_SIZE (1024 * 1024)
45rtems_unsigned8   MY_WORK_SPACE[ WORKSPACE_SIZE ];
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
53rtems_unsigned32 CPU_HPPA_CLICKS_PER_TICK;
54
55#if SIMHPPA_FAST_IDLE
56
57/*
58 * Many of the tests are very slow on the simulator because they have
59 * have 5 second delays hardwired in.
60 * Try to speed those tests up by speeding up the clock when in idle
61 */
62
63rtems_extension
64fast_idle_switch_hook(rtems_tcb *current_task,
65                      rtems_tcb *heir_task)
66{
67    static rtems_unsigned32 normal_clock = ~0;
68    static rtems_unsigned32 fast_clock;
69
70    /* init our params on first call */
71    if (normal_clock == (rtems_unsigned32) ~0)
72    {
73        normal_clock = CPU_HPPA_CLICKS_PER_TICK;
74        fast_clock = CPU_HPPA_CLICKS_PER_TICK / 0x100;
75        if (fast_clock == 0)    /* who? me?  pathological?  never! */
76            fast_clock++;
77    }
78
79    /*
80     * Checking for 'name' field of 'IDLE' is not the best/safest,
81     * but its the best we could think of at the moment.
82     */
83
84    if (heir_task == _Thread_Idle)
85        CPU_HPPA_CLICKS_PER_TICK = fast_clock;
86    else if (current_task == _Thread_Idle)
87        CPU_HPPA_CLICKS_PER_TICK = normal_clock;
88}
89
90#endif
91
92/*
93 *  Function:   bsp_libc_init
94 *  Created:    94/12/6
95 *
96 *  Description:
97 *      Initialize whatever libc we are using
98 *      called from bsp_postdriver_hook
99 *
100 *
101 *  Parameters:
102 *      none
103 *
104 *  Returns:
105 *      none.
106 *
107 *  Side Effects:
108 *
109 *
110 *  Notes:
111 *
112 *  Deficiencies/ToDo:
113 *
114 *
115 */
116
117void
118bsp_libc_init(void)
119{
120    extern int end;
121    rtems_unsigned32        heap_start;
122
123    heap_start = (rtems_unsigned32) &end;
124    if (heap_start & (CPU_ALIGNMENT-1))
125        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
126
127    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
128
129    /*
130     *  Init the RTEMS libio facility to provide UNIX-like system
131     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
132     *  Uses malloc() to get area for the iops, so must be after malloc init
133     */
134
135    rtems_libio_init();
136
137    /*
138     * Set up for the libc handling.
139     * XXX; this should allow for case of some other non-clock interrupts
140     */
141
142    if (BSP_Configuration.ticks_per_timeslice > 0)
143        libc_init(1);                /* reentrant if possible */
144    else
145        libc_init(0);                /* non-reentrant */
146
147    /*
148     * on MP systems, always use the print buffer
149     *  instead of the (broken) system calls
150     */
151
152    if (BSP_Configuration.User_multiprocessing_table)
153        use_print_buffer = 1;
154
155#ifdef SIMHPPA_ROM
156    use_print_buffer = 1;
157#endif
158}
159
160
161/*
162 *  Function:   bsp_pretasking_hook
163 *  Created:    95/03/10
164 *
165 *  Description:
166 *      BSP pretasking hook.  Called just before drivers are initialized.
167 *      Used to setup libc and install any BSP extensions.
168 *
169 *  Parameters:
170 *      none
171 *
172 *  Returns:
173 *      nada
174 *
175 *  Side Effects:
176 *      installs a few extensions
177 *
178 *  Notes:
179 *      Must not use libc (to do io) from here, since drivers are
180 *      not yet initialized.
181 *
182 *  Deficiencies/ToDo:
183 *
184 *
185 */
186
187void
188bsp_pretasking_hook(void)
189{
190    bsp_libc_init();
191
192#if SIMHPPA_FAST_IDLE
193    /*
194     * Install the fast idle task switch extension
195     *
196     * on MP systems, might now want to do this; it confuses at least
197     * one test (mp06)
198     */
199
200#if 0
201    if (BSP_Configuration.User_multiprocessing_table == 0)
202#endif
203    {
204        rtems_extensions_table  fast_idle_extension;
205        rtems_id                extension_id;
206        rtems_status_code       rc;
207
208        memset(&fast_idle_extension, 0, sizeof(fast_idle_extension));
209
210        fast_idle_extension.thread_switch  = fast_idle_switch_hook;
211
212        rc = rtems_extension_create(rtems_build_name('F', 'D', 'L', 'E'),
213                              &fast_idle_extension, &extension_id);
214        if (rc != RTEMS_SUCCESSFUL)
215            rtems_fatal_error_occurred(rc);
216    }
217#endif
218
219
220#ifdef STACK_CHECKER_ON
221    /*
222     *  Initialize the stack bounds checker
223     *  We can either turn it on here or from the app.
224     */
225
226    Stack_check_Initialize();
227#endif
228}
229
230/*
231 *  Use the shared bsp_postdriver_hook() implementation
232 */
233 
234void bsp_postdriver_hook(void);
235
236/*
237 *  Function:   bsp_start
238 *  Created:    94/12/6
239 *
240 *  Description:
241 *      called by crt0 as our "main" equivalent
242 *
243 *
244 *
245 *  Parameters:
246 *
247 *
248 *  Returns:
249 *
250 *
251 *  Side Effects:
252 *
253 *
254 *  Notes:
255 *
256 *
257 *  Deficiencies/ToDo:
258 *
259 *
260 */
261
262void bsp_start(void)
263{
264    /*
265     * Set cpu_number to accurately reflect our cpu number
266     */
267
268#ifdef hppa7200
269    /*
270     * Use HPPA_DR0 if supported
271     */
272    {
273        int dr0;
274        HPPA_ASM_MFCPU(HPPA_DR0, dr0);
275        cpu_number = (dr0 >> 4) & 0x7;
276    }
277#else
278    if (Configuration.User_multiprocessing_table)
279        cpu_number = Configuration.User_multiprocessing_table->node - 1;
280    else
281        cpu_number = 0;
282#endif
283
284    /*
285     *  Copy the table
286     */
287
288    BSP_Configuration = Configuration;
289
290    BSP_Configuration.work_space_start = (void *)MY_WORK_SPACE;
291    if (BSP_Configuration.work_space_size)
292        BSP_Configuration.work_space_size = WORKSPACE_SIZE;
293
294    /*
295     * Set up our hooks
296     * Make sure libc_init is done before drivers init'd so that
297     * they can use atexit()
298     */
299
300    Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
301
302    Cpu_table.predriver_hook = NULL;
303
304    Cpu_table.postdriver_hook = bsp_postdriver_hook;    /* register drivers */
305
306    Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
307
308    /*
309     *  Don't zero out the workspace.  The simulator did it for us.
310     */
311
312    Cpu_table.do_zero_of_workspace = FALSE;
313
314    Cpu_table.interrupt_stack_size = (12 * 1024);
315
316    Cpu_table.extra_mpci_receive_server_stack = 0;
317
318    /*
319     * Set this artificially low for the simulator
320     */
321
322    Cpu_table.itimer_clicks_per_microsecond = 1;
323
324#if 0
325    /*
326     * Commented by DIVISION INC.  External interrupt
327     * processing is now divorced from RTEMS for HPPA.
328     */
329
330    /*
331     * Determine the external interrupt processing order
332     * the external interrupt handler walks thru this table, in
333     * order checking for posted interrupts.
334     */
335
336    Cpu_table.external_interrupts = 0;
337
338    Cpu_table.external_interrupt[ Cpu_table.external_interrupts ] =
339                                   HPPA_INTERRUPT_EXTERNAL_INTERVAL_TIMER;
340    Cpu_table.external_interrupts++;
341
342    if ( Configuration.User_multiprocessing_table ) {
343      Cpu_table.external_interrupt[ Cpu_table.external_interrupts ] =
344                                               HPPA_INTERRUPT_EXTERNAL_10;
345      Cpu_table.external_interrupts++;
346    }
347#endif
348
349#if SIMHPPA_FAST_IDLE
350    /*
351     * Add 1 extension for fast idle
352     */
353
354    BSP_Configuration.maximum_extensions++;
355#endif
356
357    /*
358     * Tell libio how many fd's we want and allow it to tweak config
359     */
360
361    rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
362
363    /*
364     * Add 1 extension for MPCI_fatal
365     */
366
367    if (BSP_Configuration.User_multiprocessing_table)
368        BSP_Configuration.maximum_extensions++;
369
370    /*
371     * Set the "clicks per tick" for the simulator
372     *  used by libcpu/hppa/clock/clock.c to schedule interrupts
373     *
374     * Set it only if 0 to allow for simulator setting it via script
375     *   on test startup.
376     */
377
378    if (CPU_HPPA_CLICKS_PER_TICK == 0)
379        CPU_HPPA_CLICKS_PER_TICK = 0x4000;
380}
Note: See TracBrowser for help on using the repository browser.