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

4.104.114.84.95
Last change on this file since 5b272d1 was eba2e4f, checked in by Joel Sherrill <joel.sherrill@…>, on 11/01/00 at 21:19:23

2000-11-01 Joel Sherrill <joel@…>

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