| 1 | /* | 
|---|
| 2 |  * Copyright (c) 2011 Aeroflex Gaisler | 
|---|
| 3 |  * | 
|---|
| 4 |  * BSD license: | 
|---|
| 5 |  * | 
|---|
| 6 |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
|---|
| 7 |  * of this software and associated documentation files (the "Software"), to deal | 
|---|
| 8 |  * in the Software without restriction, including without limitation the rights | 
|---|
| 9 |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
|---|
| 10 |  * copies of the Software, and to permit persons to whom the Software is | 
|---|
| 11 |  * furnished to do so, subject to the following conditions: | 
|---|
| 12 |  * | 
|---|
| 13 |  * The above copyright notice and this permission notice shall be included in | 
|---|
| 14 |  * all copies or substantial portions of the Software. | 
|---|
| 15 |  * | 
|---|
| 16 |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
|---|
| 17 |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
|---|
| 18 |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 
|---|
| 19 |  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
|---|
| 20 |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
|---|
| 21 |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
|---|
| 22 |  * THE SOFTWARE. | 
|---|
| 23 |  */ | 
|---|
| 24 |  | 
|---|
| 25 |  | 
|---|
| 26 | #ifndef _LEON_CATCHIRQ_HANDLER_H_ | 
|---|
| 27 | #define _LEON_CATCHIRQ_HANDLER_H_ | 
|---|
| 28 |  | 
|---|
| 29 | #include <asm-leon/leon.h> | 
|---|
| 30 | #include <asm-leon/queue.h> | 
|---|
| 31 | /*#include <sys/fsu_pthread_queue.h>*/ | 
|---|
| 32 | #include <asm-leon/leoncompat.h> | 
|---|
| 33 | #include <asm-leon/leonstack.h> | 
|---|
| 34 |  | 
|---|
| 35 | #ifndef __ASSEMBLER__ | 
|---|
| 36 |  | 
|---|
| 37 | struct pt_regs; | 
|---|
| 38 | typedef int (*irqhandler) (int, void *, struct leonbare_pt_regs *); | 
|---|
| 39 |  | 
|---|
| 40 | struct irqaction | 
|---|
| 41 | { | 
|---|
| 42 |   irqhandler handler; | 
|---|
| 43 |   unsigned long flags; | 
|---|
| 44 |   void *dev_id; | 
|---|
| 45 |   struct irqaction *next; | 
|---|
| 46 | }; | 
|---|
| 47 | #define INIT_IRQACTION { 0,0,0,0 } | 
|---|
| 48 |  | 
|---|
| 49 | struct irqmp_type | 
|---|
| 50 | { | 
|---|
| 51 |   int *addr; | 
|---|
| 52 |   int eirq; | 
|---|
| 53 | }; | 
|---|
| 54 |  | 
|---|
| 55 | extern void chained_catch_interrupt (int irq, struct irqaction *a); | 
|---|
| 56 | extern int catch_interrupt (int func, int irq); | 
|---|
| 57 |  | 
|---|
| 58 | typedef int (*schedulehandler) (struct leonbare_pt_regs *); | 
|---|
| 59 | extern schedulehandler schedule_callback; | 
|---|
| 60 | typedef int (*tickerhandler) (struct leonbare_pt_regs *); | 
|---|
| 61 | extern tickerhandler ticker_callback; | 
|---|
| 62 | extern int leonbare_hz; | 
|---|
| 63 | extern int nestcount; | 
|---|
| 64 | extern int no_inirq_check; | 
|---|
| 65 | extern unsigned long force_noalarm; | 
|---|
| 66 |  | 
|---|
| 67 | extern void (*handler_irq_pre) (void); | 
|---|
| 68 | extern void (*handler_irq_post) (void); | 
|---|
| 69 |  | 
|---|
| 70 | extern void leonbare_enable_traps (unsigned long old_flags); | 
|---|
| 71 | extern unsigned long leonbare_disable_traps (); | 
|---|
| 72 | extern void leonbare_flush_windows (); | 
|---|
| 73 |  | 
|---|
| 74 | static inline void | 
|---|
| 75 | leonbare_enable_irq (int irq) | 
|---|
| 76 | { | 
|---|
| 77 |   unsigned int old, irqmask = 1 << irq; | 
|---|
| 78 |   old = leonbare_disable_traps (); | 
|---|
| 79 |   //--------------------- | 
|---|
| 80 |   switch (LEONCOMPAT_VERSION) | 
|---|
| 81 |     { | 
|---|
| 82 |     case 3: | 
|---|
| 83 |     default: | 
|---|
| 84 |       LEON3_IrqCtrl_Regs->mask[0] = LEON3_IrqCtrl_Regs->mask[0] | irqmask; | 
|---|
| 85 |       break; | 
|---|
| 86 |     } | 
|---|
| 87 |   //--------------------- | 
|---|
| 88 |   leonbare_enable_traps (old); | 
|---|
| 89 | } | 
|---|
| 90 |  | 
|---|
| 91 | typedef int (*pendinghandler) (void *); | 
|---|
| 92 | struct pendingaction | 
|---|
| 93 | { | 
|---|
| 94 |   TAILQ_ENTRY (pendingaction) next; | 
|---|
| 95 |   pendinghandler handler; | 
|---|
| 96 |   void *arg; | 
|---|
| 97 | }; | 
|---|
| 98 |  | 
|---|
| 99 | #endif | 
|---|
| 100 |  | 
|---|
| 101 | #endif | 
|---|