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

4.104.114.84.95
Last change on this file since bd9c3d1 was bd9c3d1, checked in by Joel Sherrill <joel.sherrill@…>, on 04/15/98 at 20:50:31

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.4 KB
Line 
1/*
2 *  This routine 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 this routine is 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 *  $Id$
16 */
17
18#include <rtems.h>
19#include <bsp.h>
20#include <rtems/libio.h>
21
22#include <libcsupport.h>
23
24#include <string.h>
25
26extern rtems_configuration_table  Configuration;
27
28rtems_configuration_table BSP_Configuration;
29rtems_cpu_table           Cpu_table;
30
31int cpu_number;
32
33#define WORKSPACE_SIZE (1024 * 1024)
34rtems_unsigned8   MY_WORK_SPACE[ WORKSPACE_SIZE ];
35
36/*
37 * Amount to increment itimer by each pass
38 * It is a variable instead of a #define to allow the 'looptest'
39 * script to bump it without recompiling rtems
40 */
41
42rtems_unsigned32 CPU_HPPA_CLICKS_PER_TICK;
43
44#if SIMHPPA_FAST_IDLE
45
46/*
47 * Many of the tests are very slow on the simulator because they have
48 * have 5 second delays hardwired in.
49 * Try to speed those tests up by speeding up the clock when in idle
50 */
51
52rtems_extension fast_idle_switch_hook(
53  rtems_tcb *current_task,
54  rtems_tcb *heir_task
55)
56{
57    static rtems_unsigned32 normal_clock = ~0;
58    static rtems_unsigned32 fast_clock;
59
60    /* init our params on first call */
61    if (normal_clock == (rtems_unsigned32) ~0)
62    {
63        normal_clock = CPU_HPPA_CLICKS_PER_TICK;
64        fast_clock = CPU_HPPA_CLICKS_PER_TICK / 0x100;
65        if (fast_clock == 0)    /* who? me?  pathological?  never! */
66            fast_clock++;
67    }
68
69    /*
70     * Checking for 'name' field of 'IDLE' is not the best/safest,
71     * but its the best we could think of at the moment.
72     */
73
74    if (heir_task == _Thread_Idle)
75        CPU_HPPA_CLICKS_PER_TICK = fast_clock;
76    else if (current_task == _Thread_Idle)
77        CPU_HPPA_CLICKS_PER_TICK = normal_clock;
78}
79
80#endif
81
82/*
83 *  Use the shared implementations of the following routines
84 */
85 
86void bsp_postdriver_hook(void);
87void bsp_libc_init( void *, unsigned32, int );
88
89/*
90 *  Function:   bsp_pretasking_hook
91 *  Created:    95/03/10
92 *
93 *  Description:
94 *      BSP pretasking hook.  Called just before drivers are initialized.
95 *      Used to setup libc and install any BSP extensions.
96 *
97 *  Notes:
98 *      Must not use libc (to do io) from here, since drivers are
99 *      not yet initialized.
100 */
101
102void bsp_pretasking_hook(void)
103{
104    extern int end;
105    rtems_unsigned32        heap_start;
106
107    heap_start = (rtems_unsigned32) &end;
108    if (heap_start & (CPU_ALIGNMENT-1))
109        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
110
111    bsp_libc_init((void *) heap_start, 64 * 1024, 0);
112
113    /*
114     * on MP systems, always use the print buffer
115     *  instead of the (broken) system calls
116     */
117
118    if (BSP_Configuration.User_multiprocessing_table)
119        use_print_buffer = 1;
120
121#ifdef SIMHPPA_ROM
122    use_print_buffer = 1;
123#endif
124
125#if SIMHPPA_FAST_IDLE
126    /*
127     * Install the fast idle task switch extension
128     *
129     * on MP systems, might now want to do this; it confuses at least
130     * one test (mp06)
131     */
132
133#if 0
134    if (BSP_Configuration.User_multiprocessing_table == 0)
135#endif
136    {
137        rtems_extensions_table  fast_idle_extension;
138        rtems_id                extension_id;
139        rtems_status_code       rc;
140
141        memset(&fast_idle_extension, 0, sizeof(fast_idle_extension));
142
143        fast_idle_extension.thread_switch  = fast_idle_switch_hook;
144
145        rc = rtems_extension_create(rtems_build_name('F', 'D', 'L', 'E'),
146                              &fast_idle_extension, &extension_id);
147        if (rc != RTEMS_SUCCESSFUL)
148            rtems_fatal_error_occurred(rc);
149    }
150#endif
151}
152
153void bsp_start(void)
154{
155    /*
156     * Set cpu_number to accurately reflect our cpu number
157     */
158
159#ifdef hppa7200
160    /*
161     * Use HPPA_DR0 if supported
162     */
163    {
164        int dr0;
165        HPPA_ASM_MFCPU(HPPA_DR0, dr0);
166        cpu_number = (dr0 >> 4) & 0x7;
167    }
168#else
169    if (Configuration.User_multiprocessing_table)
170        cpu_number = Configuration.User_multiprocessing_table->node - 1;
171    else
172        cpu_number = 0;
173#endif
174
175    BSP_Configuration.work_space_start = (void *)MY_WORK_SPACE;
176    if (BSP_Configuration.work_space_size)
177        BSP_Configuration.work_space_size = WORKSPACE_SIZE;
178
179    /*
180     * Set up our hooks
181     * Make sure libc_init is done before drivers init'd 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;    /* register drivers */
187
188    /*
189     *  Don't zero out the workspace.  The simulator did it for us.
190     */
191
192    Cpu_table.do_zero_of_workspace = FALSE;
193    Cpu_table.interrupt_stack_size = (12 * 1024);
194
195    /*
196     * Set this artificially low for the simulator
197     */
198
199    Cpu_table.itimer_clicks_per_microsecond = 1;
200
201#if 0
202    /*
203     * Commented by DIVISION INC.  External interrupt
204     * processing is now divorced from RTEMS for HPPA.
205     */
206
207    /*
208     * Determine the external interrupt processing order
209     * the external interrupt handler walks thru this table, in
210     * order checking for posted interrupts.
211     */
212
213    Cpu_table.external_interrupts = 0;
214
215    Cpu_table.external_interrupt[ Cpu_table.external_interrupts ] =
216                                   HPPA_INTERRUPT_EXTERNAL_INTERVAL_TIMER;
217    Cpu_table.external_interrupts++;
218
219    if ( Configuration.User_multiprocessing_table ) {
220      Cpu_table.external_interrupt[ Cpu_table.external_interrupts ] =
221                                               HPPA_INTERRUPT_EXTERNAL_10;
222      Cpu_table.external_interrupts++;
223    }
224#endif
225
226#if SIMHPPA_FAST_IDLE
227    /*
228     * Add 1 extension for fast idle
229     */
230
231    BSP_Configuration.maximum_extensions++;
232#endif
233
234    /*
235     * Add 1 extension for MPCI_fatal
236     */
237
238    if (BSP_Configuration.User_multiprocessing_table)
239        BSP_Configuration.maximum_extensions++;
240
241    /*
242     * Set the "clicks per tick" for the simulator
243     *  used by libcpu/hppa/clock/clock.c to schedule interrupts
244     *
245     * Set it only if 0 to allow for simulator setting it via script
246     *   on test startup.
247     */
248
249    if (CPU_HPPA_CLICKS_PER_TICK == 0)
250        CPU_HPPA_CLICKS_PER_TICK = 0x4000;
251}
Note: See TracBrowser for help on using the repository browser.