File: ints.c

package info (click to toggle)
kernel-source-2.0.35 2.0.35-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 32,456 kB
  • ctags: 94,327
  • sloc: ansic: 587,014; asm: 26,388; makefile: 4,055; sh: 1,221; perl: 727; tcl: 408; cpp: 277; lisp: 211; awk: 134
file content (236 lines) | stat: -rw-r--r-- 4,972 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
 * ints.c -- 680x0 Linux general interrupt handling code
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file COPYING in the main directory of this archive
 * for more details.
 *
 * 07/03/96: Timer initialization, and thus mach_sched_init(),
 *           removed from request_irq() and moved to init_time().
 *           We should therefore consider renaming our add_isr() and
 *           remove_isr() to request_irq() and free_irq()
 *           respectively, so they are compliant with the other
 *           architectures.                                     /Jes
 */

#include <linux/types.h>
#include <linux/sched.h>
#include <linux/kernel_stat.h>
#include <linux/errno.h>

#include <asm/system.h>
#include <asm/irq.h>
#include <asm/traps.h>
#include <asm/page.h>
#include <asm/machdep.h>

/* list is accessed 0-6 for IRQs 1-7 */
static isr_node_t *isr_list[7];

/* The number of spurious interrupts */
volatile unsigned long num_spurious;
/*
unsigned long interrupt_stack[PAGE_SIZE/sizeof(long)];
*/

/*
 * void init_IRQ(void)
 *
 * Parameters:	None
 *
 * Returns:	Nothing
 *
 * This function should be called during kernel startup to initialize
 * the IRQ handling routines.
 */

void init_IRQ(void)
{
    /* Setup interrupt stack pointer */
  /*
    asm ("movec %0,%/isp"
	 : : "r" (interrupt_stack + sizeof (interrupt_stack) / sizeof (long)));
	 */
    mach_init_INTS ();
}

void insert_isr (isr_node_t **listp, isr_node_t *node)
{
    unsigned long spl;
    isr_node_t *cur;

    save_flags(spl);
    cli();

    cur = *listp;

    while (cur && cur->pri <= node->pri)
    {
	listp = &cur->next;
	cur = cur->next;
    }

    node->next = cur;
    *listp = node;

    restore_flags(spl);
}

void delete_isr (isr_node_t **listp, isrfunc isr, void *data)
{
    unsigned long flags;
    isr_node_t *np;

    save_flags(flags);
    cli();
    for (np = *listp; np; listp = &np->next, np = *listp) {
	if (np->isr == isr && np->data == data) {
	    *listp = np->next;
	    /* Mark it as free. */
	    np->isr = NULL;
	    restore_flags(flags);
	    return;
	}
    }
    restore_flags(flags);
    printk ("delete_isr: isr %p not found on list!\n", isr);
}

#define NUM_ISR_NODES 100
static isr_node_t nodes[NUM_ISR_NODES];

isr_node_t *new_isr_node(void)
{
    isr_node_t *np;

    for (np = nodes; np < &nodes[NUM_ISR_NODES]; np++)
	if (np->isr == NULL)
	    return np;

    printk ("new_isr_node: out of nodes");
    return NULL;
}

int add_isr (unsigned long source, isrfunc isr, int pri, void *data,
	     char *name)
{
    isr_node_t *p;

    if (source & IRQ_MACHSPEC)
    {
	return mach_add_isr (source, isr, pri, data, name);
    }

    if (source < IRQ1 || source > IRQ7)
	panic ("add_isr: Incorrect IRQ source %ld from %s\n", source, name);

    p = new_isr_node();
    if (p == NULL)
	return 0;
    p->isr = isr;
    p->pri = pri;
    p->data = data;
    p->name = name;
    p->next = NULL;

    insert_isr (&isr_list[source-1], p);

    return 1;
}

int remove_isr (unsigned long source, isrfunc isr, void *data)
{
    if (source & IRQ_MACHSPEC)
	return mach_remove_isr (source, isr, data);

    if (source < IRQ1 || source > IRQ7) {
	printk ("remove_isr: Incorrect IRQ source %ld\n", source);
	return 0;
    }

    delete_isr (&isr_list[source - 1], isr, data);
    return 1;
}

void call_isr_list(int irq, isr_node_t *p, struct pt_regs *fp)
{
    while (p) {
	p->isr (irq, fp, p->data);
	p = p->next;
    }
}

asmlinkage void process_int(int vec, struct pt_regs *regs)
{
	int level;

	if (vec >= VECOFF(VEC_INT1) && vec <= VECOFF(VEC_INT7))
		level = (vec - VECOFF(VEC_SPUR)) >> 2;
	else {
		if (mach_process_int)
			mach_process_int(vec, regs);
		else
			panic("Can't process interrupt vector 0x%03x\n", vec);
		return;
	}

	kstat.interrupts[level]++;  	
	call_isr_list (level, isr_list[level-1], regs);
}

int request_irq(unsigned int irq,
		void (*handler)(int, void *, struct pt_regs *),
		unsigned long flags, const char * devname, void *dev_id)
{
	return -EINVAL;
}

void free_irq(unsigned int irq, void *dev_id)
{
}

/*
 * Do we need these probe functions on the m68k?
 */
unsigned long probe_irq_on (void)
{
  return 0;
}

int probe_irq_off (unsigned long irqs)
{
  return 0;
}

void enable_irq(unsigned int irq_nr)
{
	if ((irq_nr & IRQ_MACHSPEC) && mach_enable_irq)
		mach_enable_irq(irq_nr);
}

void disable_irq(unsigned int irq_nr)
{
	if ((irq_nr & IRQ_MACHSPEC) && mach_disable_irq)
		mach_disable_irq(irq_nr);
}

int get_irq_list(char *buf)
{
    int i, len = 0;
    isr_node_t *p;
    
    /* autovector interrupts */
    for (i = IRQ1; i <= IRQ7; ++i) {
	if (!isr_list[i-1])
	    continue;
	len += sprintf(buf+len, "auto %2d: %8d ", i, kstat.interrupts[i]);
	for (p = isr_list[i-1]; p; p = p->next) {
	    len += sprintf(buf+len, "%s\n", p->name);
	    if (p->next)
		len += sprintf(buf+len, "                  ");
	}
    }

    len = mach_get_irq_list(buf, len);
    return len;
}