* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-2.3.21 / arch / m68k / mvme147 / 147ints.c
blob3121ad94fd5f7e1c4fb1b303347545a8b41f13d4
1 /*
2 * arch/m68k/mvme147/147ints.c
4 * Copyright (C) 1997 Richard Hirst [richard@sleepie.demon.co.uk]
6 * based on amiints.c -- Amiga Linux interrupt handling code
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file README.legal in the main directory of this archive
10 * for more details.
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/errno.h>
18 #include <asm/ptrace.h>
19 #include <asm/system.h>
20 #include <asm/irq.h>
21 #include <asm/traps.h>
23 static void mvme147_defhand (int irq, void *dev_id, struct pt_regs *fp);
26 * This should ideally be 4 elements only, for speed.
29 static struct {
30 void (*handler)(int, void *, struct pt_regs *);
31 unsigned long flags;
32 void *dev_id;
33 const char *devname;
34 unsigned count;
35 } irq_tab[256];
38 * void mvme147_init_IRQ (void)
40 * Parameters: None
42 * Returns: Nothing
44 * This function is called during kernel startup to initialize
45 * the mvme147 IRQ handling routines.
48 void mvme147_init_IRQ (void)
50 int i;
52 for (i = 0; i < 256; i++) {
53 irq_tab[i].handler = mvme147_defhand;
54 irq_tab[i].flags = IRQ_FLG_STD;
55 irq_tab[i].dev_id = NULL;
56 irq_tab[i].devname = NULL;
57 irq_tab[i].count = 0;
61 int mvme147_request_irq(unsigned int irq,
62 void (*handler)(int, void *, struct pt_regs *),
63 unsigned long flags, const char *devname, void *dev_id)
65 if (irq > 255) {
66 printk("%s: Incorrect IRQ %d from %s\n", __FUNCTION__, irq, devname);
67 return -ENXIO;
69 if (!(irq_tab[irq].flags & IRQ_FLG_STD)) {
70 if (irq_tab[irq].flags & IRQ_FLG_LOCK) {
71 printk("%s: IRQ %d from %s is not replaceable\n",
72 __FUNCTION__, irq, irq_tab[irq].devname);
73 return -EBUSY;
75 if (flags & IRQ_FLG_REPLACE) {
76 printk("%s: %s can't replace IRQ %d from %s\n",
77 __FUNCTION__, devname, irq, irq_tab[irq].devname);
78 return -EBUSY;
81 irq_tab[irq].handler = handler;
82 irq_tab[irq].flags = flags;
83 irq_tab[irq].dev_id = dev_id;
84 irq_tab[irq].devname = devname;
85 return 0;
88 void mvme147_free_irq(unsigned int irq, void *dev_id)
90 if (irq > 255) {
91 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
92 return;
94 if (irq_tab[irq].dev_id != dev_id)
95 printk("%s: Removing probably wrong IRQ %d from %s\n",
96 __FUNCTION__, irq, irq_tab[irq].devname);
98 irq_tab[irq].handler = mvme147_defhand;
99 irq_tab[irq].flags = IRQ_FLG_STD;
100 irq_tab[irq].dev_id = NULL;
101 irq_tab[irq].devname = NULL;
104 void mvme147_process_int (unsigned long vec, struct pt_regs *fp)
106 if (vec > 255)
107 printk ("mvme147_process_int: Illegal vector %ld\n", vec);
108 else
110 irq_tab[vec].count++;
111 irq_tab[vec].handler(vec, irq_tab[vec].dev_id, fp);
115 int mvme147_get_irq_list (char *buf)
117 int i, len = 0;
119 for (i = 0; i < 256; i++) {
120 if (irq_tab[i].count)
121 len += sprintf (buf+len, "Vec 0x%02x: %8d %s\n",
122 i, irq_tab[i].count,
123 irq_tab[i].devname ? irq_tab[i].devname : "free");
125 return len;
129 static void mvme147_defhand (int irq, void *dev_id, struct pt_regs *fp)
131 printk ("Unknown interrupt 0x%02x\n", irq);
134 void mvme147_enable_irq (unsigned int irq)
139 void mvme147_disable_irq (unsigned int irq)