subr_trap.c (701) | subr_trap.c (757) |
---|---|
1/*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * the University of Utah, and William Jolitz. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 | 1/*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * the University of Utah, and William Jolitz. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 |
37 * $Id: trap.c,v 1.5 1993/11/01 11:51:29 chmr Exp $ | 37 * $Id: trap.c,v 1.6 1993/11/04 15:05:41 davidg Exp $ |
38 */ 39 40/* 41 * 386 Trap and System call handleing 42 */ 43 44#include "npx.h" 45#include "machine/cpu.h" --- 34 unchanged lines hidden (view full) --- 80#endif /* __GNUC__ */ 81 82struct sysent sysent[]; 83int nsysent; 84int dostacklimits; 85unsigned rcr2(); 86extern short cpl; 87 | 38 */ 39 40/* 41 * 386 Trap and System call handleing 42 */ 43 44#include "npx.h" 45#include "machine/cpu.h" --- 34 unchanged lines hidden (view full) --- 80#endif /* __GNUC__ */ 81 82struct sysent sysent[]; 83int nsysent; 84int dostacklimits; 85unsigned rcr2(); 86extern short cpl; 87 |
88#define MAX_TRAP_MSG 27 89char *trap_msg[] = { 90 "reserved addressing fault", /* 0 T_RESADFLT */ 91 "privileged instruction fault", /* 1 T_PRIVINFLT */ 92 "reserved operand fault", /* 2 T_RESOPFLT */ 93 "breakpoint instruction fault", /* 3 T_BPTFLT */ 94 "", /* 4 unused */ 95 "system call trap", /* 5 T_SYSCALL */ 96 "arithmetic trap", /* 6 T_ARITHTRAP */ 97 "system forced exception", /* 7 T_ASTFLT */ 98 "segmentation (limit) fault", /* 8 T_SEGFLT */ 99 "protection fault", /* 9 T_PROTFLT */ 100 "trace trap", /* 10 T_TRCTRAP */ 101 "", /* 11 unused */ 102 "page fault", /* 12 T_PAGEFLT */ 103 "page table fault", /* 13 T_TABLEFLT */ 104 "alignment fault", /* 14 T_ALIGNFLT */ 105 "kernel stack pointer not valid", /* 15 T_KSPNOTVAL */ 106 "bus error", /* 16 T_BUSERR */ 107 "kernel debugger fault", /* 17 T_KDBTRAP */ 108 "integer divide fault", /* 18 T_DIVIDE */ 109 "non-maskable interrupt trap", /* 19 T_NMI */ 110 "overflow trap", /* 20 T_OFLOW */ 111 "FPU bounds check fault", /* 21 T_BOUND */ 112 "FPU device not available", /* 22 T_DNA */ 113 "double fault", /* 23 T_DOUBLEFLT */ 114 "FPU operand fetch fault", /* 24 T_FPOPFLT */ 115 "invalid TSS fault", /* 25 T_TSSFLT */ 116 "segment not present fault", /* 26 T_SEGNPFLT */ 117 "stack fault", /* 27 T_STKFLT */ 118}; |
|
88 | 119 |
120 |
|
89/* 90 * trap(frame): 91 * Exception, fault, and trap interface to BSD kernel. This 92 * common code is called from assembly language IDT gate entry 93 * routines that prepare a suitable stack frame, and restore this 94 * frame after the exception has been processed. Note that the 95 * effect is as if the arguments were passed call by reference. 96 */ --- 63 unchanged lines hidden (view full) --- 160 if (kdb_trap(&psl)) 161 return; 162#endif 163#if NDDB > 0 164 if (kdb_trap (type, 0, &frame)) 165 return; 166#endif 167 | 121/* 122 * trap(frame): 123 * Exception, fault, and trap interface to BSD kernel. This 124 * common code is called from assembly language IDT gate entry 125 * routines that prepare a suitable stack frame, and restore this 126 * frame after the exception has been processed. Note that the 127 * effect is as if the arguments were passed call by reference. 128 */ --- 63 unchanged lines hidden (view full) --- 192 if (kdb_trap(&psl)) 193 return; 194#endif 195#if NDDB > 0 196 if (kdb_trap (type, 0, &frame)) 197 return; 198#endif 199 |
168 printf("trap type %d code = %x eip = %x cs = %x eflags = %x ", | 200 if ((type & ~T_USER) <= MAX_TRAP_MSG) 201 printf("\n\nFatal trap %d: %s while in %s mode\n", 202 type & ~T_USER, trap_msg[type & ~T_USER], 203 (type & T_USER) ? "user" : "kernel"); 204 205 printf("trap type = %d, code = %x\n eip = %x, cs = %x, eflags = %x, ", |
169 frame.tf_trapno, frame.tf_err, frame.tf_eip, 170 frame.tf_cs, frame.tf_eflags); | 206 frame.tf_trapno, frame.tf_err, frame.tf_eip, 207 frame.tf_cs, frame.tf_eflags); |
171 eva = rcr2(); 172 printf("cr2 %x cpl %x\n", eva, cpl); 173 /* type &= ~T_USER; */ /* XXX what the hell is this */ 174 panic("trap"); | 208 eva = rcr2(); 209 printf("cr2 = %x, current priority = %x\n", eva, cpl); 210 211 type &= ~T_USER; 212 if (type <= MAX_TRAP_MSG) 213 panic(trap_msg[type]); 214 else 215 panic("unknown/reserved trap"); 216 |
175 /*NOTREACHED*/ 176 177 case T_SEGNPFLT|T_USER: 178 case T_STKFLT|T_USER: 179 case T_PROTFLT|T_USER: /* protection fault */ 180 ucode = code + BUS_SEGM_FAULT ; 181 i = SIGBUS; 182 break; --- 407 unchanged lines hidden --- | 217 /*NOTREACHED*/ 218 219 case T_SEGNPFLT|T_USER: 220 case T_STKFLT|T_USER: 221 case T_PROTFLT|T_USER: /* protection fault */ 222 ucode = code + BUS_SEGM_FAULT ; 223 i = SIGBUS; 224 break; --- 407 unchanged lines hidden --- |