1
2
3
4
5
6
7
8 #include <linux/version.h>
9
10 #include <asm/cprefix.h>
11 #include <asm/head.h>
12 #include <asm/asi.h>
13 #include <asm/contregs.h>
14 #include <asm/ptrace.h>
15 #include <asm/psr.h>
16 #include <asm/page.h>
17 #include <asm/kdebug.h>
18 #include <asm/winmacro.h>
19
20 .data
21
22
23
24
25
26 .align 4
27 .globl C_LABEL(cputyp)
28 C_LABEL(cputyp):
29 .word 1
30
31 .align 4
32 .globl C_LABEL(cputypval)
33 C_LABEL(cputypval):
34 .asciz "sun4c"
35 .ascii " "
36
37 C_LABEL(cputypvalend):
38 C_LABEL(cputypvallen) = C_LABEL(cputypvar) - C_LABEL(cputypval)
39
40 .align 4
41
42
43
44
45
46
47
48
49 C_LABEL(cputypvar):
50 .asciz "compatability"
51
52
53 .align 4
54 C_LABEL(cputypvar_sun4m):
55 .asciz "compatible"
56
57 .align 4
58 sun4_notsup:
59 .asciz "Sparc-Linux sun4 support not implemented yet\n\n"
60 .align 4
61
62 sun4d_notsup:
63 .asciz "Sparc-Linux sun4d support does not exist\n\n"
64 .align 4
65
66 sun4e_notsup:
67 .asciz "Sparc-Linux sun4e support does not exist\n\n"
68 .align 4
69
70 sun4u_notsup:
71 .asciz "Sparc-Linux sun4u support does not exist\n\n"
72 .align 4
73
74
75 .text
76 .globl start, _stext, _start, __stext
77 .globl C_LABEL(trapbase)
78 _start:
79 __stext:
80 _stext:
81 start:
82 C_LABEL(trapbase):
83
84 t_zero: b gokernel; nop; nop; nop;
85 t_tflt: TRAP_ENTRY(0x1, sparc_fault)
86 t_bins: TRAP_ENTRY(0x2, bad_instruction)
87 t_pins: TRAP_ENTRY(0x3, priv_instruction)
88 t_fpd: TRAP_ENTRY(0x4, fpd_trap_handler)
89 t_wovf: WINDOW_SPILL
90 t_wunf: WINDOW_FILL
91 t_mna: TRAP_ENTRY(0x7, mna_handler)
92 t_fpe: TRAP_ENTRY(0x8, fpe_trap_handler)
93 t_dflt: TRAP_ENTRY(0x9, sparc_fault)
94 t_tio: TRAP_ENTRY(0xa, do_tag_overflow)
95 t_wpt: TRAP_ENTRY(0xb, do_watchpoint)
96 t_badc: BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
97 t_irq1: TRAP_ENTRY_SOFTINT(1)
98 t_irq2: TRAP_ENTRY_INTERRUPT(2)
99 t_irq3: TRAP_ENTRY_INTERRUPT(3)
100 t_irq4: TRAP_ENTRY_SOFTINT(4)
101 t_irq5: TRAP_ENTRY_INTERRUPT(5)
102 t_irq6: TRAP_ENTRY_SOFTINT(6)
103 t_irq7: TRAP_ENTRY_INTERRUPT(7)
104 t_irq8: TRAP_ENTRY_INTERRUPT(8)
105 t_irq9: TRAP_ENTRY_INTERRUPT(9)
106 t_irq10:TRAP_ENTRY_INTERRUPT(10)
107 t_irq11:TRAP_ENTRY_INTERRUPT(11)
108 t_irq12:TRAP_ENTRY_INTERRUPT(12)
109 t_irq13:TRAP_ENTRY_INTERRUPT(13)
110 t_irq14:TRAP_ENTRY_INTERRUPT(14)
111 t_nmi: NMI_TRAP
112 t_racc: TRAP_ENTRY(0x20, do_reg_access)
113 t_iacce:TRAP_ENTRY(0x21, sparc_fault)
114 t_bad22:BAD_TRAP(0x22) BAD_TRAP(0x23)
115 t_cpdis:TRAP_ENTRY(0x24, do_cp_disabled)
116 t_uflsh:TRAP_ENTRY(0x25, do_bad_flush)
117 t_bad26:BAD_TRAP(0x26) BAD_TRAP(0x27)
118 t_cpexc:TRAP_ENTRY(0x28, do_cp_exception)
119 t_dacce:TRAP_ENTRY(0x29, sparc_fault)
120 t_hwdz: TRAP_ENTRY(0x2a, do_hw_divzero)
121 t_dserr:TRAP_ENTRY(0x2b, sparc_fault)
122 t_daccm:TRAP_ENTRY(0x2c, sparc_fault)
123 t_bad2d:BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
124 t_bad32:BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
125 t_bad37:BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
126 t_iaccm:TRAP_ENTRY(0x3c, sparc_fault)
127 t_bad3d:BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40) BAD_TRAP(0x41)
128 t_bad42:BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45) BAD_TRAP(0x46)
129 t_bad47:BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a) BAD_TRAP(0x4b)
130 t_bad4c:BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f) BAD_TRAP(0x50)
131 t_bad51:BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
132 t_bad56:BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
133 t_bad5b:BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
134 t_bad60:BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
135 t_bad65:BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
136 t_bad6a:BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
137 t_bad6f:BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
138 t_bad74:BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
139 t_bad79:BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
140 t_bad7e:BAD_TRAP(0x7e) BAD_TRAP(0x7f)
141 t_sunos:SUNOS_SYSCALL_TRAP
142 t_sbkpt:BAD_TRAP(0x81)
143 t_divz: BAD_TRAP(0x82)
144 t_flwin:TRAP_ENTRY(0x83, do_flush_windows)
145 t_clwin:BAD_TRAP(0x84)
146 t_rchk: BAD_TRAP(0x85)
147 t_funal:BAD_TRAP(0x86)
148 t_iovf: BAD_TRAP(0x87)
149 t_slowl:SOLARIS_SYSCALL_TRAP
150 t_netbs:NETBSD_SYSCALL_TRAP
151 t_bad8a:BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) BAD_TRAP(0x8d) BAD_TRAP(0x8e)
152 t_bad8f:BAD_TRAP(0x8f)
153 t_linux:LINUX_SYSCALL_TRAP
154 t_bad91:BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94) BAD_TRAP(0x95)
155 t_bad96:BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99) BAD_TRAP(0x9a)
156 t_bad9b:BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e) BAD_TRAP(0x9f)
157 t_getcc:GETCC_TRAP
158 t_setcc:SETCC_TRAP
159 t_bada2:BAD_TRAP(0xa2) BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
160 t_bada7:BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
161 t_badac:BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
162 t_badb1:BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
163 t_badb6:BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
164 t_badbb:BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
165 t_badc0:BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
166 t_badc5:BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
167 t_badca:BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
168 t_badcf:BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
169 t_badd4:BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
170 t_badd9:BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
171 t_badde:BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
172 t_bade3:BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
173 t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
174 t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
175 t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
176 t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
177 t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd)
178 dbtrap: BAD_TRAP(0xfe)
179 dbtrap2:BAD_TRAP(0xff)
180
181 .globl C_LABEL(end_traptable)
182 C_LABEL(end_traptable):
183
184 .skip 4096
185
186
187
188
189
190 .globl C_LABEL(auxio_reg_addr)
191 C_LABEL(auxio_reg_addr): .skip (PAGE_SIZE)
192
193 .globl C_LABEL(clock_reg_addr)
194 C_LABEL(clock_reg_addr): .skip (PAGE_SIZE*5)
195
196 .globl C_LABEL(int_reg_addr)
197 C_LABEL(int_reg_addr): .skip (PAGE_SIZE*5)
198
199 .globl C_LABEL(bootup_user_stack)
200 .globl C_LABEL(bootup_kernel_stack)
201 .globl C_LABEL(pg0)
202 .globl C_LABEL(empty_bad_page)
203 .globl C_LABEL(empty_bad_page_table)
204 .globl C_LABEL(empty_zero_page)
205 .globl C_LABEL(swapper_pg_dir)
206 C_LABEL(bootup_user_stack): .skip 0x1000
207 C_LABEL(bootup_kernel_stack): .skip 0x1000
208 C_LABEL(swapper_pg_dir): .skip 0x1000
209 C_LABEL(pg0): .skip 0x1000
210 C_LABEL(empty_bad_page): .skip 0x1000
211 C_LABEL(empty_bad_page_table): .skip 0x1000
212 C_LABEL(empty_zero_page): .skip 0x1000
213
214
215
216
217
218
219 gokernel:
220
221
222
223
224
225
226
227
228
229
230
231
232
233 mov %o7, %g4 ! Save %o7
234
235
236 current_pc:
237 call 1f
238 nop
239
240 1:
241 mov %o7, %g3
242
243 got_pc:
244 mov %g4, %o7
245
246 mov %o0, %l0 ! stash away romvec
247 mov %o0, %g7 ! put it here too
248 mov %o1, %l1 ! stash away debug_vec too
249
250
251 set current_pc, %g5
252 cmp %g3, %g5
253 be already_mapped
254 nop
255
256
257
258
259
260
261
262 set PAGE_OFFSET, %l6
263 b copy_prom_lvl14
264 nop
265
266 already_mapped:
267 mov 0, %l6
268
269
270 copy_prom_lvl14:
271 rd %tbr, %g1
272 andn %g1, 0xfff, %g1 ! proms trap table base
273 or %g0, (0x1e<<4), %g2 ! offset to lvl14 intr
274 or %g1, %g2, %g2
275 set t_irq14, %g3
276 sub %g3, %l6, %g3
277 ldd [%g2], %g4
278 std %g4, [%g3]
279 ldd [%g2 + 0x8], %g4
280 std %g4, [%g3 + 0x8] ! Copy proms handler
281
282
283 copy_prom_bpoint:
284 or %g0, (0xfe<<4), %g2
285 or %g1, %g2, %g2
286 set dbtrap, %g3
287 sub %g3, %l6, %g3
288 ldd [%g2], %g4
289 std %g4, [%g3]
290 ldd [%g2 + 0x8], %g4
291 std %g4, [%g3 + 0x8]
292 ldd [%g2 + 0x10], %g4
293 std %g4, [%g3 + 0x10]
294 ldd [%g2 + 0x18], %g4
295 std %g4, [%g3 + 0x18]
296
297
298
299
300
301
302
303
304
305
306 copy_prom_done:
307 cmp %l6, 0
308 be go_to_highmem ! this will be a nop then
309 nop
310
311 set LOAD_ADDR, %g6
312 cmp %g7, %g6
313 bne remap_not_a_sun4 ! This is not a Sun4
314 nop
315
316 or %g0, 0x1, %g1
317 lduba [%g1] ASI_CONTROL, %g1 ! Only safe to try on Sun4.
318 subcc %g1, 0x24, %g0 ! Is this a mutant Sun4/400???
319 be sun4_mutant_remap ! Ugh, it is...
320 nop
321
322 remap_not_a_sun4:
323 lda [%g0] ASI_M_MMUREGS, %g1 ! same as ASI_PTE on sun4c
324 and %g1, 0x1, %g1 ! Test SRMMU Enable bit ;-)
325 cmp %g1, 0x0
326 be sun4c_remap ! A sun4c MMU or normal Sun4
327 nop
328 srmmu_remap:
329
330 set 0x40000000, %g2
331 rd %psr, %g3
332 and %g2, %g3, %g3
333 subcc %g3, 0x0, %g0
334 bz srmmu_nviking
335 nop
336
337
338
339
340
341
342
343
344
345 set 0x800, %g2
346 lda [%g0] ASI_M_MMUREGS, %g3 ! peek in the control reg
347 and %g2, %g3, %g3
348 subcc %g3, 0x0, %g0
349 bnz srmmu_nviking ! is in mbus mode
350 nop
351
352 rd %psr, %g3 ! DONT TOUCH %g3
353 andn %g3, PSR_ET, %g2
354 wr %g2, 0x0, %psr
355 WRITE_PAUSE
356
357
358
359
360 set AC_M_CTPR, %g4
361 lda [%g4] ASI_M_MMUREGS, %g4
362 sll %g4, 0x4, %g4 ! We use this below
363 ! DONT TOUCH %g4
364
365
366 lda [%g0] ASI_M_MMUREGS, %g5 ! DONT TOUCH %g5
367 set 0x8000, %g6 ! AC bit mask
368 or %g5, %g6, %g6 ! Or it in...
369 sta %g6, [%g0] ASI_M_MMUREGS ! Close your eyes...
370
371
372
373
374
375
376 lda [%g4] ASI_M_BYPASS, %o1 ! This is a level 1 ptr
377 srl %o1, 0x4, %o1 ! Clear low 4 bits
378 sll %o1, 0x8, %o1 ! Make physical
379
380
381 lda [%o1] ASI_M_BYPASS, %o2 ! This is the 0x0 16MB pgd
382
383
384
385
386
387
388 add %o1, 0x3c0, %o3
389
390
391 sta %o2, [%o3] ASI_M_BYPASS
392
393
394
395
396
397
398
399
400
401
402
403
404 sta %g5, [%g0] ASI_M_MMUREGS ! POW... ouch
405
406
407 wr %g3, 0x0, %psr ! tick tock, tick tock
408
409
410 WRITE_PAUSE
411
412
413
414
415 b go_to_highmem
416 nop
417
418
419
420
421
422
423 srmmu_nviking:
424 set AC_M_CTPR, %g1
425 lda [%g1] ASI_M_MMUREGS, %g1 ! get ctx table ptr
426 sll %g1, 0x4, %g1 ! make physical addr
427 lda [%g1] ASI_M_BYPASS, %g1 ! ptr to level 1 pg_table
428 srl %g1, 0x4, %g1
429 sll %g1, 0x8, %g1 ! make phys addr for l1 tbl
430
431 lda [%g1] ASI_M_BYPASS, %g2 ! get level1 entry for 0x0
432 add %g1, 0x3c0, %g3 ! XXX AWAY WITH IMPERICALS
433 sta %g2, [%g3] ASI_M_BYPASS ! place at KERNBASE entry
434 b go_to_highmem
435 nop ! wheee....
436
437
438
439
440
441
442
443
444
445
446
447
448 sun4_mutant_remap:
449 or %g0, %g0, %g3 ! source base
450 sethi %hi(KERNBASE), %g4 ! destination base
451 or %g4, %lo(KERNBASE), %g4
452 sethi %hi(0x300000), %g5
453 or %g5, %lo(0x300000), %g5 ! upper bound 3MB
454 or %g0, 0x1, %l6
455 sll %l6, 24, %l6 ! Regmap mapping size
456 add %g3, 0x2, %g3 ! Base magic
457 add %g4, 0x2, %g4 ! Base magic
458
459
460
461
462 sun4_mutant_loop:
463 lduha [%g3] ASI_REGMAP, %g2 ! Get lower entry
464 stha %g2, [%g4] ASI_REGMAP ! Store in high entry
465 add %g4, %l6, %g4 ! Move up high memory ptr
466 subcc %g3, %g5, %g0 ! Reached our limit?
467 blu sun4_mutant_loop ! Nope, loop again
468 add %g3, %l6, %g3 ! delay, Move up low ptr
469 b go_to_highmem ! Jump to high memory.
470 nop
471
472
473 sun4c_remap:
474 mov 0, %g3 ! source base
475 set KERNBASE, %g4 ! destination base
476 set 0x300000, %g5 ! upper bound 3MB
477 mov 1, %l6
478 sll %l6, 18, %l6 ! sun4c mmu segmap size
479 sun4c_remap_loop:
480 lda [%g3] ASI_SEGMAP, %g6 ! load phys_seg
481 sta %g6, [%g4] ASI_SEGMAP ! store new virt mapping
482 add %g3, %l6, %g3 ! Increment source ptr
483 subcc %g3, %g5, %g0 ! Reached limit?
484 bl sun4c_remap_loop ! Nope, loop again
485 add %g4, %l6, %g4 ! delay, Increment dest ptr
486
487
488 go_to_highmem:
489 set execute_in_high_mem, %g1
490 jmpl %g1, %g0
491 nop
492
493
494
495
496 execute_in_high_mem:
497 mov %l0, %o0 ! put back romvec
498 mov %l1, %o1 ! and debug_vec
499
500 sethi %hi( C_LABEL(prom_vector_p) ), %g1
501 st %o0, [%g1 + %lo( C_LABEL(prom_vector_p) )]
502
503 sethi %hi( C_LABEL(linux_dbvec) ), %g1
504 st %o1, [%g1 + %lo( C_LABEL(linux_dbvec) )]
505
506 ld [%o0 + 0x4], %o3
507 and %o3, 0x3, %o5 ! get the version
508
509 cmp %o3, 0x2 ! a v2 prom?
510 be found_version
511 nop
512
513
514 cmp %o3, 0x3 ! a v3 prom?
515 be found_version
516 nop
517
518
519
520
521
522
523
524 set LOAD_ADDR, %g6
525 cmp %o0, %g6 ! an old sun4?
526 be no_sun4_here
527 nop
528
529 found_version:
530
531
532
533 or %g0, %g7, %l1
534 add %l1, 0x1c, %l1
535 ld [%l1], %l0
536 ld [%l0], %l0
537 call %l0
538 or %g0, %g0, %o0 ! next_node(0) = first_node
539 or %o0, %g0, %g6
540
541 sethi %hi( C_LABEL(cputypvar) ), %o1 ! First node has cpu-arch
542 or %o1, %lo( C_LABEL(cputypvar) ), %o1
543 sethi %hi( C_LABEL(cputypval) ), %o2 ! information, the string
544 or %o2, %lo( C_LABEL(cputypval) ), %o2
545 ld [%l1], %l0 ! 'compatibility' tells
546 ld [%l0 + 0xc], %l0 ! that we want 'sun4x' where
547 call %l0 ! x is one of '', 'c', 'm',
548 nop ! 'd' or 'e'. %o2 holds pointer
549 ! to a buf where above string
550 ! will get stored by the prom.
551
552 subcc %o0, %g0, %g0
553 bpos got_prop ! Got the property
554 nop
555
556 or %g6, %g0, %o0
557 sethi %hi( C_LABEL(cputypvar_sun4m) ), %o1
558 or %o1, %lo( C_LABEL(cputypvar_sun4m) ), %o1
559 sethi %hi( C_LABEL(cputypval) ), %o2
560 or %o2, %lo( C_LABEL(cputypval) ), %o2
561 ld [%l1], %l0
562 ld [%l0 + 0xc], %l0
563 call %l0
564 nop
565
566 got_prop:
567 set C_LABEL(cputypval), %o2
568 ldub [%o2 + 0x4], %l1
569
570 cmp %l1, 'c' ! We already know we are not
571 be 1f ! on a plain sun4 because of
572 nop ! the check for 0x4000 in %o0
573
574 cmp %l1, 'm' ! at start
575 be 1f
576 nop
577
578 cmp %l1, 'd'
579 be no_sun4d_here ! God bless the person who
580 nop ! tried to run this on sun4d.
581
582 cmp %l1, 'e'
583 be no_sun4e_here ! Could be a sun4e.
584 nop
585
586 b no_sun4u_here ! AIEEE, a V9 sun4u...
587 nop
588
589
590 1:
591 set C_LABEL(cputypval), %l1
592 ldub [%l1 + 0x4], %l1
593 cmp %l1, 'm' ! Test for sun4d, sun4e ?
594 be sun4m_init
595 nop
596
597
598 set AC_CONTEXT, %g1
599 stba %g0, [%g1] ASI_CONTROL
600
601 b sun4c_continue_boot
602 nop
603
604 sun4m_init:
605
606
607
608
609
610
611
612 rd %psr, %o1
613 srl %o1, 28, %o1 ! Get a type of the CPU
614
615 subcc %o1, 4, %g0 ! TI: Viking or MicroSPARC
616 be sun4c_continue_boot
617 nop
618
619 set AC_M_SFSR, %o0
620 lda [%o0] ASI_M_MMUREGS, %g0
621 set AC_M_SFAR, %o0
622 lda [%o0] ASI_M_MMUREGS, %g0
623
624
625 subcc %o1, 0, %g0
626 be sun4c_continue_boot
627 nop
628
629 set AC_M_AFSR, %o0
630 lda [%o0] ASI_M_MMUREGS, %g0
631 set AC_M_AFAR, %o0
632 lda [%o0] ASI_M_MMUREGS, %g0
633 nop
634
635
636 sun4c_continue_boot:
637
638
639
640
641
642
643 sethi %hi( C_LABEL(cputyp) ), %o0
644 st %g4, [%o0 + %lo( C_LABEL(cputyp) )]
645
646
647
648
649 set (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
650 wr %g2, 0x0, %psr
651 WRITE_PAUSE
652
653
654 set C_LABEL(bootup_user_stack), %g1
655 add %g1, (PAGE_SIZE - STACKFRAME_SZ - TRACEREG_SZ), %sp
656 mov 0, %fp
657
658
659 set C_LABEL(edata) , %o0 ! First address of BSS
660 set C_LABEL(end) , %o1 ! Last address of BSS
661 add %o0, 0x1, %o0
662 1:
663 stb %g0, [%o0]
664 subcc %o0, %o1, %g0
665 bl 1b
666 add %o0, 0x1, %o0
667
668
669
670
671 set C_LABEL(init_task), %g4
672 set C_LABEL(current_set), %g2
673 st %g4, [%g2]
674
675
676 LOAD_CURRENT(g2)
677 set C_LABEL(bootup_kernel_stack), %g4
678 st %g4, [%g2 + TASK_KSTACK_PG]
679 st %g0, [%g2 + THREAD_UMASK]
680
681
682
683
684
685
686 wr %g0, 0x0, %wim ! so we dont get a trap
687 WRITE_PAUSE
688
689 save
690
691 rd %psr, %g3
692
693 restore
694
695 and %g3, 0x1f, %g3
696 add %g3, 0x1, %g3
697
698 mov 2, %g1
699 wr %g1, 0x0, %wim ! make window 1 invalid
700 WRITE_PAUSE
701
702 cmp %g3, 0x7
703 bne 2f
704 nop
705
706
707
708
709
710 #define PATCH_INSN(src, dest) \
711 set src, %g5; \
712 set dest, %g6; \
713 ld [%g5], %g4; \
714 st %g4, [%g6];
715
716
717 PATCH_INSN(spnwin_patch1_7win, spnwin_patch1)
718 PATCH_INSN(spnwin_patch2_7win, spnwin_patch2)
719 PATCH_INSN(spnwin_patch3_7win, spnwin_patch3)
720
721
722 PATCH_INSN(fnwin_patch1_7win, fnwin_patch1)
723 PATCH_INSN(fnwin_patch2_7win, fnwin_patch2)
724
725
726 PATCH_INSN(tsetup_7win_patch1, tsetup_patch1)
727 PATCH_INSN(tsetup_7win_patch2, tsetup_patch2)
728 PATCH_INSN(tsetup_7win_patch3, tsetup_patch3)
729 PATCH_INSN(tsetup_7win_patch4, tsetup_patch4)
730 PATCH_INSN(tsetup_7win_patch5, tsetup_patch5)
731 PATCH_INSN(tsetup_7win_patch6, tsetup_patch6)
732
733
734 PATCH_INSN(rtrap_7win_patch1, rtrap_patch1)
735 PATCH_INSN(rtrap_7win_patch2, rtrap_patch2)
736 PATCH_INSN(rtrap_7win_patch3, rtrap_patch3)
737 PATCH_INSN(rtrap_7win_patch4, rtrap_patch4)
738 PATCH_INSN(rtrap_7win_patch5, rtrap_patch5)
739
740 2:
741 sethi %hi( C_LABEL(nwindows) ), %g4
742 st %g3, [%g4 + %lo( C_LABEL(nwindows) )] ! store final value
743 sub %g3, 0x1, %g3
744 sethi %hi( C_LABEL(nwindowsm1) ), %g4
745 st %g3, [%g4 + %lo( C_LABEL(nwindowsm1) )]
746
747
748 set C_LABEL(trapbase), %g3
749 wr %g3, 0x0, %tbr
750 WRITE_PAUSE
751
752
753 rd %psr, %g3
754 wr %g3, 0x0, %psr
755 wr %g3, PSR_ET, %psr
756 WRITE_PAUSE
757
758
759
760
761
762 sethi %hi( C_LABEL(prom_vector_p) ), %g5
763 ld [%g5 + %lo( C_LABEL(prom_vector_p) )], %o0
764 call C_LABEL(prom_init)
765 nop
766
767 call C_LABEL(start_kernel)
768 nop
769
770
771 call halt_me
772 nop
773
774
775
776
777 no_sun4_here:
778 sethi %hi(SUN4_PROM_VECTOR+SUN4_PRINTF), %o1
779 ld [%o1 + %lo(SUN4_PROM_VECTOR+SUN4_PRINTF)], %o1
780 set sun4_notsup, %o0
781 call %o1
782 nop
783 1:
784 ba 1b ! Cannot exit into KMON
785 nop
786
787 no_sun4d_here:
788 ld [%g7 + 0x68], %o1
789 set sun4d_notsup, %o0
790 call %o1
791 nop
792 b halt_me
793 nop
794
795 no_sun4e_here:
796 ld [%g7 + 0x68], %o1
797 set sun4e_notsup, %o0
798 call %o1
799 nop
800 b halt_me
801 nop
802
803 no_sun4u_here:
804 ld [%g7 + 0x68], %o1
805 set sun4u_notsup, %o0
806 call %o1
807 nop
808 b halt_me
809 nop
810
811 halt_me:
812 ld [%g7 + 0x74], %o0
813 call %o0 ! Get us out of here...
814 nop ! Apparently Solaris is better.
815
816 .data
817 .align 4
818
819
820
821
822
823
824
825 .globl C_LABEL(prom_vector_p)
826 C_LABEL(prom_vector_p):
827 .word 0
828
829
830
831
832
833 .align 4
834 .globl C_LABEL(nwindows)
835 .globl C_LABEL(nwindowsm1)
836 C_LABEL(nwindows):
837 .word 8
838 C_LABEL(nwindowsm1):
839 .word 7
840
841
842
843 .align 4
844 .globl C_LABEL(linux_dbvec)
845 C_LABEL(linux_dbvec):
846 .word 0
847 .word 0
848
849 .align 4