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

Subversion Repositories openrisc_me

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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