1/*- 2 * Copyright (c) 2001 Jake Burkholder. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h>
|
28__FBSDID("$FreeBSD: head/lib/libc/sparc64/sys/__sparc_utrap.c 91174 2002-02-23 21:37:18Z tmm $");
|
28__FBSDID("$FreeBSD: head/lib/libc/sparc64/sys/__sparc_utrap.c 95587 2002-04-27 21:56:28Z jake $"); |
29 30#include <sys/types.h> 31 32#include <machine/utrap.h> 33#include <machine/sysarch.h> 34
|
35#include <errno.h> 36#include <signal.h> |
37#include <stdio.h> 38#include <stdlib.h>
|
39#include <unistd.h> |
40 41#include "__sparc_utrap_private.h" 42 43static const char *utrap_msg[] = { 44 "reserved", 45 "instruction access exception", 46 "instruction access error", 47 "instruction access protection", 48 "illtrap instruction", 49 "illegal instruction", 50 "privileged opcode", 51 "floating point disabled", 52 "floating point exception ieee 754", 53 "floating point exception other", 54 "tag overflow", 55 "division by zero", 56 "data access exception", 57 "data access error", 58 "data access protection", 59 "memory address not aligned", 60 "privileged action", 61 "async data error", 62 "trap instruction 16", 63 "trap instruction 17", 64 "trap instruction 18", 65 "trap instruction 19", 66 "trap instruction 20", 67 "trap instruction 21", 68 "trap instruction 22", 69 "trap instruction 23", 70 "trap instruction 24", 71 "trap instruction 25", 72 "trap instruction 26", 73 "trap instruction 27", 74 "trap instruction 28", 75 "trap instruction 29", 76 "trap instruction 30", 77 "trap instruction 31", 78}; 79 80void 81__sparc_utrap(struct utrapframe *uf) 82{
|
83 int sig; |
84 85 switch (uf->uf_type) { 86 case UT_FP_EXCEPTION_IEEE_754: 87 case UT_FP_EXCEPTION_OTHER:
|
84 __fpu_exception(uf);
85 UF_DONE(uf);
86 return;
|
88 sig = __fpu_exception(uf); 89 break; |
90 case UT_ILLEGAL_INSTRUCTION:
|
91 sig = __emul_insn(uf); 92 break; |
93 case UT_MEM_ADDRESS_NOT_ALIGNED: 94 break;
|
90 case UT_TRAP_INSTRUCTION_16:
91 UF_DONE(uf);
92 return;
|
95 default: 96 break; 97 }
|
96 printf("__sparc_utrap: type=%s pc=%#lx npc=%#lx\n",
97 utrap_msg[uf->uf_type], uf->uf_pc, uf->uf_npc);
98 abort();
|
98 if (sig) { 99 __utrap_write("__sparc_utrap: fatal "); 100 __utrap_write(utrap_msg[uf->uf_type]); 101 __utrap_write("\n"); 102 __utrap_kill_self(sig); 103 } 104 UF_DONE(uf); |
105}
|
106 107void 108__utrap_write(const char *str) 109{ 110 int berrno; 111 112 berrno = errno; 113 __sys_write(STDERR_FILENO, str, strlen(str)); 114 errno = berrno; 115} 116 117void 118__utrap_kill_self(sig) 119{ 120 int berrno; 121 122 berrno = errno; 123 __sys_kill(__sys_getpid(), sig); 124 errno = berrno; 125} 126 127void 128__utrap_panic(const char *msg) 129{ 130 131 __utrap_write(msg); 132 __utrap_write("\n"); 133 __utrap_kill_self(SIGKILL); 134} |
|