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

4.104.114.84.95
Last change on this file since 71f4beb was 9b64c2d5, checked in by Joel Sherrill <joel.sherrill@…>, on 04/15/98 at 00:10:03

Per suggestion from Eric Norum, went from one initial extension set
to multiple. This lets the stack check extension be installed
at system initialization time and avoids the BSP having to
even know about its existence.

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