source: rtems/cpukit/score/cpu/hppa1.1/cpu.c @ 8bdcfc4

4.104.114.84.95
Last change on this file since 8bdcfc4 was ca201c9, checked in by Joel Sherrill <joel.sherrill@…>, on 12/05/95 at 15:28:12

minor changes so it would compile

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