2 * Copyright (c) 2001 Jake Burkholder.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <sys/types.h>
32 #include <machine/utrap.h>
33 #include <machine/sysarch.h>
42 #include "fpu_extern.h"
43 #include "__sparc_utrap_private.h"
45 extern ssize_t __sys_write(int, const void *, size_t);
46 extern int __sys_kill(pid_t, int);
47 extern pid_t __sys_getpid(void);
49 static const char *utrap_msg[] = {
51 "instruction access exception",
52 "instruction access error",
53 "instruction access protection",
54 "illtrap instruction",
55 "illegal instruction",
57 "floating point disabled",
58 "floating point exception ieee 754",
59 "floating point exception other",
62 "data access exception",
64 "data access protection",
65 "memory address not aligned",
68 "trap instruction 16",
69 "trap instruction 17",
70 "trap instruction 18",
71 "trap instruction 19",
72 "trap instruction 20",
73 "trap instruction 21",
74 "trap instruction 22",
75 "trap instruction 23",
76 "trap instruction 24",
77 "trap instruction 25",
78 "trap instruction 26",
79 "trap instruction 27",
80 "trap instruction 28",
81 "trap instruction 29",
82 "trap instruction 30",
83 "trap instruction 31",
87 __sparc_utrap(struct utrapframe *uf)
91 switch (uf->uf_type) {
92 case UT_FP_EXCEPTION_IEEE_754:
93 case UT_FP_EXCEPTION_OTHER:
94 sig = __fpu_exception(uf);
96 case UT_ILLEGAL_INSTRUCTION:
97 sig = __emul_insn(uf);
99 case UT_MEM_ADDRESS_NOT_ALIGNED:
100 sig = __unaligned_fixup(uf);
106 __utrap_write("__sparc_utrap: fatal ");
107 __utrap_write(utrap_msg[uf->uf_type]);
109 __utrap_kill_self(sig);
115 __utrap_write(const char *str)
120 __sys_write(STDERR_FILENO, str, strlen(str));
125 __utrap_kill_self(sig)
130 __sys_kill(__sys_getpid(), sig);
135 __utrap_panic(const char *msg)
140 __utrap_kill_self(SIGKILL);