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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [m68knommu/] [platform/] [5206e/] [ints.c] - Blame information for rev 1781

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 * linux/arch/m68knommu/platform/5206e/ints.c -- General interrupt handling code
3
 *
4
 * Copyright (C) 1999  Greg Ungerer (gerg@moreton.com.au)
5
 * Copyright (C) 1998  D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>,
6
 *                     Kenneth Albanowski <kjahds@kjahds.com>,
7
 *                     The Silver Hammer Group, Ltd.
8
 *
9
 * Based on:
10
 *
11
 * linux/arch/m68k/kernel/ints.c -- Linux/m68k general interrupt handling code
12
 *
13
 * This file is subject to the terms and conditions of the GNU General Public
14
 * License.  See the file COPYING in the main directory of this archive
15
 * for more details.
16
 */
17
 
18
#include <linux/types.h>
19
#include <linux/sched.h>
20
#include <linux/kernel_stat.h>
21
#include <linux/errno.h>
22
#include <linux/config.h>
23
 
24
#include <asm/system.h>
25
#include <asm/irq.h>
26
#include <asm/traps.h>
27
#include <asm/page.h>
28
#include <asm/machdep.h>
29
 
30
/*
31
 *      This table stores the address info for each vector handler.
32
 */
33
irq_handler_t vec_list[SYS_IRQS];
34
 
35
unsigned int *irq_kstat_interrupt;
36
 
37
/* The number of spurious interrupts */
38
volatile unsigned int num_spurious;
39
 
40
 
41
static void default_irq_handler(int irq, void *ptr, struct pt_regs *regs)
42
{
43
#if 1
44
        printk("%s(%d): default irq handler vec=%d [%d]\n",
45
                __FILE__, __LINE__, (irq / 4), irq);
46
#endif
47
}
48
 
49
/*
50
 * void init_IRQ(void)
51
 *
52
 * Parameters:  None
53
 *
54
 * Returns:     Nothing
55
 *
56
 * This function should be called during kernel startup to initialize
57
 * the IRQ handling routines.
58
 */
59
 
60
void init_IRQ(void)
61
{
62
        int i;
63
 
64
 
65
        for (i = 0; i < SYS_IRQS; i++) {
66
                if (mach_default_handler)
67
                        vec_list[i].handler = (*mach_default_handler)[i];
68
                else
69
                        vec_list[i].handler = default_irq_handler;
70
                vec_list[i].flags   = IRQ_FLG_STD;
71
                vec_list[i].dev_id  = NULL;
72
                vec_list[i].devname = NULL;
73
        }
74
 
75
        if (mach_init_IRQ)
76
                mach_init_IRQ ();
77
 
78
        irq_kstat_interrupt = &kstat.interrupts[0];
79
}
80
 
81
int request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
82
                unsigned long flags, const char *devname, void *dev_id)
83
{
84
        if ((irq & IRQ_MACHSPEC) && mach_request_irq) {
85
                return mach_request_irq(IRQ_IDX(irq), handler, flags,
86
                        devname, dev_id);
87
        }
88
 
89
        if (irq < 0 || irq >= NR_IRQS) {
90
                printk("%s: Incorrect IRQ %d from %s\n", __FUNCTION__,
91
                        irq, devname);
92
                return -ENXIO;
93
        }
94
 
95
        if (!(vec_list[irq].flags & IRQ_FLG_STD)) {
96
                if (vec_list[irq].flags & IRQ_FLG_LOCK) {
97
                        printk("%s: IRQ %d from %s is not replaceable\n",
98
                               __FUNCTION__, irq, vec_list[irq].devname);
99
                        return -EBUSY;
100
                }
101
                if (flags & IRQ_FLG_REPLACE) {
102
                        printk("%s: %s can't replace IRQ %d from %s\n",
103
                               __FUNCTION__, devname, irq, vec_list[irq].devname);
104
                        return -EBUSY;
105
                }
106
        }
107
 
108
        if (flags & IRQ_FLG_FAST) {
109
                extern asmlinkage void fasthandler(void);
110
                extern void set_evector(int vecnum, void (*handler)(void));
111
                set_evector(irq, fasthandler);
112
        }
113
 
114
        vec_list[irq].handler = handler;
115
        vec_list[irq].flags   = flags;
116
        vec_list[irq].dev_id  = dev_id;
117
        vec_list[irq].devname = devname;
118
        return 0;
119
}
120
 
121
void free_irq(unsigned int irq, void *dev_id)
122
{
123
        if (irq & IRQ_MACHSPEC) {
124
                mach_free_irq(IRQ_IDX(irq), dev_id);
125
                return;
126
        }
127
 
128
        if (irq < 0 || irq >= NR_IRQS) {
129
                printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
130
                return;
131
        }
132
 
133
        if (vec_list[irq].dev_id != dev_id)
134
                printk("%s: Removing probably wrong IRQ %d from %s\n",
135
                       __FUNCTION__, irq, vec_list[irq].devname);
136
 
137
        if (vec_list[irq].flags & IRQ_FLG_FAST) {
138
                extern asmlinkage void intrhandler(void);
139
                extern void set_evector(int vecnum, void (*handler)(void));
140
                set_evector(irq, intrhandler);
141
        }
142
 
143
        if (mach_default_handler)
144
                vec_list[irq].handler = (*mach_default_handler)[irq];
145
        else
146
                vec_list[irq].handler = default_irq_handler;
147
        vec_list[irq].flags   = IRQ_FLG_STD;
148
        vec_list[irq].dev_id  = NULL;
149
        vec_list[irq].devname = NULL;
150
}
151
 
152
int get_irq_list(char *buf)
153
{
154
        int i, len = 0;
155
 
156
        for (i = 0; i < NR_IRQS; i++) {
157
                if (vec_list[i].flags & IRQ_FLG_STD)
158
                        continue;
159
 
160
                len += sprintf(buf+len, "%3d: %10u ", i,
161
                               i ? kstat.interrupts[i] : num_spurious);
162
                if (vec_list[i].flags & IRQ_FLG_LOCK)
163
                        len += sprintf(buf+len, "L ");
164
                else
165
                        len += sprintf(buf+len, "  ");
166
                len += sprintf(buf+len, "%s\n", vec_list[i].devname);
167
        }
168
 
169
        if (mach_get_irq_list)
170
                len += mach_get_irq_list(buf+len);
171
        return len;
172
}

powered by: WebSVN 2.1.0

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