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

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

Initial work on sparc32 architecture support.

  • /boot/arch/sparc32 loosely based on arm32 port
  • /kernel/arch/sparc32 based on abs32le template
  • /uspace/lib/c/arch/sparc32 based on sparc64 implementation with incompatible parts temporarily commented out.

Work currently done:

  • AMBA plug and play support in loader
  • initial MMU setup
  • kernel booting
  • register window traps
  • context_save_arch/context_restore_arch

Completed milestones: M1, M2

  • Property mode set to 100644
File size: 5.5 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 BADTRAP(_vector) \
126 .org trap_table + _vector * TRAP_ENTRY_SIZE ; \
127 ta 0 ;
128
129.align TRAP_TABLE_SIZE
130trap_table:
131 TRAP(0, reset_trap)
132 BADTRAP(1)
133 TRAP(2, illegal_instruction)
134 TRAP(3, privileged_instruction)
135 TRAP(4, fp_disabled)
136 TRAP(5, window_overflow_trap)
137 TRAP(6, window_underflow_trap)
138 BADTRAP(7)
139 BADTRAP(8)
140 BADTRAP(9)
141 BADTRAP(10)
142 BADTRAP(11)
143 BADTRAP(12)
144 BADTRAP(13)
145 BADTRAP(14)
146 BADTRAP(15)
147 BADTRAP(16)
148 BADTRAP(17)
149 BADTRAP(18)
150 BADTRAP(19)
151 BADTRAP(20)
152 BADTRAP(21)
153 BADTRAP(22)
154 BADTRAP(23)
155 BADTRAP(24)
156 BADTRAP(25)
157 BADTRAP(26)
158 BADTRAP(27)
159 BADTRAP(28)
160 BADTRAP(29)
161 BADTRAP(30)
162 BADTRAP(31)
163 BADTRAP(32)
164 BADTRAP(33)
165 BADTRAP(34)
166 BADTRAP(35)
167 BADTRAP(36)
168 BADTRAP(37)
169 BADTRAP(38)
170 BADTRAP(39)
171 BADTRAP(40)
172 BADTRAP(41)
173 BADTRAP(42)
174 BADTRAP(43)
175 BADTRAP(44)
176 BADTRAP(45)
177 BADTRAP(46)
178 BADTRAP(47)
179 BADTRAP(48)
180 BADTRAP(49)
181 BADTRAP(50)
182 BADTRAP(51)
183 BADTRAP(52)
184 BADTRAP(53)
185 BADTRAP(54)
186 BADTRAP(55)
187 BADTRAP(56)
188 BADTRAP(57)
189 BADTRAP(58)
190 BADTRAP(59)
191 BADTRAP(60)
192 BADTRAP(61)
193 BADTRAP(62)
194 BADTRAP(63)
195 BADTRAP(64)
196 BADTRAP(65)
197 BADTRAP(66)
198 BADTRAP(67)
199 BADTRAP(68)
200 BADTRAP(69)
201 BADTRAP(70)
202 BADTRAP(71)
203 BADTRAP(72)
204 BADTRAP(73)
205 BADTRAP(74)
206 BADTRAP(75)
207 BADTRAP(76)
208 BADTRAP(77)
209 BADTRAP(78)
210 BADTRAP(79)
211 BADTRAP(80)
212 BADTRAP(81)
213 BADTRAP(82)
214 BADTRAP(83)
215 BADTRAP(84)
216 BADTRAP(85)
217 BADTRAP(86)
218 BADTRAP(87)
219 BADTRAP(88)
220 BADTRAP(89)
221 BADTRAP(90)
222 BADTRAP(91)
223 BADTRAP(92)
224 BADTRAP(93)
225 BADTRAP(94)
226 BADTRAP(95)
227 BADTRAP(96)
228 BADTRAP(97)
229 BADTRAP(98)
230 BADTRAP(99)
231 BADTRAP(100)
232 BADTRAP(101)
233 BADTRAP(102)
234 BADTRAP(103)
235
Note: See TracBrowser for help on using the repository browser.