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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [m68knommu/] [platform/] [68EN302/] [traps.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 * linux/arch/$(ARCH)/platform/$(PLATFORM)/traps.c -- general exception handling code
3
 *
4
 * Cloned from Linux/m68k.
5
 *
6
 * No original Copyright holder listed,
7
 * Probabily original (C) Roman Zippel (assigned DJD, 1999)
8
 *
9
 * Copyright 1999-2000 D. Jeff Dionne, <jeff@rt-control.com>
10
 *
11
 * This file is subject to the terms and conditions of the GNU General Public
12
 * License.  See the file COPYING in the main directory of this archive
13
 * for more details.
14
 */
15
 
16
#include <linux/types.h>
17
#include <linux/sched.h>
18
#include <linux/kernel_stat.h>
19
#include <linux/errno.h>
20
 
21
#include <asm/system.h>
22
#include <asm/irq.h>
23
#include <asm/traps.h>
24
#include <asm/page.h>
25
#include <asm/machdep.h>
26
 
27
/* table for system interrupt handlers */
28
static irq_handler_t irq_list[SYS_IRQS];
29
 
30
static const char *default_names[SYS_IRQS] = {
31
        "spurious int", "int1 handler", "int2 handler", "int3 handler",
32
        "int4 handler", "int5 handler", "int6 handler", "int7 handler"
33
};
34
 
35
/* The number of spurious interrupts */
36
volatile unsigned int num_spurious;
37
 
38
#define NUM_IRQ_NODES 16
39
static irq_node_t nodes[NUM_IRQ_NODES];
40
 
41
#if defined( CONFIG_M68328 ) || defined ( CONFIG_M68EZ328 )
42
 
43
asm ("
44
        .global _start, _ramend
45
        .section .romvec
46
 
47
e_vectors:
48
        .long _ramend-4, _start, buserr, trap, trap, trap, trap, trap
49
        .long trap, trap, trap, trap, trap, trap, trap, trap
50
        .long trap, trap, trap, trap, trap, trap, trap, trap
51
        .long trap, trap, trap, trap
52
        .long trap, trap, trap, trap
53
        /*.long inthandler, inthandler, inthandler, inthandler
54
        .long inthandler4, inthandler, inthandler, inthandler   */
55
        /* TRAP #0-15 */
56
        .long system_call, trap, trap, trap, trap, trap, trap, trap
57
        .long trap, trap, trap, trap, trap, trap, trap, trap
58
        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
59
        .text
60
 
61
ignore: rte
62
 
63
");
64
#endif /* CONFIG_M68328 || CONFIG_M68EZ328 */
65
 
66
/*
67
 * void init_IRQ(void)
68
 *
69
 * Parameters:  None
70
 *
71
 * Returns:     Nothing
72
 *
73
 * This function should be called during kernel startup to initialize
74
 * the IRQ handling routines.
75
 */
76
 
77
void init_IRQ(void)
78
{
79
        int i;
80
 
81
        for (i = 0; i < SYS_IRQS; i++) {
82
                if (mach_default_handler)
83
                        irq_list[i].handler = (*mach_default_handler)[i];
84
                else
85
                        irq_list[i].handler = NULL;
86
                        irq_list[i].flags   = IRQ_FLG_STD;
87
                        irq_list[i].dev_id  = NULL;
88
                        irq_list[i].devname = default_names[i];
89
        }
90
 
91
        for (i = 0; i < NUM_IRQ_NODES; i++)
92
                nodes[i].handler = NULL;
93
 
94
        mach_init_IRQ ();
95
}
96
 
97
irq_node_t *new_irq_node(void)
98
{
99
        irq_node_t *node;
100
        short i;
101
 
102
        for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
103
                if (!node->handler)
104
                        return node;
105
 
106
        printk ("new_irq_node: out of nodes\n");
107
        return NULL;
108
}
109
 
110
int request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
111
                unsigned long flags, const char *devname, void *dev_id)
112
{
113
        if (irq & IRQ_MACHSPEC)
114
                return mach_request_irq(IRQ_IDX(irq), handler, flags, devname, dev_id);
115
 
116
        if (irq < IRQ1 || irq > IRQ7) {
117
                printk("%s: Incorrect IRQ %d from %s\n", __FUNCTION__, irq, devname);
118
                return -ENXIO;
119
        }
120
 
121
        if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
122
                if (irq_list[irq].flags & IRQ_FLG_LOCK) {
123
                        printk("%s: IRQ %d from %s is not replaceable\n",
124
                               __FUNCTION__, irq, irq_list[irq].devname);
125
                        return -EBUSY;
126
                }
127
                if (flags & IRQ_FLG_REPLACE) {
128
                        printk("%s: %s can't replace IRQ %d from %s\n",
129
                               __FUNCTION__, devname, irq, irq_list[irq].devname);
130
                        return -EBUSY;
131
                }
132
        }
133
        irq_list[irq].handler = handler;
134
        irq_list[irq].flags   = flags;
135
        irq_list[irq].dev_id  = dev_id;
136
        irq_list[irq].devname = devname;
137
        return 0;
138
}
139
 
140
void free_irq(unsigned int irq, void *dev_id)
141
{
142
        if (irq & IRQ_MACHSPEC) {
143
                mach_free_irq(IRQ_IDX(irq), dev_id);
144
                return;
145
        }
146
 
147
        if (irq < IRQ1 || irq > IRQ7) {
148
                printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
149
                return;
150
        }
151
 
152
        if (irq_list[irq].dev_id != dev_id)
153
                printk("%s: Removing probably wrong IRQ %d from %s\n",
154
                       __FUNCTION__, irq, irq_list[irq].devname);
155
 
156
        if (mach_default_handler)
157
                irq_list[irq].handler = (*mach_default_handler)[irq];
158
        else
159
                irq_list[irq].handler = NULL;
160
        irq_list[irq].flags   = IRQ_FLG_STD;
161
        irq_list[irq].dev_id  = NULL;
162
        irq_list[irq].devname = default_names[irq];
163
}
164
 
