1 | /*
|
---|
2 | * Copyright (c) 2005 Jakub Jermar
|
---|
3 | * Copyright (c) 2013 Jakub Klama
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * - The name of the author may not be used to endorse or promote products
|
---|
16 | * derived from this software without specific prior written permission.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | */
|
---|
29 |
|
---|
30 | /** @addtogroup sparc64interrupt
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 | /** @file
|
---|
34 | *
|
---|
35 | */
|
---|
36 |
|
---|
37 | #include <arch.h>
|
---|
38 | #include <typedefs.h>
|
---|
39 | #include <arch/istate.h>
|
---|
40 | #include <arch/exception.h>
|
---|
41 | #include <arch/regwin.h>
|
---|
42 | #include <arch/machine_func.h>
|
---|
43 | #include <syscall/syscall.h>
|
---|
44 | #include <interrupt.h>
|
---|
45 | #include <arch/asm.h>
|
---|
46 | #include <mm/frame.h>
|
---|
47 | #include <mm/page.h>
|
---|
48 | #include <mm/as.h>
|
---|
49 | #include <memstr.h>
|
---|
50 | #include <debug.h>
|
---|
51 | #include <print.h>
|
---|
52 | #include <symtab.h>
|
---|
53 |
|
---|
54 | /** Handle instruction_access_exception. (0x1) */
|
---|
55 | void instruction_access_exception(int n, istate_t *istate)
|
---|
56 | {
|
---|
57 | page_fault(n, istate);
|
---|
58 | }
|
---|
59 |
|
---|
60 | /** Handle instruction_access_error. (0x21) */
|
---|
61 | void instruction_access_error(int n, istate_t *istate)
|
---|
62 | {
|
---|
63 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
64 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
65 | }
|
---|
66 |
|
---|
67 | /** Handle illegal_instruction. (0x2) */
|
---|
68 | void illegal_instruction(int n, istate_t *istate)
|
---|
69 | {
|
---|
70 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
71 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
72 | }
|
---|
73 |
|
---|
74 | /** Handle privileged_instruction. (0x3) */
|
---|
75 | void privileged_instruction(int n, istate_t *istate)
|
---|
76 | {
|
---|
77 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
78 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
79 | }
|
---|
80 |
|
---|
81 | /** Handle fp_disabled. (0x3) */
|
---|
82 | void fp_disabled(int n, istate_t *istate)
|
---|
83 | {
|
---|
84 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
85 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
86 | }
|
---|
87 |
|
---|
88 | /** Handle fp_exception. (0x08) */
|
---|
89 | void fp_exception(int n, istate_t *istate)
|
---|
90 | {
|
---|
91 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
92 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
93 | }
|
---|
94 |
|
---|
95 | /** Handle tag_overflow. (0x0a) */
|
---|
96 | void tag_overflow(int n, istate_t *istate)
|
---|
97 | {
|
---|
98 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
99 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
100 | }
|
---|
101 |
|
---|
102 | /** Handle division_by_zero. (0x2a) */
|
---|
103 | void division_by_zero(int n, istate_t *istate)
|
---|
104 | {
|
---|
105 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
106 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
107 | }
|
---|
108 |
|
---|
109 | /** Handle data_access_exception. (0x9) */
|
---|
110 | void data_access_exception(int n, istate_t *istate)
|
---|
111 | {
|
---|
112 | page_fault(n, istate);
|
---|
113 | }
|
---|
114 |
|
---|
115 | /** Handle data_access_error. (0x29) */
|
---|
116 | void data_access_error(int n, istate_t *istate)
|
---|
117 | {
|
---|
118 | page_fault(n, istate);
|
---|
119 | }
|
---|
120 |
|
---|
121 | /** Handle data_store_error. (0x29) */
|
---|
122 | void data_store_error(int n, istate_t *istate)
|
---|
123 | {
|
---|
124 | page_fault(n, istate);
|
---|
125 | }
|
---|
126 |
|
---|
127 | /** Handle data_access_error. (0x2c) */
|
---|
128 | void data_access_mmu_miss(int n, istate_t *istate)
|
---|
129 | {
|
---|
130 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
131 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
132 | }
|
---|
133 |
|
---|
134 | /** Handle mem_address_not_aligned. (0x7) */
|
---|
135 | void mem_address_not_aligned(int n, istate_t *istate)
|
---|
136 | {
|
---|
137 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
138 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
139 | }
|
---|
140 |
|
---|
141 | sysarg_t syscall(sysarg_t a1, sysarg_t a2, sysarg_t a3, sysarg_t a4,
|
---|
142 | sysarg_t a5, sysarg_t a6, sysarg_t id)
|
---|
143 | {
|
---|
144 | return syscall_handler(a1, a2, a3, a4, a5, a6, id);
|
---|
145 | }
|
---|
146 |
|
---|
147 | void irq_exception(unsigned int nr, istate_t *istate)
|
---|
148 | {
|
---|
149 | machine_irq_exception(nr, istate);
|
---|
150 | }
|
---|
151 |
|
---|
152 | void preemptible_save_uspace(uintptr_t sp, istate_t *istate)
|
---|
153 | {
|
---|
154 | as_page_fault(sp, PF_ACCESS_WRITE, istate);
|
---|
155 | }
|
---|
156 |
|
---|
157 | void preemptible_restore_uspace(uintptr_t sp, istate_t *istate)
|
---|
158 | {
|
---|
159 | as_page_fault(sp, PF_ACCESS_WRITE, istate);
|
---|
160 | }
|
---|
161 |
|
---|
162 | /** @}
|
---|
163 | */
|
---|