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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [or32/] [kernel/] [traps.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1624 jcastillo
/*
2
 *  linux/arch/m68knommu/kernel/traps.c
3
 *
4
 *  Copyright (C) 1998  D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>,
5
 *                      Kenneth Albanowski <kjahds@kjahds.com>
6
 *                      The Silver Hammer Group, Ltd.
7
 *
8
 *  (Blame me for the icky bits -- kja)
9
 *
10
 *  Based on:
11
 *
12
 *  linux/arch/m68k/kernel/traps.c
13
 *
14
 *  Copyright (C) 1993, 1994 by Hamish Macdonald
15
 *
16
 *  68040 fixes by Michael Rausch
17
 *  68040 fixes by Martin Apel
18
 *  68060 fixes by Roman Hodek
19
 *  68060 fixes by Jesper Skov
20
 *
21
 * This file is subject to the terms and conditions of the GNU General Public
22
 * License.  See the file COPYING in the main directory of this archive
23
 * for more details.
24
 *
25
 *  Feb/1999 - Greg Ungerer (gerg@moreton.com.au) changes to support ColdFire.
26
 */
27
 
28
/*
29
 * Sets up all exception vectors
30
 */
31
 
32
#include <linux/config.h>
33
#include <linux/sched.h>
34
#include <linux/signal.h>
35
#include <linux/kernel.h>
36
#include <linux/mm.h>
37
#include <linux/types.h>
38
#include <linux/a.out.h>
39
#include <linux/user.h>
40
#include <linux/string.h>
41
#include <linux/linkage.h>
42
 
43
#include <asm/system.h>
44
#include <asm/segment.h>
45
#include <asm/traps.h>
46
#include <asm/pgtable.h>
47
#include <asm/machdep.h>
48
 
49
 
50
void trap_init (void)
51
{
52
        if (mach_trap_init)
53
                mach_trap_init();
54
}
55
 
56
static inline void console_verbose(void)
57
{
58
        extern int console_loglevel;
59
        console_loglevel = 15;
60
        if (mach_debug_init)
61
                mach_debug_init();
62
}
63
 
64
 
65
extern void die_if_kernel(char *,struct pt_regs *,int);
66
asmlinkage void trap_c(int vector, struct frame *fp);
67
 
68
asmlinkage void buserr_c(struct frame *fp)
69
{
70
#if 1
71
        extern void dump(struct pt_regs *fp);
72
        printk("%s(%d): BUSS ERROR TRAP\n", __FILE__, __LINE__);
73
        dump((struct pt_regs *) fp);
74
#endif
75
 
76
        /* Only set esp0 if coming from user mode */
77
        if (user_mode(&fp->ptregs)) {
78
                current->tss.esp0 = (unsigned long) fp;
79
        } else {
80
                die_if_kernel("Kernel mode BUS error",(struct pt_regs *)fp,0);
81
        }
82
 
83
        /* insert handler here */
84
        force_sig(SIGSEGV, current);
85
}
86
 
87
 
88
static int bad_super_trap_count = 0;
89
 
90
void bad_super_trap (int vector, struct frame *fp)
91
{
92
  extern void dump(struct pt_regs *fp);
93
 
94
  if (bad_super_trap_count++) {
95
    while(1);
96
  }
97
 
98
  printk ("KERNEL: Bad trap from supervisor state, vector=%d\n", vector);
99
  dump((struct pt_regs *) fp);
100
  panic ("Trap from supervisor state");
101
}
102
 
103
asmlinkage void trap_c(int vector, struct frame *fp)
104
{
105
        int sig;
106
#if 0
107
        if ((fp->ptregs.sr & PS_S)
108
            && ((fp->ptregs.vector) >> 2) == VEC_TRACE
109
            && !(fp->ptregs.sr & PS_T)) {
110
                /* traced a trapping instruction */
111
                unsigned char *lp = ((unsigned char *)&fp->un.fmt2) + 4;
112
                current->flags |= PF_DTRACE;
113
                /* clear the trace bit */
114
                (*(unsigned short *)lp) &= ~PS_T;
115
                return;
116
        } else if (fp->ptregs.sr & PS_S) {
117
                bad_super_trap(vector, fp);
118
                return;
119
        }
120
 
121
        /* send the appropriate signal to the user program */
122
        switch (vector) {
123
            case VEC_ADDRERR:
124
                sig = SIGBUS;
125
                break;
126
            case VEC_BUSERR:
127
                sig = SIGSEGV;
128
                break;
129
            case VEC_ILLEGAL:
130
            case VEC_PRIV:
131
            case VEC_LINE10:
132
            case VEC_LINE11:
133
            case VEC_COPROC:
134
            case VEC_TRAP2:
135
            case VEC_TRAP3:
136
            case VEC_TRAP4:
137
            case VEC_TRAP5:
138
            case VEC_TRAP6:
139
            case VEC_TRAP7:
140
            case VEC_TRAP8:
141
            case VEC_TRAP9:
142
            case VEC_TRAP10:
143
            case VEC_TRAP11:
144
            case VEC_TRAP12:
145
            case VEC_TRAP13:
146
            case VEC_TRAP14:
147
                sig = SIGILL;
148
                break;
149
#ifndef NO_FPU
150
            case VEC_FPBRUC:
151
            case VEC_FPIR:
152
            case VEC_FPDIVZ:
153
            case VEC_FPUNDER:
154
            case VEC_FPOE:
155
            case VEC_FPOVER:
156
            case VEC_FPNAN:
157
                {
158
                  unsigned char fstate[216];
159
 
160
                  __asm__ __volatile__ ("fsave %0@" : : "a" (fstate) : "memory");
161
                  /* Set the exception pending bit in the 68882 idle frame */
162
                  if (*(unsigned short *) fstate == 0x1f38)
163
                    {
164
                      fstate[fstate[1]] |= 1 << 3;
165
                      __asm__ __volatile__ ("frestore %0@" : : "a" (fstate));
166
                    }
167
                }
168
                /* fall through */
169
#endif
170
            case VEC_ZERODIV:
171
            case VEC_TRAP:
172
                sig = SIGFPE;
173
                break;
174
            case VEC_TRACE:             /* ptrace single step */
175
                fp->ptregs.sr &= ~PS_T;
176
            case VEC_TRAP15:            /* breakpoint */
177
                sig = SIGTRAP;
178
                break;
179
            case VEC_TRAP1:             /* gdbserver breakpoint */
180
                /* kwonsk: is this right? */
181
                fp->ptregs.pc -= 2;
182
                sig = SIGTRAP;
183
                break;
184
            default:
185
                sig = SIGILL;
186
                break;
187
        }
188
 
189
        send_sig (sig, current, 1);
190
#endif
191
}
192
 
193
asmlinkage void set_esp0 (unsigned long ssp)
194
{
195
  current->tss.esp0 = ssp;
196
}
197
 
198
void die_if_kernel (char *str, struct pt_regs *fp, int nr)
199
{
200
        extern void dump(struct pt_regs *fp);
201
 
202
        if (!(fp->sr & PS_S))
203
                return;
204
 
205
        console_verbose();
206
        dump(fp);
207
 
208
        do_exit(SIGSEGV);
209
}

powered by: WebSVN 2.1.0

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