source: mainline/kernel/arch/sparc32/src/trap_table.S@ 3efc35a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 3efc35a was 3efc35a, checked in by Jakub Klama <jakub.klama@…>, 12 years ago

Construct full exception and interrupt table.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1#
2# Copyright (c) 2013 Jakub Klama
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#include <arch/trap.h>
30
31.text
32
33.global trap_table
34.global reset_trap
35.global window_overflow_trap
36.global window_underflow_trap
37
38reset_trap:
39 set 0x80000100, %l0
40 set 'r', %l1
41 sta %l1, [%l0] 0x1c
42 rett
43
44window_overflow_trap:
45 /* rotate WIM on bit right, we have 8 windows */
46 mov %wim,%l3
47 sll %l3,7,%l4
48 srl %l3,1,%l3
49 or %l3,%l4,%l3
50 and %l3,0xff,%l3
51
52 /* disable WIM traps */
53 mov %g0,%wim
54 nop; nop; nop
55
56 /* point to correct window */
57 save
58
59 /* dump registers to stack */
60 std %l0, [%sp + 0]
61 std %l2, [%sp + 8]
62 std %l4, [%sp + 16]
63 std %l6, [%sp + 24]
64 std %i0, [%sp + 32]
65 std %i2, [%sp + 40]
66 std %i4, [%sp + 48]
67 std %i6, [%sp + 56]
68
69 /* back to where we should be */
70 restore
71
72 /* set new value of window */
73 mov %l3,%wim
74 nop; nop; nop
75
76 /* go home */
77 jmp %l1
78 rett %l2
79
80window_underflow_trap:
81 /* rotate WIM on bit LEFT, we have 8 windows */
82 mov %wim,%l3
83 srl %l3,7,%l4
84 sll %l3,1,%l3
85 or %l3,%l4,%l3
86 and %l3, 0xff,%l3
87
88 /* disable WIM traps */
89 mov %g0,%wim
90 nop; nop; nop
91
92 /* point to correct window */
93 restore
94 restore
95
96 /* dump registers to stack */
97 ldd [%sp + 0], %l0
98 ldd [%sp + 8], %l2
99 ldd [%sp + 16], %l4
100 ldd [%sp + 24], %l6
101 ldd [%sp + 32], %i0
102 ldd [%sp + 40], %i2
103 ldd [%sp + 48], %i4
104 ldd [%sp + 56], %i6
105
106 /* back to where we should be */
107 save
108 save
109
110 /* set new value of window */
111 mov %l3,%wim
112 nop; nop; nop
113
114 /* go home */
115 jmp %l1
116 rett %l2
117
118#define TRAP(_vector, _handler) \
119 .org trap_table + _vector * TRAP_ENTRY_SIZE; \
120 mov %psr, %l0 ; \
121 sethi %hi(_handler), %l4 ; \
122 jmp %l4 + %lo(_handler); \
123 mov _vector, %l3 ;
124
125#define INTERRUPT(_vector, _priority) \
126 .org trap_table + _vector * TRAP_ENTRY_SIZE; \
127 mov %psr, %l0 ; \
128 mov _priority, %g2 ; \
129 call exc_dispatch ; \
130 nop ;
131
132#define BADTRAP(_vector) \
133 .org trap_table + _vector * TRAP_ENTRY_SIZE ; \
134 ta 0 ;
135
136.align TRAP_TABLE_SIZE
137trap_table:
138 TRAP(0x0, reset_trap)
139 TRAP(0x1, instruction_access_exception)
140 TRAP(0x2, illegal_instruction)
141 TRAP(0x3, privileged_instruction)
142 TRAP(0x4, fp_disabled)
143 TRAP(0x5, window_overflow_trap)
144 TRAP(0x6, window_underflow_trap)
145 TRAP(0x7, mem_address_not_aligned)
146 TRAP(0x8, fp_exception)
147 TRAP(0x9, data_access_exception)
148 TRAP(0xa, tag_overflow)
149 BADTRAP(0xb)
150 BADTRAP(0xc)
151 BADTRAP(0xd)
152 BADTRAP(0xe)
153 BADTRAP(0xf)
154 BADTRAP(0x10)
155 INTERRUPT(0x11, 1)
156 INTERRUPT(0x12, 2)
157 INTERRUPT(0x13, 3)
158 INTERRUPT(0x14, 4)
159 INTERRUPT(0x15, 5)
160 INTERRUPT(0x16, 6)
161 INTERRUPT(0x17, 7)
162 INTERRUPT(0x18, 8)
163 INTERRUPT(0x19, 9)
164 INTERRUPT(0x1a, 10)
165 INTERRUPT(0x1b, 11)
166 INTERRUPT(0x1c, 12)
167 INTERRUPT(0x1d, 13)
168 INTERRUPT(0x1e, 14)
169 INTERRUPT(0x1f, 15)
170 TRAP(0x21, instruction_access_error)
171 BADTRAP(0x22)
172 BADTRAP(0x23)
173 BADTRAP(0x24)
174 BADTRAP(0x25)
175 BADTRAP(0x26)
176 BADTRAP(0x27)
177 BADTRAP(0x28)
178 TRAP(0x29, data_access_error)
179 TRAP(0x2a, division_by_zero)
180 TRAP(0x2b, data_store_error)
181 TRAP(0x2c, data_access_mmu_miss)
182 BADTRAP(0x2d)
183 BADTRAP(0x2e)
184 BADTRAP(0x2f)
185 BADTRAP(0x30)
186 BADTRAP(0x31)
187 BADTRAP(0x32)
188 BADTRAP(0x33)
189 BADTRAP(0x34)
190 BADTRAP(0x35)
191 BADTRAP(0x36)
192 BADTRAP(0x37)
193 BADTRAP(0x38)
194 BADTRAP(0x39)
195 BADTRAP(0x3a)
196 BADTRAP(0x3b)
197 BADTRAP(0x3c)
198 BADTRAP(0x3d)
199 BADTRAP(0x3e)
200 BADTRAP(0x3f)
201 BADTRAP(0x40)
202 BADTRAP(0x41)
203 BADTRAP(0x42)
204 BADTRAP(0x43)
205 BADTRAP(0x44)
206 BADTRAP(0x45)
207 BADTRAP(0x46)
208 BADTRAP(0x47)
209 BADTRAP(0x48)
210 BADTRAP(0x49)
211 BADTRAP(0x4a)
212 BADTRAP(0x4b)
213 BADTRAP(0x4c)
214 BADTRAP(0x4d)
215 BADTRAP(0x4e)
216 BADTRAP(0x4f)
217 BADTRAP(0x50)
218 BADTRAP(0x51)
219 BADTRAP(0x52)
220 BADTRAP(0x53)
221 BADTRAP(0x54)
222 BADTRAP(0x55)
223 BADTRAP(0x56)
224 BADTRAP(0x57)
225 BADTRAP(0x58)
226 BADTRAP(0x59)
227 BADTRAP(0x5a)
228 BADTRAP(0x5b)
229 BADTRAP(0x5c)
230 BADTRAP(0x5d)
231 BADTRAP(0x5e)
232 BADTRAP(0x5f)
233 BADTRAP(0x60)
234 BADTRAP(0x61)
235 BADTRAP(0x62)
236 BADTRAP(0x63)
237 BADTRAP(0x64)
238 BADTRAP(0x65)
239 BADTRAP(0x66)
240 BADTRAP(0x67)
241 BADTRAP(0x68)
242 BADTRAP(0x69)
243 BADTRAP(0x6a)
244 BADTRAP(0x6b)
245 BADTRAP(0x6c)
246 BADTRAP(0x6d)
247 BADTRAP(0x6e)
248 BADTRAP(0x6f)
249 BADTRAP(0x70)
250 BADTRAP(0x71)
251 BADTRAP(0x72)
252 BADTRAP(0x73)
253 BADTRAP(0x74)
254 BADTRAP(0x75)
255 BADTRAP(0x76)
256 BADTRAP(0x77)
257 BADTRAP(0x78)
258 BADTRAP(0x79)
259 BADTRAP(0x7a)
260 BADTRAP(0x7b)
261 BADTRAP(0x7c)
262 BADTRAP(0x7d)
263 BADTRAP(0x7e)
264 BADTRAP(0x7f)
265
Note: See TracBrowser for help on using the repository browser.