1
2
3
4
5
6
7
8
9
10
11
12
13#include <linux/version.h>
14#include <linux/init.h>
15
16#include <asm/head.h>
17#include <asm/asi.h>
18#include <asm/contregs.h>
19#include <asm/ptrace.h>
20#include <asm/psr.h>
21#include <asm/page.h>
22#include <asm/kdebug.h>
23#include <asm/winmacro.h>
24#include <asm/thread_info.h>
25#include <asm/errno.h>
26#include <asm/pgtsrmmu.h>
27
28 .data
29
30
31
32
33
34 .align 4
35 .globl cputyp
36cputyp:
37 .word 1
38
39 .align 4
40 .globl cputypval
41cputypval:
42 .asciz "sun4c"
43 .ascii " "
44
45cputypvalend:
46cputypvallen = cputypvar - cputypval
47
48 .align 4
49
50
51
52
53
54
55
56
57cputypvar:
58 .asciz "compatability"
59
60
61 .align 4
62cputypvar_sun4m:
63 .asciz "compatible"
64
65 .align 4
66
67#ifndef CONFIG_SUN4
68sun4_notsup:
69 .asciz "Sparc-Linux sun4 needs a specially compiled kernel, turn CONFIG_SUN4 on.\n\n"
70 .align 4
71#else
72sun4cdm_notsup:
73 .asciz "Kernel compiled with CONFIG_SUN4 cannot run on SUN4C/SUN4M/SUN4D\nTurn CONFIG_SUN4 off.\n\n"
74 .align 4
75#endif
76
77sun4e_notsup:
78 .asciz "Sparc-Linux sun4e support does not exist\n\n"
79 .align 4
80
81#ifndef CONFIG_SUNOS_EMUL
82#undef SUNOS_SYSCALL_TRAP
83#define SUNOS_SYSCALL_TRAP SUNOS_NO_SYSCALL_TRAP
84#endif
85
86
87 .text
88 .globl start, _stext, _start, __stext
89 .globl trapbase
90_start:
91__stext:
92_stext:
93start:
94trapbase:
95#ifdef CONFIG_SMP
96trapbase_cpu0:
97#endif
98
99t_zero: b gokernel; nop; nop; nop;
100t_tflt: SPARC_TFAULT
101t_bins: TRAP_ENTRY(0x2, bad_instruction)
102t_pins: TRAP_ENTRY(0x3, priv_instruction)
103t_fpd: TRAP_ENTRY(0x4, fpd_trap_handler)
104t_wovf: WINDOW_SPILL
105t_wunf: WINDOW_FILL
106t_mna: TRAP_ENTRY(0x7, mna_handler)
107t_fpe: TRAP_ENTRY(0x8, fpe_trap_handler)
108t_dflt: SPARC_DFAULT
109t_tio: TRAP_ENTRY(0xa, do_tag_overflow)
110t_wpt: TRAP_ENTRY(0xb, do_watchpoint)
111t_badc: BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
112t_irq1: TRAP_ENTRY_INTERRUPT(1)
113t_irq2: TRAP_ENTRY_INTERRUPT(2)
114t_irq3: TRAP_ENTRY_INTERRUPT(3)
115t_irq4: TRAP_ENTRY_INTERRUPT(4)
116t_irq5: TRAP_ENTRY_INTERRUPT(5)
117t_irq6: TRAP_ENTRY_INTERRUPT(6)
118t_irq7: TRAP_ENTRY_INTERRUPT(7)
119t_irq8: TRAP_ENTRY_INTERRUPT(8)
120t_irq9: TRAP_ENTRY_INTERRUPT(9)
121t_irq10:TRAP_ENTRY_INTERRUPT(10)
122t_irq11:TRAP_ENTRY_INTERRUPT(11)
123t_irq12:TRAP_ENTRY_INTERRUPT(12)
124t_irq13:TRAP_ENTRY_INTERRUPT(13)
125t_irq14:TRAP_ENTRY_INTERRUPT(14)
126 .globl t_nmi
127#ifndef CONFIG_SMP
128t_nmi: NMI_TRAP
129#else
130t_nmi: TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
131#endif
132t_racc: TRAP_ENTRY(0x20, do_reg_access)
133t_iacce:BAD_TRAP(0x21)
134t_bad22:BAD_TRAP(0x22) BAD_TRAP(0x23)
135t_cpdis:TRAP_ENTRY(0x24, do_cp_disabled)
136t_uflsh:SKIP_TRAP(0x25, unimp_flush)
137t_bad26:BAD_TRAP(0x26) BAD_TRAP(0x27)
138t_cpexc:TRAP_ENTRY(0x28, do_cp_exception)
139t_dacce:SPARC_DFAULT
140t_hwdz: TRAP_ENTRY(0x2a, do_hw_divzero)
141t_dserr:BAD_TRAP(0x2b)
142t_daccm:BAD_TRAP(0x2c)
143t_bad2d:BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
144t_bad32:BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
145t_bad37:BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
146t_iaccm:BAD_TRAP(0x3c)
147t_bad3d:BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40) BAD_TRAP(0x41)
148t_bad42:BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45) BAD_TRAP(0x46)
149t_bad47:BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a) BAD_TRAP(0x4b)
150t_bad4c:BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f) BAD_TRAP(0x50)
151t_bad51:BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
152t_bad56:BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
153t_bad5b:BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
154t_bad60:BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
155t_bad65:BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
156t_bad6a:BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
157t_bad6f:BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
158t_bad74:BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
159t_bad79:BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
160t_bad7e:BAD_TRAP(0x7e) BAD_TRAP(0x7f)
161t_sunos:SUNOS_SYSCALL_TRAP
162t_sbkpt:BREAKPOINT_TRAP
163t_divz: TRAP_ENTRY(0x82, do_hw_divzero)
164t_flwin:TRAP_ENTRY(0x83, do_flush_windows)
165t_clwin:BAD_TRAP(0x84)
166t_rchk: BAD_TRAP(0x85)
167t_funal:BAD_TRAP(0x86)
168t_iovf: BAD_TRAP(0x87)
169t_slowl:SOLARIS_SYSCALL_TRAP
170t_netbs:NETBSD_SYSCALL_TRAP
171t_bad8a:BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) BAD_TRAP(0x8d) BAD_TRAP(0x8e)
172t_bad8f:BAD_TRAP(0x8f)
173t_linux:LINUX_SYSCALL_TRAP
174t_bad91:BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94) BAD_TRAP(0x95)
175t_bad96:BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99) BAD_TRAP(0x9a)
176t_bad9b:BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e) BAD_TRAP(0x9f)
177t_getcc:GETCC_TRAP
178t_setcc:SETCC_TRAP
179t_getpsr:GETPSR_TRAP
180t_bada3:BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
181t_slowi:INDIRECT_SOLARIS_SYSCALL(156)
182t_bada8:BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
183t_badac:BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
184t_badb1:BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
185t_badb6:BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
186t_badbb:BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
187t_badc0:BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
188t_badc5:BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
189t_badca:BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
190t_badcf:BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
191t_badd4:BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
192t_badd9:BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
193t_badde:BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
194t_bade3:BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
195t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
196t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
197t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
198t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
199t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd)
200dbtrap: BAD_TRAP(0xfe)
201dbtrap2:BAD_TRAP(0xff)
202
203 .globl end_traptable
204end_traptable:
205
206#ifdef CONFIG_SMP
207
208 .globl trapbase_cpu1, trapbase_cpu2, trapbase_cpu3
209trapbase_cpu1:
210 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
211 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
212 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
213 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
214 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
215 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
216 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
217 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
218 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
219 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
220 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
221 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
222 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
223 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
224 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
225 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
226 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
227 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
228 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
229 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
230 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
231 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
232 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
233 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
234 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
235 BAD_TRAP(0x50)
236 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
237 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
238 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
239 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
240 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
241 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
242 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
243 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
244 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
245 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
246 SUNOS_SYSCALL_TRAP
247 BREAKPOINT_TRAP
248 TRAP_ENTRY(0x82, do_hw_divzero)
249 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
250 BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
251 NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
252 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
253 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
254 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
255 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
256 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
257 BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
258 INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
259 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
260 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
261 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
262 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
263 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
264 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
265 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
266 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
267 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
268 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
269 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
270 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
271 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
272 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
273 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
274 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
275 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
276
277trapbase_cpu2:
278 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
279 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
280 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
281 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
282 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
283 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
284 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
285 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
286 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
287 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
288 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
289 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
290 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
291 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
292 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
293 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
294 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
295 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
296 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
297 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
298 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
299 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
300 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
301 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
302 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
303 BAD_TRAP(0x50)
304 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
305 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
306 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
307 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
308 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
309 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
310 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
311 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
312 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
313 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
314 SUNOS_SYSCALL_TRAP
315 BREAKPOINT_TRAP
316 TRAP_ENTRY(0x82, do_hw_divzero)
317 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
318 BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
319 NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
320 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
321 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
322 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
323 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
324 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
325 BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
326 INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
327 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
328 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
329 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
330 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
331 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
332 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
333 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
334 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
335 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
336 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
337 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
338 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
339 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
340 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
341 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
342 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
343 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
344
345trapbase_cpu3:
346 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
347 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
348 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
349 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
350 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
351 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
352 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
353 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
354 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
355 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
356 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
357 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
358 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
359 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
360 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
361 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
362 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
363 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
364 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
365 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
366 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
367 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
368 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
369 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
370 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
371 BAD_TRAP(0x50)
372 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
373 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
374 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
375 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
376 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
377 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
378 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
379 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
380 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
381 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
382 SUNOS_SYSCALL_TRAP
383 BREAKPOINT_TRAP
384 TRAP_ENTRY(0x82, do_hw_divzero)
385 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
386 BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
387 NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
388 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
389 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
390 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
391 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
392 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
393 BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
394 INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
395 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
396 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
397 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
398 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
399 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
400 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
401 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
402 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
403 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
404 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
405 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
406 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
407 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
408 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
409 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
410 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
411 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
412
413#endif
414 .align PAGE_SIZE
415
416
417
418
419 .globl pg0, pg1, pg2, pg3
420 .globl empty_bad_page
421 .globl empty_bad_page_table
422 .globl empty_zero_page
423 .globl swapper_pg_dir
424swapper_pg_dir: .skip PAGE_SIZE
425pg0: .skip PAGE_SIZE
426pg1: .skip PAGE_SIZE
427pg2: .skip PAGE_SIZE
428pg3: .skip PAGE_SIZE
429empty_bad_page: .skip PAGE_SIZE
430empty_bad_page_table: .skip PAGE_SIZE
431empty_zero_page: .skip PAGE_SIZE
432
433 .global root_flags
434 .global ram_flags
435 .global root_dev
436 .global sparc_ramdisk_image
437 .global sparc_ramdisk_size
438
439
440
441
442
443 .ascii "HdrS"
444 .word LINUX_VERSION_CODE
445 .half 0x0203
446root_flags:
447 .half 1
448root_dev:
449 .half 0
450ram_flags:
451 .half 0
452sparc_ramdisk_image:
453 .word 0
454sparc_ramdisk_size:
455 .word 0
456 .word reboot_command
457 .word 0, 0, 0
458 .word _end
459
460
461
462
463
464gokernel:
465
466
467
468
469
470
471
472
473
474
475
476 mov %o7, %g4 ! Save %o7
477
478
479current_pc:
480 call 1f
481 nop
482
4831:
484 mov %o7, %g3
485
486 tst %o0
487 be no_sun4u_here
488 mov %g4, %o7
489
490 mov %o0, %l0 ! stash away romvec
491 mov %o0, %g7 ! put it here too
492 mov %o1, %l1 ! stash away debug_vec too
493
494
495 set current_pc, %g5
496 cmp %g3, %g5
497 be already_mapped
498 nop
499
500
501
502
503
504
505 set KERNBASE, %l6
506 b copy_prom_lvl14
507 nop
508
509already_mapped:
510 mov 0, %l6
511
512
513copy_prom_lvl14:
514
515
516
517
518 set lvl14_save, %g1
519 set t_irq14, %g3
520 sub %g1, %l6, %g1 ! translate to physical
521 sub %g3, %l6, %g3 ! translate to physical
522 ldd [%g3], %g4
523 std %g4, [%g1]
524 ldd [%g3+8], %g4
525 std %g4, [%g1+8]
526#endif
527 rd %tbr, %g1
528 andn %g1, 0xfff, %g1 ! proms trap table base
529 or %g0, (0x1e<<4), %g2 ! offset to lvl14 intr
530 or %g1, %g2, %g2
531 set t_irq14, %g3
532 sub %g3, %l6, %g3
533 ldd [%g2], %g4
534 std %g4, [%g3]
535 ldd [%g2 + 0x8], %g4
536 std %g4, [%g3 + 0x8] ! Copy proms handler
537
538
539
540
541
542
543
544
545copy_prom_done:
546 cmp %l6, 0
547 be go_to_highmem ! this will be a nop then
548 nop
549
550 set LOAD_ADDR, %g6
551 cmp %g7, %g6
552 bne remap_not_a_sun4 ! This is not a Sun4
553 nop
554
555 or %g0, 0x1, %g1
556 lduba [%g1] ASI_CONTROL, %g1 ! Only safe to try on Sun4.
557 subcc %g1, 0x24, %g0 ! Is this a mutant Sun4/400???
558 be sun4_mutant_remap ! Ugh, it is...
559 nop
560
561 b sun4_normal_remap ! regular sun4, 2 level mmu
562 nop
563
564remap_not_a_sun4:
565 lda [%g0] ASI_M_MMUREGS, %g1 ! same as ASI_PTE on sun4c
566 and %g1, 0x1, %g1 ! Test SRMMU Enable bit ;-)
567 cmp %g1, 0x0
568 be sun4c_remap ! A sun4c MMU or normal Sun4
569 nop
570srmmu_remap:
571
572 set 0x40000000, %g2
573 rd %psr, %g3
574 and %g2, %g3, %g3
575 subcc %g3, 0x0, %g0
576 bz srmmu_nviking
577 nop
578
579
580
581
582
583
584
585
586
587 set 0x800, %g2
588 lda [%g0] ASI_M_MMUREGS, %g3 ! peek in the control reg
589 and %g2, %g3, %g3
590 subcc %g3, 0x0, %g0
591 bnz srmmu_nviking ! is in mbus mode
592 nop
593
594 rd %psr, %g3 ! DO NOT TOUCH %g3
595 andn %g3, PSR_ET, %g2
596 wr %g2, 0x0, %psr
597 WRITE_PAUSE
598
599
600
601
602 set AC_M_CTPR, %g4
603 lda [%g4] ASI_M_MMUREGS, %g4
604 sll %g4, 0x4, %g4 ! We use this below
605 ! DO NOT TOUCH %g4
606
607
608 lda [%g0] ASI_M_MMUREGS, %g5 ! DO NOT TOUCH %g5
609 set 0x8000, %g6 ! AC bit mask
610 or %g5, %g6, %g6 ! Or it in...
611 sta %g6, [%g0] ASI_M_MMUREGS ! Close your eyes...
612
613
614
615
616
617
618 lda [%g4] ASI_M_BYPASS, %o1 ! This is a level 1 ptr
619 srl %o1, 0x4, %o1 ! Clear low 4 bits
620 sll %o1, 0x8, %o1 ! Make physical
621
622
623 lda [%o1] ASI_M_BYPASS, %o2 ! This is the 0x0 16MB pgd
624
625
626 add %o1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %o3
627
628
629 sta %o2, [%o3] ASI_M_BYPASS
630
631
632
633
634
635
636
637
638
639
640
641
642 sta %g5, [%g0] ASI_M_MMUREGS ! POW... ouch
643
644
645 wr %g3, 0x0, %psr ! tick tock, tick tock
646
647
648 WRITE_PAUSE
649
650
651
652
653 b go_to_highmem
654 nop
655
656
657
658
659
660
661srmmu_nviking:
662 set AC_M_CTPR, %g1
663 lda [%g1] ASI_M_MMUREGS, %g1 ! get ctx table ptr
664 sll %g1, 0x4, %g1 ! make physical addr
665 lda [%g1] ASI_M_BYPASS, %g1 ! ptr to level 1 pg_table
666 srl %g1, 0x4, %g1
667 sll %g1, 0x8, %g1 ! make phys addr for l1 tbl
668
669 lda [%g1] ASI_M_BYPASS, %g2 ! get level1 entry for 0x0
670 add %g1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %g3
671 sta %g2, [%g3] ASI_M_BYPASS ! place at KERNBASE entry
672 b go_to_highmem
673 nop ! wheee....
674
675
676
677
678
679
680
681
682
683
684
685
686sun4_mutant_remap:
687 or %g0, %g0, %g3 ! source base
688 sethi %hi(KERNBASE), %g4 ! destination base
689 or %g4, %lo(KERNBASE), %g4
690 sethi %hi(0x300000), %g5
691 or %g5, %lo(0x300000), %g5 ! upper bound 3MB
692 or %g0, 0x1, %l6
693 sll %l6, 24, %l6 ! Regmap mapping size
694 add %g3, 0x2, %g3 ! Base magic
695 add %g4, 0x2, %g4 ! Base magic
696
697
698
699
700sun4_mutant_loop:
701 lduha [%g3] ASI_REGMAP, %g2 ! Get lower entry
702 stha %g2, [%g4] ASI_REGMAP ! Store in high entry
703 add %g4, %l6, %g4 ! Move up high memory ptr
704 subcc %g3, %g5, %g0 ! Reached our limit?
705 blu sun4_mutant_loop ! Nope, loop again
706 add %g3, %l6, %g3 ! delay, Move up low ptr
707 b go_to_highmem ! Jump to high memory.
708 nop
709
710
711sun4_normal_remap:
712 mov 0, %g3 ! source base
713 set KERNBASE, %g4 ! destination base
714 set 0x300000, %g5 ! upper bound 3MB
715 mov 1, %l6
716 sll %l6, 18, %l6 ! sun4 mmu segmap size
717sun4_normal_loop:
718 lduha [%g3] ASI_SEGMAP, %g6 ! load phys_seg
719 stha %g6, [%g4] ASI_SEGMAP ! stort new virt mapping
720 add %g3, %l6, %g3 ! increment source pointer
721 subcc %g3, %g5, %g0 ! reached limit?
722 blu sun4_normal_loop ! nope, loop again
723 add %g4, %l6, %g4 ! delay, increment dest ptr
724 b go_to_highmem
725 nop
726
727
728sun4c_remap:
729 mov 0, %g3 ! source base
730 set KERNBASE, %g4 ! destination base
731 set 0x300000, %g5 ! upper bound 3MB
732 mov 1, %l6
733 sll %l6, 18, %l6 ! sun4c mmu segmap size
734sun4c_remap_loop:
735 lda [%g3] ASI_SEGMAP, %g6 ! load phys_seg
736 sta %g6, [%g4] ASI_SEGMAP ! store new virt mapping
737 add %g3, %l6, %g3 ! Increment source ptr
738 subcc %g3, %g5, %g0 ! Reached limit?
739 bl sun4c_remap_loop ! Nope, loop again
740 add %g4, %l6, %g4 ! delay, Increment dest ptr
741
742
743go_to_highmem:
744 set execute_in_high_mem, %g1
745 jmpl %g1, %g0
746 nop
747
748
749
750
751 __INIT
752
753
754
755execute_in_high_mem:
756 mov %l0, %o0 ! put back romvec
757 mov %l1, %o1 ! and debug_vec
758
759 sethi %hi(prom_vector_p), %g1
760 st %o0, [%g1 + %lo(prom_vector_p)]
761
762 sethi %hi(linux_dbvec), %g1
763 st %o1, [%g1 + %lo(linux_dbvec)]
764
765 ld [%o0 + 0x4], %o3
766 and %o3, 0x3, %o5 ! get the version
767
768 cmp %o3, 0x2 ! a v2 prom?
769 be found_version
770 nop
771
772
773 cmp %o3, 0x3 ! a v3 prom?
774 be found_version
775 nop
776
777
778
779
780
781
782 set LOAD_ADDR, %g6
783 cmp %o0, %g6 ! an old sun4?
784 be sun4_init
785 nop
786
787found_version:
788#ifdef CONFIG_SUN4
789
790 ld [%g7 + 0x68], %o1
791 set sun4cdm_notsup, %o0
792 call %o1
793 nop
794 b halt_me
795 nop
796#endif
797
798
799 add %g7, 0x1c, %l1
800 ld [%l1], %l0
801 ld [%l0], %l0
802 call %l0
803 or %g0, %g0, %o0 ! next_node(0) = first_node
804 or %o0, %g0, %g6
805
806 sethi %hi(cputypvar), %o1 ! First node has cpu-arch
807 or %o1, %lo(cputypvar), %o1
808 sethi %hi(cputypval), %o2 ! information, the string
809 or %o2, %lo(cputypval), %o2
810 ld [%l1], %l0 ! 'compatibility' tells
811 ld [%l0 + 0xc], %l0 ! that we want 'sun4x' where
812 call %l0 ! x is one of '', 'c', 'm',
813 nop ! 'd' or 'e'. %o2 holds pointer
814 ! to a buf where above string
815 ! will get stored by the prom.
816
817 subcc %o0, %g0, %g0
818 bpos got_prop ! Got the property
819 nop
820
821 or %g6, %g0, %o0
822 sethi %hi(cputypvar_sun4m), %o1
823 or %o1, %lo(cputypvar_sun4m), %o1
824 sethi %hi(cputypval), %o2
825 or %o2, %lo(cputypval), %o2
826 ld [%l1], %l0
827 ld [%l0 + 0xc], %l0
828 call %l0
829 nop
830
831got_prop:
832 set cputypval, %o2
833 ldub [%o2 + 0x4], %l1
834
835 cmp %l1, ' '
836 be 1f
837 cmp %l1, 'c'
838 be 1f
839 cmp %l1, 'm'
840 be 1f
841 cmp %l1, 's'
842 be 1f
843 cmp %l1, 'd'
844 be 1f
845 cmp %l1, 'e'
846 be no_sun4e_here ! Could be a sun4e.
847 nop
848 b no_sun4u_here ! AIEEE, a V9 sun4u... Get our BIG BROTHER kernel :))
849 nop
850
8511: set cputypval, %l1
852 ldub [%l1 + 0x4], %l1
853 cmp %l1, 'm' ! Test for sun4d, sun4e ?
854 be sun4m_init
855 cmp %l1, 's' ! Treat sun4s as sun4m
856 be sun4m_init
857 cmp %l1, 'd' ! Let us see how the beast will die
858 be sun4d_init
859 nop
860
861
862 set AC_CONTEXT, %g1
863 stba %g0, [%g1] ASI_CONTROL
864
865 b sun4c_continue_boot
866 nop
867
868
869#define SUN4D_BOOTBUS_CPUID 0xf0140000
870
871sun4d_init:
872
873 set patch_handler_irq, %g4
874 set sun4d_handler_irq, %g5
875 sethi %hi(0x40000000), %g3 ! call
876 sub %g5, %g4, %g5
877 srl %g5, 2, %g5
878 or %g5, %g3, %g5
879 st %g5, [%g4]
880
881#ifdef CONFIG_SMP
882
883 set SUN4D_BOOTBUS_CPUID, %g3
884 lduba [%g3] ASI_M_CTL, %g3
885 and %g3, 0xf8, %g3
886 srl %g3, 3, %g4
887 sta %g4, [%g0] ASI_M_VIKING_TMP1
888 sethi %hi(boot_cpu_id), %g5
889 stb %g4, [%g5 + %lo(boot_cpu_id)]
890 sll %g4, 2, %g4
891 sethi %hi(boot_cpu_id4), %g5
892 stb %g4, [%g5 + %lo(boot_cpu_id4)]
893#endif
894
895
896
897sun4m_init:
898
899 lda [%g0] ASI_M_MMUREGS, %g5
900 srl %g5, 28, %g4
901
902 cmp %g4, 1
903 bne 1f
904 srl %g5, 24, %g4
905
906 and %g4, 0xf, %g4
907 cmp %g4, 7
908
909 bne 2f
910 nop
911
9121:
913
914#define PATCH_IT(dst, src) \
915 set (dst), %g5; \
916 set (src), %g4; \
917 ld [%g4], %g3; \
918 st %g3, [%g5]; \
919 ld [%g4+0x4], %g3; \
920 st %g3, [%g5+0x4];
921
922
923 PATCH_IT(.mul, .mul_patch)
924 PATCH_IT(.mul+0x08, .mul_patch+0x08)
925
926
927 PATCH_IT(.rem, .rem_patch)
928 PATCH_IT(.rem+0x08, .rem_patch+0x08)
929 PATCH_IT(.rem+0x10, .rem_patch+0x10)
930 PATCH_IT(.rem+0x18, .rem_patch+0x18)
931 PATCH_IT(.rem+0x20, .rem_patch+0x20)
932 PATCH_IT(.rem+0x28, .rem_patch+0x28)
933
934
935 PATCH_IT(.div, .div_patch)
936 PATCH_IT(.div+0x08, .div_patch+0x08)
937 PATCH_IT(.div+0x10, .div_patch+0x10)
938 PATCH_IT(.div+0x18, .div_patch+0x18)
939 PATCH_IT(.div+0x20, .div_patch+0x20)
940
941
942 PATCH_IT(.umul, .umul_patch)
943 PATCH_IT(.umul+0x08, .umul_patch+0x08)
944
945
946 PATCH_IT(.urem, .urem_patch)
947 PATCH_IT(.urem+0x08, .urem_patch+0x08)
948 PATCH_IT(.urem+0x10, .urem_patch+0x10)
949 PATCH_IT(.urem+0x18, .urem_patch+0x18)
950
951
952 PATCH_IT(.udiv, .udiv_patch)
953 PATCH_IT(.udiv+0x08, .udiv_patch+0x08)
954 PATCH_IT(.udiv+0x10, .udiv_patch+0x10)
955
956#undef PATCH_IT
957
958
959
960
961
962
9632:
964 rd %psr, %o1
965 srl %o1, 28, %o1 ! Get a type of the CPU
966
967 subcc %o1, 4, %g0 ! TI: Viking or MicroSPARC
968 be sun4c_continue_boot
969 nop
970
971 set AC_M_SFSR, %o0
972 lda [%o0] ASI_M_MMUREGS, %g0
973 set AC_M_SFAR, %o0
974 lda [%o0] ASI_M_MMUREGS, %g0
975
976
977 subcc %o1, 0, %g0
978 be sun4c_continue_boot
979 nop
980
981 set AC_M_AFSR, %o0
982 lda [%o0] ASI_M_MMUREGS, %g0
983 set AC_M_AFAR, %o0
984 lda [%o0] ASI_M_MMUREGS, %g0
985 nop
986
987
988sun4c_continue_boot:
989
990
991
992
993
994
995 sethi %hi(cputyp), %o0
996 st %g4, [%o0 + %lo(cputyp)]
997
998
999
1000
1001 set (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
1002 wr %g2, 0x0, %psr
1003 WRITE_PAUSE
1004
1005
1006 set init_thread_union, %g1
1007 set (THREAD_SIZE - STACKFRAME_SZ), %g2
1008 add %g1, %g2, %sp
1009 mov 0, %fp
1010
1011
1012 set __bss_start , %o0 ! First address of BSS
1013 set end , %o1 ! Last address of BSS
1014 add %o0, 0x1, %o0
10151:
1016 stb %g0, [%o0]
1017 subcc %o0, %o1, %g0
1018 bl 1b
1019 add %o0, 0x1, %o0
1020
1021
1022
1023
1024 set init_thread_union, %g6
1025 set current_set, %g2
1026#ifdef CONFIG_SMP
1027 sethi %hi(boot_cpu_id4), %g3
1028 ldub [%g3 + %lo(boot_cpu_id4)], %g3
1029 st %g6, [%g2]
1030 add %g2, %g3, %g2
1031#endif
1032 st %g6, [%g2]
1033
1034 st %g0, [%g6 + TI_UWINMASK]
1035
1036
1037
1038
1039
1040
1041 wr %g0, 0x0, %wim ! so we do not get a trap
1042 WRITE_PAUSE
1043
1044 save
1045
1046 rd %psr, %g3
1047
1048 restore
1049
1050 and %g3, 0x1f, %g3
1051 add %g3, 0x1, %g3
1052
1053 mov 2, %g1
1054 wr %g1, 0x0, %wim ! make window 1 invalid
1055 WRITE_PAUSE
1056
1057 cmp %g3, 0x7
1058 bne 2f
1059 nop
1060
1061
1062
1063
1064
1065#define PATCH_INSN(src, dest) \
1066 set src, %g5; \
1067 set dest, %g2; \
1068 ld [%g5], %g4; \
1069 st %g4, [%g2];
1070
1071
1072 PATCH_INSN(spnwin_patch1_7win, spnwin_patch1)
1073 PATCH_INSN(spnwin_patch2_7win, spnwin_patch2)
1074 PATCH_INSN(spnwin_patch3_7win, spnwin_patch3)
1075
1076
1077 PATCH_INSN(fnwin_patch1_7win, fnwin_patch1)
1078 PATCH_INSN(fnwin_patch2_7win, fnwin_patch2)
1079
1080
1081 PATCH_INSN(tsetup_7win_patch1, tsetup_patch1)
1082 PATCH_INSN(tsetup_7win_patch2, tsetup_patch2)
1083 PATCH_INSN(tsetup_7win_patch3, tsetup_patch3)
1084 PATCH_INSN(tsetup_7win_patch4, tsetup_patch4)
1085 PATCH_INSN(tsetup_7win_patch5, tsetup_patch5)
1086 PATCH_INSN(tsetup_7win_patch6, tsetup_patch6)
1087
1088
1089 PATCH_INSN(rtrap_7win_patch1, rtrap_patch1)
1090 PATCH_INSN(rtrap_7win_patch2, rtrap_patch2)
1091 PATCH_INSN(rtrap_7win_patch3, rtrap_patch3)
1092 PATCH_INSN(rtrap_7win_patch4, rtrap_patch4)
1093 PATCH_INSN(rtrap_7win_patch5, rtrap_patch5)
1094
1095
1096 PATCH_INSN(kuw_patch1_7win, kuw_patch1)
1097
1098
1099
1100
1101 set 0x01000000, %g4
1102 set flush_patch_one, %g5
1103 st %g4, [%g5 + 0x18]
1104 st %g4, [%g5 + 0x1c]
1105 set flush_patch_two, %g5
1106 st %g4, [%g5 + 0x18]
1107 st %g4, [%g5 + 0x1c]
1108 set flush_patch_three, %g5
1109 st %g4, [%g5 + 0x18]
1110 st %g4, [%g5 + 0x1c]
1111 set flush_patch_four, %g5
1112 st %g4, [%g5 + 0x18]
1113 st %g4, [%g5 + 0x1c]
1114 set flush_patch_exception, %g5
1115 st %g4, [%g5 + 0x18]
1116 st %g4, [%g5 + 0x1c]
1117 set flush_patch_switch, %g5
1118 st %g4, [%g5 + 0x18]
1119 st %g4, [%g5 + 0x1c]
1120
11212:
1122 sethi %hi(nwindows), %g4
1123 st %g3, [%g4 + %lo(nwindows)] ! store final value
1124 sub %g3, 0x1, %g3
1125 sethi %hi(nwindowsm1), %g4
1126 st %g3, [%g4 + %lo(nwindowsm1)]
1127
1128
1129 set trapbase, %g3
1130 wr %g3, 0x0, %tbr
1131 WRITE_PAUSE
1132
1133
1134 rd %psr, %g3
1135 wr %g3, 0x0, %psr
1136 WRITE_PAUSE
1137
1138 wr %g3, PSR_ET, %psr
1139 WRITE_PAUSE
1140
1141
1142
1143
1144
1145 sethi %hi(prom_vector_p), %g5
1146 ld [%g5 + %lo(prom_vector_p)], %o0
1147 call prom_init
1148 nop
1149
1150 call start_kernel
1151 nop
1152
1153
1154 call halt_me
1155 nop
1156
1157sun4_init:
1158#ifdef CONFIG_SUN4
1159
1160 set cputypval, %o2 ! Let everyone know we
1161 set ' ', %o0 ! are a "sun4 " architecture
1162 stb %o0, [%o2 + 0x4]
1163
1164 b got_prop
1165 nop
1166#else
1167 sethi %hi(SUN4_PROM_VECTOR+0x84), %o1
1168 ld [%o1 + %lo(SUN4_PROM_VECTOR+0x84)], %o1
1169 set sun4_notsup, %o0
1170 call %o1
1171 nop
1172 sethi %hi(SUN4_PROM_VECTOR+0xc4), %o1
1173 ld [%o1 + %lo(SUN4_PROM_VECTOR+0xc4)], %o1
1174 call %o1
1175 nop
11761: ba 1b ! Cannot exit into KMON
1177 nop
1178#endif
1179no_sun4e_here:
1180 ld [%g7 + 0x68], %o1
1181 set sun4e_notsup, %o0
1182 call %o1
1183 nop
1184 b halt_me
1185 nop
1186
1187 __INITDATA
1188
1189sun4u_1:
1190 .asciz "finddevice"
1191 .align 4
1192sun4u_2:
1193 .asciz "/chosen"
1194 .align 4
1195sun4u_3:
1196 .asciz "getprop"
1197 .align 4
1198sun4u_4:
1199 .asciz "stdout"
1200 .align 4
1201sun4u_5:
1202 .asciz "write"
1203 .align 4
1204sun4u_6:
1205 .asciz "\n\rOn sun4u you have to use UltraLinux (64bit) kernel\n\rand not a 32bit sun4[cdem] version\n\r\n\r"
1206sun4u_6e:
1207 .align 4
1208sun4u_7:
1209 .asciz "exit"
1210 .align 8
1211sun4u_a1:
1212 .word 0, sun4u_1, 0, 1, 0, 1, 0, sun4u_2, 0
1213sun4u_r1:
1214 .word 0
1215sun4u_a2:
1216 .word 0, sun4u_3, 0, 4, 0, 1, 0
1217sun4u_i2:
1218 .word 0, 0, sun4u_4, 0, sun4u_1, 0, 8, 0
1219sun4u_r2:
1220 .word 0
1221sun4u_a3:
1222 .word 0, sun4u_5, 0, 3, 0, 1, 0
1223sun4u_i3:
1224 .word 0, 0, sun4u_6, 0, sun4u_6e - sun4u_6 - 1, 0
1225sun4u_r3:
1226 .word 0
1227sun4u_a4:
1228 .word 0, sun4u_7, 0, 0, 0, 0
1229sun4u_r4:
1230
1231 __INIT
1232no_sun4u_here:
1233 set sun4u_a1, %o0
1234 set current_pc, %l2
1235 cmp %l2, %g3
1236 be 1f
1237 mov %o4, %l0
1238 sub %g3, %l2, %l6
1239 add %o0, %l6, %o0
1240 mov %o0, %l4
1241 mov sun4u_r4 - sun4u_a1, %l3
1242 ld [%l4], %l5
12432:
1244 add %l4, 4, %l4
1245 cmp %l5, %l2
1246 add %l5, %l6, %l5
1247 bgeu,a 3f
1248 st %l5, [%l4 - 4]
12493:
1250 subcc %l3, 4, %l3
1251 bne 2b
1252 ld [%l4], %l5
12531:
1254 call %l0
1255 mov %o0, %l1
1256
1257 ld [%l1 + (sun4u_r1 - sun4u_a1)], %o1
1258 add %l1, (sun4u_a2 - sun4u_a1), %o0
1259 call %l0
1260 st %o1, [%o0 + (sun4u_i2 - sun4u_a2)]
1261
1262 ld [%l1 + (sun4u_1 - sun4u_a1)], %o1
1263 add %l1, (sun4u_a3 - sun4u_a1), %o0
1264 call %l0
1265 st %o1, [%o0 + (sun4u_i3 - sun4u_a3)]
1266
1267 call %l0
1268 add %l1, (sun4u_a4 - sun4u_a1), %o0
1269
1270
1271halt_me:
1272 ld [%g7 + 0x74], %o0
1273 call %o0 ! Get us out of here...
1274 nop ! Apparently Solaris is better.
1275
1276
1277
1278 .data
1279 .align 4
1280
1281
1282
1283
1284
1285
1286
1287 .globl prom_vector_p
1288prom_vector_p:
1289 .word 0
1290
1291
1292
1293
1294
1295 .align 4
1296 .globl nwindows
1297 .globl nwindowsm1
1298nwindows:
1299 .word 8
1300nwindowsm1:
1301 .word 7
1302
1303
1304
1305 .align 4
1306 .globl linux_dbvec
1307linux_dbvec:
1308 .word 0
1309 .word 0
1310
1311 .align 8
1312
1313 .globl lvl14_save
1314lvl14_save:
1315 .word 0
1316 .word 0
1317 .word 0
1318 .word 0
1319 .word t_irq14
1320
1321 .section ".fixup",
1322 .globl __ret_efault
1323__ret_efault:
1324 ret
1325 restore %g0, -EFAULT, %o0
1326