165
/*
166
 * Do we need these probe functions on the m68k?
167
 */
168
unsigned long probe_irq_on (void)
169
{
170
        return 0;
171
}
172
 
173
int probe_irq_off (unsigned long irqs)
174
{
175
        return 0;
176
}
177
 
178
void enable_irq(unsigned int irq)
179
{
180
        if ((irq & IRQ_MACHSPEC) && mach_enable_irq)
181
                mach_enable_irq(IRQ_IDX(irq));
182
}
183
 
184
void disable_irq(unsigned int irq)
185
{
186
        if ((irq & IRQ_MACHSPEC) && mach_disable_irq)
187
                mach_disable_irq(IRQ_IDX(irq));
188
}
189
 
190
asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
191
{
192
        /* give the machine specific code a crack at it first */
193
        if (mach_process_int)
194
                if (!mach_process_int(vec, fp))
195
                        return;
196
 
197
        if (vec < VEC_SPUR || vec > VEC_INT7)
198
                panic("No interrupt handler for vector %ld\n", vec);
199
 
200
        vec -= VEC_SPUR;
201
        kstat.interrupts[vec]++;
202
        if (irq_list[vec].handler)
203
                irq_list[vec].handler(vec, irq_list[vec].dev_id, fp);
204
        else
205
                panic("No interrupt handler for autovector %ld\n", vec);
206
}
207
 
208
int get_irq_list(char *buf)
209
{
210
        int i, len = 0;
211
 
212
        /* autovector interrupts */
213
        for (i = 0; i < SYS_IRQS; i++) {
214
                if (irq_list[i].handler) {
215
                        len += sprintf(buf+len, "auto %2d: %10u ", i,
216
                                       i ? kstat.interrupts[i] : num_spurious);
217
                        if (irq_list[i].flags & IRQ_FLG_LOCK)
218
                                len += sprintf(buf+len, "L ");
219
                        else
220
                                len += sprintf(buf+len, "  ");
221
                        len += sprintf(buf+len, "%s\n", irq_list[i].devname);
222
                }
223
        }
224
 
225
        if (mach_get_irq_list)
226
                len += mach_get_irq_list(buf+len);
227
        return len;
228
}
229
 
230
/*
231
 *      Generic dumping code. Used for panic and debug.
232
 */
233
 
234
void dump(struct pt_regs *fp)
235
{
236
        unsigned long   *sp;
237
        unsigned char   *tp;
238
        int             i;
239
 
240
        printk("\nCURRENT PROCESS:\n\n");
241
#if 0
242
{
243
        extern int      swt_lastjiffies, swt_reference;
244
        printk("WATCHDOG: jiffies=%d lastjiffies=%d [%d] reference=%d\n",
245
                jiffies, swt_lastjiffies, (swt_lastjiffies - jiffies),
246
                swt_reference);
247
}
248
#endif
249
        printk("COMM=%s PID=%d\n", current->comm, current->pid);
250
        if (current->mm) {
251
                printk("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
252
                        (int) current->mm->start_code,
253
                        (int) current->mm->end_code,
254
                        (int) current->mm->start_data,
255
                        (int) current->mm->end_data,
256
                        (int) current->mm->end_data,
257
                        (int) current->mm->brk);
258
                printk("USER-STACK=%08x  KERNEL-STACK=%08x\n\n",
259
                        (int) current->mm->start_stack,
260
                        (int) current->kernel_stack_page);
261
        }
262
 
263
        printk("PC: %08lx\n", fp->pc);
264
        printk("SR: %08lx    SP: %08lx\n", (long) fp->sr, (long) fp);
265
        printk("d0: %08lx    d1: %08lx    d2: %08lx    d3: %08lx\n",
266
                fp->d0, fp->d1, fp->d2, fp->d3);
267
        printk("d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
268
                fp->d4, fp->d5, fp->a0, fp->a1);
269
        printk("\nUSP: %08x   TRAPFRAME: %08x\n",
270
                rdusp(), (unsigned int) fp);
271
 
272
        printk("\nCODE:");
273
        tp = ((unsigned char *) fp->pc) - 0x20;
274
        for (sp = (unsigned long *) tp, i = 0; (i < 0x40);  i += 4) {
275
                if ((i % 0x10) == 0)
276
                        printk("\n%08x: ", (int) (tp + i));
277
                printk("%08x ", (int) *sp++);
278
        }
279
        printk("\n");
280
 
281
        printk("\nKERNEL STACK:");
282
        tp = ((unsigned char *) fp) - 0x40;
283
        for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
284
                if ((i % 0x10) == 0)
285
                        printk("\n%08x: ", (int) (tp + i));
286
                printk("%08x ", (int) *sp++);
287
        }
288
        printk("\n");
289
        if (STACK_MAGIC != *(unsigned long *)current->kernel_stack_page)
290
                printk("(Possibly corrupted stack page??)\n");
291
        printk("\n");
292
 
293
        printk("\nUSER STACK:");
294
        tp = (unsigned char *) (rdusp() - 0x10);
295
        for (sp = (unsigned long *) tp, i = 0; (i < 0x80); i += 4) {
296
                if ((i % 0x10) == 0)
297
                        printk("\n%08x: ", (int) (tp + i));
298
                printk("%08x ", (int) *sp++);
299
        }
300
        printk("\n\n");
301
}

powered by: WebSVN 2.1.0

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