source: mainline/kernel/arch/sparc64/src/trap/exception.c

Last change on this file was bab75df6, checked in by Jiri Svoboda <jiri@…>, 7 years ago

Let kernel code get printf via the standard stdio header. Clean up unused includes.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/*
2 * Copyright (c) 2005 Jakub Jermar
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 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup kernel_sparc64_interrupt
30 * @{
31 */
32/** @file
33 *
34 */
35
36#include <arch/trap/exception.h>
37#include <arch/mm/tlb.h>
38#include <arch/interrupt.h>
39#include <interrupt.h>
40#include <arch/asm.h>
41#include <arch/register.h>
42#include <debug.h>
43#include <stdio.h>
44#include <symtab.h>
45
46void istate_decode(istate_t *istate)
47{
48 const char *tpcs = symtab_fmt_name_lookup(istate->tpc);
49 const char *tnpcs = symtab_fmt_name_lookup(istate->tnpc);
50
51 printf("TSTATE=%#" PRIx64 "\n", istate->tstate);
52 printf("TPC=%#" PRIx64 " (%s)\n", istate->tpc, tpcs);
53 printf("TNPC=%#" PRIx64 " (%s)\n", istate->tnpc, tnpcs);
54}
55
56/** Handle instruction_access_exception. (0x8) */
57void instruction_access_exception(unsigned int n, istate_t *istate)
58{
59 fault_if_from_uspace(istate, "%s.", __func__);
60 panic_badtrap(istate, n, "%s.", __func__);
61}
62
63/** Handle instruction_access_error. (0xa) */
64void instruction_access_error(unsigned int n, istate_t *istate)
65{
66 fault_if_from_uspace(istate, "%s.", __func__);
67 panic_badtrap(istate, n, "%s.", __func__);
68}
69
70/** Handle illegal_instruction. (0x10) */
71void illegal_instruction(unsigned int n, istate_t *istate)
72{
73 fault_if_from_uspace(istate, "%s.", __func__);
74 panic_badtrap(istate, n, "%s.", __func__);
75}
76
77/** Handle privileged_opcode. (0x11) */
78void privileged_opcode(unsigned int n, istate_t *istate)
79{
80 fault_if_from_uspace(istate, "%s.", __func__);
81 panic_badtrap(istate, n, "%s.", __func__);
82}
83
84/** Handle unimplemented_LDD. (0x12) */
85void unimplemented_LDD(unsigned int n, istate_t *istate)
86{
87 fault_if_from_uspace(istate, "%s.", __func__);
88 panic_badtrap(istate, n, "%s.", __func__);
89}
90
91/** Handle unimplemented_STD. (0x13) */
92void unimplemented_STD(unsigned int n, istate_t *istate)
93{
94 fault_if_from_uspace(istate, "%s.", __func__);
95 panic_badtrap(istate, n, "%s.", __func__);
96}
97
98/** Handle fp_disabled. (0x20) */
99void fp_disabled(unsigned int n, istate_t *istate)
100{
101 fprs_reg_t fprs;
102
103 fprs.value = fprs_read();
104 if (!fprs.fef) {
105 fprs.fef = true;
106 fprs_write(fprs.value);
107 return;
108 }
109
110#ifdef CONFIG_FPU_LAZY
111 scheduler_fpu_lazy_request();
112#else
113 fault_if_from_uspace(istate, "%s.", __func__);
114 panic_badtrap(istate, n, "%s.", __func__);
115#endif
116}
117
118/** Handle fp_exception_ieee_754. (0x21) */
119void fp_exception_ieee_754(unsigned int n, istate_t *istate)
120{
121 fault_if_from_uspace(istate, "%s.", __func__);
122 panic_badtrap(istate, n, "%s.", __func__);
123}
124
125/** Handle fp_exception_other. (0x22) */
126void fp_exception_other(unsigned int n, istate_t *istate)
127{
128 fault_if_from_uspace(istate, "%s.", __func__);
129 panic_badtrap(istate, n, "%s.", __func__);
130}
131
132/** Handle tag_overflow. (0x23) */
133void tag_overflow(unsigned int n, istate_t *istate)
134{
135 fault_if_from_uspace(istate, "%s.", __func__);
136 panic_badtrap(istate, n, "%s.", __func__);
137}
138
139/** Handle division_by_zero. (0x28) */
140void division_by_zero(unsigned int n, istate_t *istate)
141{
142 fault_if_from_uspace(istate, "%s.", __func__);
143 panic_badtrap(istate, n, "%s.", __func__);
144}
145
146/** Handle data_access_exception. (0x30) */
147void data_access_exception(unsigned int n, istate_t *istate)
148{
149 fault_if_from_uspace(istate, "%s.", __func__);
150 panic_badtrap(istate, n, "%s.", __func__);
151}
152
153/** Handle data_access_error. (0x32) */
154void data_access_error(unsigned int n, istate_t *istate)
155{
156 fault_if_from_uspace(istate, "%s.", __func__);
157 panic_badtrap(istate, n, "%s.", __func__);
158}
159
160/** Handle mem_address_not_aligned. (0x34) */
161void mem_address_not_aligned(unsigned int n, istate_t *istate)
162{
163 fault_if_from_uspace(istate, "%s.", __func__);
164 panic_badtrap(istate, n, "%s.", __func__);
165}
166
167/** Handle LDDF_mem_address_not_aligned. (0x35) */
168void LDDF_mem_address_not_aligned(unsigned int n, istate_t *istate)
169{
170 fault_if_from_uspace(istate, "%s.", __func__);
171 panic_badtrap(istate, n, "%s.", __func__);
172}
173
174/** Handle STDF_mem_address_not_aligned. (0x36) */
175void STDF_mem_address_not_aligned(unsigned int n, istate_t *istate)
176{
177 fault_if_from_uspace(istate, "%s.", __func__);
178 panic_badtrap(istate, n, "%s.", __func__);
179}
180
181/** Handle privileged_action. (0x37) */
182void privileged_action(unsigned int n, istate_t *istate)
183{
184 fault_if_from_uspace(istate, "%s.", __func__);
185 panic_badtrap(istate, n, "%s.", __func__);
186}
187
188/** Handle LDQF_mem_address_not_aligned. (0x38) */
189void LDQF_mem_address_not_aligned(unsigned int n, istate_t *istate)
190{
191 fault_if_from_uspace(istate, "%s.", __func__);
192 panic_badtrap(istate, n, "%s.", __func__);
193}
194
195/** Handle STQF_mem_address_not_aligned. (0x39) */
196void STQF_mem_address_not_aligned(unsigned int n, istate_t *istate)
197{
198 fault_if_from_uspace(istate, "%s.", __func__);
199 panic_badtrap(istate, n, "%s.", __func__);
200}
201
202/** @}
203 */
Note: See TracBrowser for help on using the repository browser.