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 | // fault_if_from_uspace(istate, "%s.", __func__);
|
---|
59 | // panic_badtrap(istate, n, "%s.", __func__);
|
---|
60 | }
|
---|
61 |
|
---|
62 | /** Handle instruction_access_error. (0x21) */
|
---|
63 | void instruction_access_error(int n, istate_t *istate)
|
---|
64 | {
|
---|
65 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
66 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
67 | }
|
---|
68 |
|
---|
69 | /** Handle illegal_instruction. (0x2) */
|
---|
70 | void illegal_instruction(int n, istate_t *istate)
|
---|
71 | {
|
---|
72 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
73 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
74 | }
|
---|
75 |
|
---|
76 | /** Handle privileged_instruction. (0x3) */
|
---|
77 | void privileged_instruction(int n, istate_t *istate)
|
---|
78 | {
|
---|
79 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
80 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
81 | }
|
---|
82 |
|
---|
83 | /** Handle fp_disabled. (0x3) */
|
---|
84 | void fp_disabled(int n, istate_t *istate)
|
---|
85 | {
|
---|
86 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
87 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
88 | }
|
---|
89 |
|
---|
90 | /** Handle fp_exception. (0x08) */
|
---|
91 | void fp_exception(int n, istate_t *istate)
|
---|
92 | {
|
---|
93 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
94 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
95 | }
|
---|
96 |
|
---|
97 | /** Handle tag_overflow. (0x0a) */
|
---|
98 | void tag_overflow(int n, istate_t *istate)
|
---|
99 | {
|
---|
100 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
101 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
102 | }
|
---|
103 |
|
---|
104 | /** Handle division_by_zero. (0x2a) */
|
---|
105 | void division_by_zero(int n, istate_t *istate)
|
---|
106 | {
|
---|
107 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
108 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
109 | }
|
---|
110 |
|
---|
111 | /** Handle data_access_exception. (0x9) */
|
---|
112 | void data_access_exception(int n, istate_t *istate)
|
---|
113 | {
|
---|
114 | page_fault(n, istate);
|
---|
115 | // fault_if_from_uspace(istate, "%s.", __func__);
|
---|
116 | // panic_badtrap(istate, n, "%s.", __func__);
|
---|
117 | }
|
---|
118 |
|
---|
119 | /** Handle data_access_error. (0x29) */
|
---|
120 | void data_access_error(int n, istate_t *istate)
|
---|
121 | {
|
---|
122 | page_fault(n, istate);
|
---|
123 | // fault_if_from_uspace(istate, "%s.", __func__);
|
---|
124 | // panic_badtrap(istate, n, "%s.", __func__);
|
---|
125 | }
|
---|
126 |
|
---|
127 | /** Handle data_store_error. (0x29) */
|
---|
128 | void data_store_error(int n, istate_t *istate)
|
---|
129 | {
|
---|
130 | page_fault(n, istate);
|
---|
131 | // fault_if_from_uspace(istate, "%s.", __func__);
|
---|
132 | // panic_badtrap(istate, n, "%s.", __func__);
|
---|
133 | }
|
---|
134 | /** Handle data_access_error. (0x2c) */
|
---|
135 | void data_access_mmu_miss(int n, istate_t *istate)
|
---|
136 | {
|
---|
137 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
138 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
139 | }
|
---|
140 |
|
---|
141 | /** Handle mem_address_not_aligned. (0x7) */
|
---|
142 | void mem_address_not_aligned(int n, istate_t *istate)
|
---|
143 | {
|
---|
144 | fault_if_from_uspace(istate, "%s.", __func__);
|
---|
145 | panic_badtrap(istate, n, "%s.", __func__);
|
---|
146 | }
|
---|
147 |
|
---|
148 | sysarg_t syscall(sysarg_t a1, sysarg_t a2, sysarg_t a3, sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id)
|
---|
149 | {
|
---|
150 | // printf("syscall %d\n", id);
|
---|
151 | // printf("args: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", a1, a2, a3, a4, a5, a6);
|
---|
152 | // if (id == 0x4f) {
|
---|
153 | // flush_windows();
|
---|
154 | // return 0;
|
---|
155 | // }
|
---|
156 |
|
---|
157 | return syscall_handler(a1, a2, a3, a4, a5, a6, id);
|
---|
158 | }
|
---|
159 |
|
---|
160 | void irq_exception(unsigned int nr, istate_t *istate)
|
---|
161 | {
|
---|
162 | machine_irq_exception(nr, istate);
|
---|
163 | }
|
---|
164 |
|
---|
165 | void preemptible_save_uspace(uintptr_t sp, istate_t *istate)
|
---|
166 | {
|
---|
167 | as_page_fault(sp, PF_ACCESS_WRITE, istate);
|
---|
168 | }
|
---|
169 |
|
---|
170 | void preemptible_restore_uspace(uintptr_t sp, istate_t *istate)
|
---|
171 | {
|
---|
172 | as_page_fault(sp, PF_ACCESS_WRITE, istate);
|
---|
173 | }
|
---|
174 |
|
---|
175 | /** @}
|
---|
176 | */
|
---|