source: rtems/c/src/exec/score/cpu/hppa1.1/cpu.c @ da6375b

4.104.114.84.95
Last change on this file since da6375b was da6375b, checked in by Joel Sherrill <joel.sherrill@…>, on 08/22/95 at 16:03:46

fix broken RCS Ids -- $ accidentally lost merging changes earlier

  • Property mode set to 100644
File size: 8.2 KB
Line 
1/*
2 *  HP PA-RISC Dependent Source
3 *
4 *  COPYRIGHT (c) 1994 by Division Incorporated
5 *
6 *  To anyone who acknowledges that this file is provided "AS IS"
7 *  without any express or implied warranty:
8 *      permission to use, copy, modify, and distribute this file
9 *      for any purpose is hereby granted without fee, provided that
10 *      the above copyright notice and this notice appears in all
11 *      copies, and that the name of Division Incorporated not be
12 *      used in advertising or publicity pertaining to distribution
13 *      of the software without specific, written prior permission.
14 *      Division Incorporated makes no representations about the
15 *      suitability of this software for any purpose.
16 *
17 *  $Id$
18 */
19
20#include <rtems/system.h>
21#include <rtems/fatal.h>
22#include <rtems/isr.h>
23#include <rtems/intr.h>
24#include <rtems/wkspace.h>
25
26rtems_status_code hppa_external_interrupt_initialize(void);
27void hppa_external_interrupt_enable(unsigned32);
28void hppa_external_interrupt_disable(unsigned32);
29void hppa_external_interrupt(unsigned32, CPU_Interrupt_frame *);
30
31/*
32 * Our interrupt handlers take a 2nd argument:
33 *   a pointer to a CPU_Interrupt_frame
34 * So we use our own prototype instead of rtems_isr_entry
35 */
36
37typedef rtems_isr ( *hppa_rtems_isr_entry )(
38    rtems_vector_number,
39    CPU_Interrupt_frame *
40 );
41
42
43/*
44 * who are we?  cpu number
45 * Not used by executive proper, just kept (or not) as a convenience
46 * for libcpu and libbsp stuff that wants it.
47 *
48 * Defaults to 0.  If the BSP doesn't like it, it can change it.
49 */
50
51int cpu_number;                 /* from 0; cpu number in a multi cpu system */
52
53
54/*  _CPU_Initialize
55 *
56 *  This routine performs processor dependent initialization.
57 *
58 *  INPUT PARAMETERS:
59 *    cpu_table       - CPU table to initialize
60 *    thread_dispatch - address of disptaching routine
61 *
62 */
63
64void _CPU_Initialize(
65  rtems_cpu_table  *cpu_table,
66  void      (*thread_dispatch)      /* ignored on this CPU */
67)
68{
69    register unsigned8  *fp_context;
70    unsigned32 iva;
71    unsigned32 iva_table;
72    int i;
73
74    extern void IVA_Table(void);
75
76    if ( cpu_table == NULL )
77        rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED );
78
79    /*
80     * XXX; need to setup fpsr smarter perhaps
81     */
82
83    fp_context = (unsigned8*) &_CPU_Null_fp_context;
84    for (i=0 ; i<sizeof(Context_Control_fp); i++)
85        *fp_context++ = 0;
86
87    /*
88     *  Set _CPU_Default_gr27 here so it will hopefully be the correct
89     *  global data pointer for the entire system.
90     */
91
92    asm volatile( "stw   %%r27,%0" : "=m" (_CPU_Default_gr27): );
93
94    /*
95     * Stabilize the interrupt stuff
96     */
97
98    (void) hppa_external_interrupt_initialize();
99
100    /*
101     * Set the IVA to point to physical address of the IVA_Table
102     */
103
104    iva_table = (unsigned32) IVA_Table;
105    HPPA_ASM_LPA(0, iva_table, iva);
106    set_iva(iva);
107
108    _CPU_Table = *cpu_table;
109}
110
111/*PAGE
112 *
113 *  _CPU_ISR_install_raw_handler
114 */
115 
116void _CPU_ISR_install_raw_handler(
117  unsigned32  vector,
118  proc_ptr    new_handler,
119  proc_ptr   *old_handler
120)
121{
122  /*
123   *  This is unsupported.
124   */
125
126  _CPU_Fatal_halt( 0xdeaddead );
127}
128
129/*PAGE
130 *
131 *  _CPU_ISR_install_vector
132 *
133 *  This kernel routine installs the RTEMS handler for the
134 *  specified vector.
135 *
136 *  Input parameters:
137 *    vector      - interrupt vector number
138 *    old_handler - former ISR for this vector number
139 *    new_handler - replacement ISR for this vector number
140 *
141 *  Output parameters:  NONE
142 *
143 */
144
145/*
146 * HPPA has 8w for each vector instead of an address to jump to.
147 * We put the actual ISR address in '_ISR_vector_table'.  This will
148 * be pulled by the code in the vector.
149 */
150
151void _CPU_ISR_install_vector(
152  unsigned32  vector,
153  proc_ptr    new_handler,
154  proc_ptr   *old_handler
155)
156{
157    *old_handler = _ISR_Vector_table[vector];
158
159    _ISR_Vector_table[vector] = new_handler;
160
161    if (vector >= HPPA_INTERRUPT_EXTERNAL_BASE)
162    {
163        unsigned32 external_vector;
164
165        external_vector = vector - HPPA_INTERRUPT_EXTERNAL_BASE;
166        if (new_handler)
167            hppa_external_interrupt_enable(external_vector);
168        else
169            /* XXX this can never happen due to _ISR_Is_valid_user_handler */
170            hppa_external_interrupt_disable(external_vector);
171    }
172}
173
174
175/*
176 * Support for external and spurious interrupts on HPPA
177 *
178 *  TODO:
179 *    delete interrupt.c etc.
180 *    Count interrupts
181 *    make sure interrupts disabled properly
182 *    should handler check again for more interrupts before exit?
183 *    How to enable interrupts from an interrupt handler?
184 *    Make sure there is an entry for everything in ISR_Vector_Table
185 */
186
187#define DISMISS(mask)           set_eirr(mask)
188#define DISABLE(mask)           set_eiem(get_eiem() & ~(mask))
189#define ENABLE(mask)            set_eiem(get_eiem() | (mask))
190#define VECTOR_TO_MASK(v)       (1 << (31 - (v)))
191
192/*
193 * Init the external interrupt scheme
194 * called by bsp_start()
195 */
196
197rtems_status_code
198hppa_external_interrupt_initialize(void)
199{
200    rtems_isr_entry ignore;
201
202    /* mark them all unused */
203
204    DISABLE(~0);
205    DISMISS(~0);
206
207    /* install the external interrupt handler */
208    rtems_interrupt_catch((rtems_isr_entry) hppa_external_interrupt,
209                          HPPA_INTERRUPT_EXTERNAL_INTERRUPT, &ignore) ;
210
211    return RTEMS_SUCCESSFUL;
212}
213
214/*
215 * Enable a specific external interrupt
216 */
217
218void
219hppa_external_interrupt_enable(unsigned32 v)
220{
221    unsigned32 isrlevel;
222
223    _CPU_ISR_Disable(isrlevel);
224    ENABLE(VECTOR_TO_MASK(v));
225    _CPU_ISR_Enable(isrlevel);
226}
227
228/*
229 * Does not clear or otherwise affect any pending requests
230 */
231
232void
233hppa_external_interrupt_disable(unsigned32 v)
234{
235    unsigned32 isrlevel;
236
237    _CPU_ISR_Disable(isrlevel);
238    DISABLE(VECTOR_TO_MASK(v));
239    _CPU_ISR_Enable(isrlevel);
240}
241
242void
243hppa_external_interrupt_spurious_handler(unsigned32           vector,
244                                         CPU_Interrupt_frame *iframe)
245{
246/* XXX should not be printing :)
247    printf("spurious external interrupt: %d at pc 0x%x; disabling\n",
248       vector, iframe->Interrupt.pcoqfront);
249*/
250    DISMISS(VECTOR_TO_MASK(vector));
251    DISABLE(VECTOR_TO_MASK(vector));
252}
253
254void
255hppa_external_interrupt_report_spurious(unsigned32           spurious,
256                                        CPU_Interrupt_frame *iframe)
257{
258    int v;
259    for (v=0; v < HPPA_EXTERNAL_INTERRUPTS; v++)
260        if (VECTOR_TO_MASK(v) & spurious)
261            hppa_external_interrupt_spurious_handler(v, iframe);
262    DISMISS(spurious);
263}
264
265
266/*
267 * External interrupt handler.
268 * This is installed as cpu interrupt handler for
269 * HPPA_INTERRUPT_EXTERNAL_INTERRUPT. It vectors out to
270 * specific external interrupt handlers.
271 */
272
273void
274hppa_external_interrupt(unsigned32           vector,
275                        CPU_Interrupt_frame *iframe)
276{
277    unsigned32   mask;
278    unsigned32  *vp, *max_vp;
279    unsigned32   external_vector;
280    unsigned32   global_vector;
281    hppa_rtems_isr_entry handler;
282
283    max_vp = &_CPU_Table.external_interrupt[_CPU_Table.external_interrupts];
284    while ( (mask = (get_eirr() & get_eiem())) )
285    {
286        for (vp = _CPU_Table.external_interrupt; (vp < max_vp) && mask; vp++)
287        {
288            unsigned32 m;
289
290            external_vector = *vp;
291            global_vector = external_vector + HPPA_INTERRUPT_EXTERNAL_BASE;
292            m = VECTOR_TO_MASK(external_vector);
293            handler = (hppa_rtems_isr_entry) _ISR_Vector_table[global_vector];
294            if ((m & mask) && handler)
295            {
296                DISMISS(m);
297                mask &= ~m;
298                (*handler)(global_vector, iframe);
299            }
300        }
301
302        if (mask != 0) {
303            if ( _CPU_Table.spurious_handler )
304              (*((hppa_rtems_isr_entry) _CPU_Table.spurious_handler))(
305                  mask,
306                  iframe
307                );
308            else
309              hppa_external_interrupt_report_spurious(mask, iframe);
310        }
311    }
312}
313
314/*
315 * Halt the system.
316 * Called by the _CPU_Fatal_halt macro
317 *
318 * XXX
319 * Later on, this will allow us to return to the prom.
320 * For now, we just ignore 'type_of_halt'
321 */
322
323void
324hppa_cpu_halt(unsigned32 type_of_halt,
325              unsigned32 the_error)
326{
327    unsigned32 isrlevel;
328
329    _CPU_ISR_Disable(isrlevel);
330
331    asm volatile( "copy %0,%%r1" : : "r" (the_error) );
332    HPPA_ASM_BREAK(1, 0);
333}
Note: See TracBrowser for help on using the repository browser.