blob: 50d9a16af795c5d675fefd40a3e17cab5f486840 [file] [log] [blame]
Adrian Bunk88278ca2008-05-19 16:53:02 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * head.S: The initial boot code for the Sparc port of Linux.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1995,1999 Pete Zaitcev (zaitcev@yahoo.com)
6 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
7 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
8 * Copyright (C) 1997 Michael A. Griffith (grif@acm.org)
9 *
10 * CompactPCI platform by Eric Brower, 1999.
11 */
12
13#include <linux/version.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#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>
Robert Reif19fce2b2007-05-14 03:22:08 -070022#include <asm/kdebug.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <asm/winmacro.h>
24#include <asm/thread_info.h> /* TI_UWINMASK */
25#include <asm/errno.h>
26#include <asm/pgtsrmmu.h> /* SRMMU_PGDIR_SHIFT */
27
28 .data
29/*
30 * The following are used with the prom_vector node-ops to figure out
31 * the cpu-type
32 */
33
34 .align 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070035cputyp:
36 .word 1
37
38 .align 4
39 .globl cputypval
40cputypval:
41 .asciz "sun4c"
42 .ascii " "
43
44cputypvalend:
45cputypvallen = cputypvar - cputypval
46
47 .align 4
48/*
49 * Sun people can't spell worth damn. "compatability" indeed.
50 * At least we *know* we can't spell, and use a spell-checker.
51 */
52
53/* Uh, actually Linus it is I who cannot spell. Too much murky
54 * Sparc assembly will do this to ya.
55 */
56cputypvar:
57 .asciz "compatability"
58
59/* Tested on SS-5, SS-10. Probably someone at Sun applied a spell-checker. */
60 .align 4
61cputypvar_sun4m:
62 .asciz "compatible"
63
64 .align 4
65
66#ifndef CONFIG_SUN4
67sun4_notsup:
68 .asciz "Sparc-Linux sun4 needs a specially compiled kernel, turn CONFIG_SUN4 on.\n\n"
69 .align 4
70#else
71sun4cdm_notsup:
72 .asciz "Kernel compiled with CONFIG_SUN4 cannot run on SUN4C/SUN4M/SUN4D\nTurn CONFIG_SUN4 off.\n\n"
73 .align 4
74#endif
75
76sun4e_notsup:
77 .asciz "Sparc-Linux sun4e support does not exist\n\n"
78 .align 4
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 /* The Sparc trap table, bootloader gives us control at _start. */
81 .text
82 .globl start, _stext, _start, __stext
83 .globl trapbase
84_start: /* danger danger */
85__stext:
86_stext:
87start:
88trapbase:
89#ifdef CONFIG_SMP
90trapbase_cpu0:
91#endif
92/* We get control passed to us here at t_zero. */
93t_zero: b gokernel; nop; nop; nop;
94t_tflt: SPARC_TFAULT /* Inst. Access Exception */
95t_bins: TRAP_ENTRY(0x2, bad_instruction) /* Illegal Instruction */
96t_pins: TRAP_ENTRY(0x3, priv_instruction) /* Privileged Instruction */
97t_fpd: TRAP_ENTRY(0x4, fpd_trap_handler) /* Floating Point Disabled */
98t_wovf: WINDOW_SPILL /* Window Overflow */
99t_wunf: WINDOW_FILL /* Window Underflow */
100t_mna: TRAP_ENTRY(0x7, mna_handler) /* Memory Address Not Aligned */
101t_fpe: TRAP_ENTRY(0x8, fpe_trap_handler) /* Floating Point Exception */
102t_dflt: SPARC_DFAULT /* Data Miss Exception */
103t_tio: TRAP_ENTRY(0xa, do_tag_overflow) /* Tagged Instruction Ovrflw */
104t_wpt: TRAP_ENTRY(0xb, do_watchpoint) /* Watchpoint Detected */
105t_badc: BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
106t_irq1: TRAP_ENTRY_INTERRUPT(1) /* IRQ Software/SBUS Level 1 */
107t_irq2: TRAP_ENTRY_INTERRUPT(2) /* IRQ SBUS Level 2 */
108t_irq3: TRAP_ENTRY_INTERRUPT(3) /* IRQ SCSI/DMA/SBUS Level 3 */
109t_irq4: TRAP_ENTRY_INTERRUPT(4) /* IRQ Software Level 4 */
110t_irq5: TRAP_ENTRY_INTERRUPT(5) /* IRQ SBUS/Ethernet Level 5 */
111t_irq6: TRAP_ENTRY_INTERRUPT(6) /* IRQ Software Level 6 */
112t_irq7: TRAP_ENTRY_INTERRUPT(7) /* IRQ Video/SBUS Level 5 */
113t_irq8: TRAP_ENTRY_INTERRUPT(8) /* IRQ SBUS Level 6 */
114t_irq9: TRAP_ENTRY_INTERRUPT(9) /* IRQ SBUS Level 7 */
115t_irq10:TRAP_ENTRY_INTERRUPT(10) /* IRQ Timer #1 (one we use) */
116t_irq11:TRAP_ENTRY_INTERRUPT(11) /* IRQ Floppy Intr. */
117t_irq12:TRAP_ENTRY_INTERRUPT(12) /* IRQ Zilog serial chip */
118t_irq13:TRAP_ENTRY_INTERRUPT(13) /* IRQ Audio Intr. */
119t_irq14:TRAP_ENTRY_INTERRUPT(14) /* IRQ Timer #2 */
120 .globl t_nmi
121#ifndef CONFIG_SMP
122t_nmi: NMI_TRAP /* Level 15 (NMI) */
123#else
124t_nmi: TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
125#endif
126t_racc: TRAP_ENTRY(0x20, do_reg_access) /* General Register Access Error */
127t_iacce:BAD_TRAP(0x21) /* Instr Access Error */
128t_bad22:BAD_TRAP(0x22) BAD_TRAP(0x23)
129t_cpdis:TRAP_ENTRY(0x24, do_cp_disabled) /* Co-Processor Disabled */
130t_uflsh:SKIP_TRAP(0x25, unimp_flush) /* Unimplemented FLUSH inst. */
131t_bad26:BAD_TRAP(0x26) BAD_TRAP(0x27)
132t_cpexc:TRAP_ENTRY(0x28, do_cp_exception) /* Co-Processor Exception */
133t_dacce:SPARC_DFAULT /* Data Access Error */
134t_hwdz: TRAP_ENTRY(0x2a, do_hw_divzero) /* Division by zero, you lose... */
135t_dserr:BAD_TRAP(0x2b) /* Data Store Error */
136t_daccm:BAD_TRAP(0x2c) /* Data Access MMU-Miss */
137t_bad2d:BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
138t_bad32:BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
139t_bad37:BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
140t_iaccm:BAD_TRAP(0x3c) /* Instr Access MMU-Miss */
141t_bad3d:BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40) BAD_TRAP(0x41)
142t_bad42:BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45) BAD_TRAP(0x46)
143t_bad47:BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a) BAD_TRAP(0x4b)
144t_bad4c:BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f) BAD_TRAP(0x50)
145t_bad51:BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
146t_bad56:BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
147t_bad5b:BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
148t_bad60:BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
149t_bad65:BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
150t_bad6a:BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
151t_bad6f:BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
152t_bad74:BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
153t_bad79:BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
154t_bad7e:BAD_TRAP(0x7e) BAD_TRAP(0x7f)
David S. Millerec98c6b2008-04-20 02:14:23 -0700155t_bad80:BAD_TRAP(0x80) /* SunOS System Call */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156t_sbkpt:BREAKPOINT_TRAP /* Software Breakpoint/KGDB */
157t_divz: TRAP_ENTRY(0x82, do_hw_divzero) /* Divide by zero trap */
158t_flwin:TRAP_ENTRY(0x83, do_flush_windows) /* Flush Windows Trap */
159t_clwin:BAD_TRAP(0x84) /* Clean Windows Trap */
160t_rchk: BAD_TRAP(0x85) /* Range Check */
161t_funal:BAD_TRAP(0x86) /* Fix Unaligned Access Trap */
162t_iovf: BAD_TRAP(0x87) /* Integer Overflow Trap */
David S. Millerec98c6b2008-04-20 02:14:23 -0700163t_bad88:BAD_TRAP(0x88) /* Slowaris System Call */
164t_bad89:BAD_TRAP(0x89) /* Net-B.S. System Call */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165t_bad8a:BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) BAD_TRAP(0x8d) BAD_TRAP(0x8e)
166t_bad8f:BAD_TRAP(0x8f)
167t_linux:LINUX_SYSCALL_TRAP /* Linux System Call */
168t_bad91:BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94) BAD_TRAP(0x95)
169t_bad96:BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99) BAD_TRAP(0x9a)
170t_bad9b:BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e) BAD_TRAP(0x9f)
171t_getcc:GETCC_TRAP /* Get Condition Codes */
172t_setcc:SETCC_TRAP /* Set Condition Codes */
173t_getpsr:GETPSR_TRAP /* Get PSR Register */
174t_bada3:BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
David S. Millerec98c6b2008-04-20 02:14:23 -0700175t_bada7:BAD_TRAP(0xa7)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176t_bada8:BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
177t_badac:BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
178t_badb1:BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
179t_badb6:BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
180t_badbb:BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
181t_badc0:BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
182t_badc5:BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
183t_badca:BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
184t_badcf:BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
185t_badd4:BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
186t_badd9:BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
187t_badde:BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
188t_bade3:BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
189t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
190t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
191t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
192t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
David S. Millere2fdd7f2008-04-29 02:38:50 -0700193t_badfc:BAD_TRAP(0xfc)
194t_kgdb: KGDB_TRAP(0xfd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195dbtrap: BAD_TRAP(0xfe) /* Debugger/PROM breakpoint #1 */
196dbtrap2:BAD_TRAP(0xff) /* Debugger/PROM breakpoint #2 */
197
198 .globl end_traptable
199end_traptable:
200
201#ifdef CONFIG_SMP
202 /* Trap tables for the other cpus. */
203 .globl trapbase_cpu1, trapbase_cpu2, trapbase_cpu3
204trapbase_cpu1:
205 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
206 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
207 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
208 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
209 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
210 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
211 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
212 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
213 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
214 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
215 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
216 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
217 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
218 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
219 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
220 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
221 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
222 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
223 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
224 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
225 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
226 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
227 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
228 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
229 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
230 BAD_TRAP(0x50)
231 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
232 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
233 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
234 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
235 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
236 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
237 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
238 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
239 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
240 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
David S. Millerec98c6b2008-04-20 02:14:23 -0700241 BAD_TRAP(0x80)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 BREAKPOINT_TRAP
243 TRAP_ENTRY(0x82, do_hw_divzero)
244 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
David S. Millerec98c6b2008-04-20 02:14:23 -0700245 BAD_TRAP(0x86) BAD_TRAP(0x87) BAD_TRAP(0x88)
246 BAD_TRAP(0x89) BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
248 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
249 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
250 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
251 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
252 BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
David S. Millerec98c6b2008-04-20 02:14:23 -0700253 BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
255 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
256 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
257 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
258 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
259 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
260 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
261 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
262 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
263 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
264 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
265 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
266 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
267 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
268 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
269 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
David S. Millere2fdd7f2008-04-29 02:38:50 -0700270 BAD_TRAP(0xfc) KGDB_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
272trapbase_cpu2:
273 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
274 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
275 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
276 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
277 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
278 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
279 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
280 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
281 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
282 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
283 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
284 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
285 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
286 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
287 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
288 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
289 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
290 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
291 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
292 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
293 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
294 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
295 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
296 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
297 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
298 BAD_TRAP(0x50)
299 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
300 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
301 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
302 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
303 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
304 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
305 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
306 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
307 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
308 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
David S. Millerec98c6b2008-04-20 02:14:23 -0700309 BAD_TRAP(0x80)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 BREAKPOINT_TRAP
311 TRAP_ENTRY(0x82, do_hw_divzero)
312 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
David S. Millerec98c6b2008-04-20 02:14:23 -0700313 BAD_TRAP(0x86) BAD_TRAP(0x87) BAD_TRAP(0x88)
314 BAD_TRAP(0x89) BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
316 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
317 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
318 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
319 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
320 BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
David S. Millerec98c6b2008-04-20 02:14:23 -0700321 BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
323 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
324 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
325 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
326 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
327 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
328 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
329 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
330 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
331 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
332 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
333 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
334 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
335 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
336 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
337 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
David S. Millere2fdd7f2008-04-29 02:38:50 -0700338 BAD_TRAP(0xfc) KGDB_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
340trapbase_cpu3:
341 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
342 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
343 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
344 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
345 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
346 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
347 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
348 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
349 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
350 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
351 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
352 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
353 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
354 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
355 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
356 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
357 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
358 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
359 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
360 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
361 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
362 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
363 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
364 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
365 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
366 BAD_TRAP(0x50)
367 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
368 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
369 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
370 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
371 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
372 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
373 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
374 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
375 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
376 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
David S. Millerec98c6b2008-04-20 02:14:23 -0700377 BAD_TRAP(0x80)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 BREAKPOINT_TRAP
379 TRAP_ENTRY(0x82, do_hw_divzero)
380 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
David S. Millerec98c6b2008-04-20 02:14:23 -0700381 BAD_TRAP(0x86) BAD_TRAP(0x87) BAD_TRAP(0x88)
382 BAD_TRAP(0x89) BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
384 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
385 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
386 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
387 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
388 BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
David S. Millerec98c6b2008-04-20 02:14:23 -0700389 BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
391 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
392 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
393 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
394 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
395 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
396 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
397 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
398 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
399 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
400 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
401 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
402 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
403 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
404 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
405 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
David S. Millere2fdd7f2008-04-29 02:38:50 -0700406 BAD_TRAP(0xfc) KGDB_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
408#endif
409 .align PAGE_SIZE
410
411/* This was the only reasonable way I could think of to properly align
412 * these page-table data structures.
413 */
414 .globl pg0, pg1, pg2, pg3
415 .globl empty_bad_page
416 .globl empty_bad_page_table
417 .globl empty_zero_page
418 .globl swapper_pg_dir
419swapper_pg_dir: .skip PAGE_SIZE
420pg0: .skip PAGE_SIZE
421pg1: .skip PAGE_SIZE
422pg2: .skip PAGE_SIZE
423pg3: .skip PAGE_SIZE
424empty_bad_page: .skip PAGE_SIZE
425empty_bad_page_table: .skip PAGE_SIZE
426empty_zero_page: .skip PAGE_SIZE
427
428 .global root_flags
429 .global ram_flags
430 .global root_dev
431 .global sparc_ramdisk_image
432 .global sparc_ramdisk_size
433
434/* This stuff has to be in sync with SILO and other potential boot loaders
435 * Fields should be kept upward compatible and whenever any change is made,
436 * HdrS version should be incremented.
437 */
438 .ascii "HdrS"
439 .word LINUX_VERSION_CODE
440 .half 0x0203 /* HdrS version */
441root_flags:
442 .half 1
443root_dev:
444 .half 0
445ram_flags:
446 .half 0
447sparc_ramdisk_image:
448 .word 0
449sparc_ramdisk_size:
450 .word 0
451 .word reboot_command
452 .word 0, 0, 0
453 .word _end
454
455/* Cool, here we go. Pick up the romvec pointer in %o0 and stash it in
456 * %g7 and at prom_vector_p. And also quickly check whether we are on
457 * a v0, v2, or v3 prom.
458 */
459gokernel:
460 /* Ok, it's nice to know, as early as possible, if we
461 * are already mapped where we expect to be in virtual
462 * memory. The Solaris /boot elf format bootloader
463 * will peek into our elf header and load us where
464 * we want to be, otherwise we have to re-map.
465 *
466 * Some boot loaders don't place the jmp'rs address
467 * in %o7, so we do a pc-relative call to a local
468 * label, then see what %o7 has.
469 */
470
471 mov %o7, %g4 ! Save %o7
472
473 /* Jump to it, and pray... */
474current_pc:
475 call 1f
476 nop
477
4781:
479 mov %o7, %g3
480
481 tst %o0
482 be no_sun4u_here
483 mov %g4, %o7 /* Previous %o7. */
484
485 mov %o0, %l0 ! stash away romvec
486 mov %o0, %g7 ! put it here too
487 mov %o1, %l1 ! stash away debug_vec too
488
489 /* Ok, let's check out our run time program counter. */
490 set current_pc, %g5
491 cmp %g3, %g5
492 be already_mapped
493 nop
494
495 /* %l6 will hold the offset we have to subtract
496 * from absolute symbols in order to access areas
497 * in our own image. If already mapped this is
498 * just plain zero, else it is KERNBASE.
499 */
500 set KERNBASE, %l6
501 b copy_prom_lvl14
502 nop
503
504already_mapped:
505 mov 0, %l6
506
507 /* Copy over the Prom's level 14 clock handler. */
508copy_prom_lvl14:
509#if 1
510 /* DJHR
511 * preserve our linked/calculated instructions
512 */
513 set lvl14_save, %g1
514 set t_irq14, %g3
515 sub %g1, %l6, %g1 ! translate to physical
516 sub %g3, %l6, %g3 ! translate to physical
517 ldd [%g3], %g4
518 std %g4, [%g1]
519 ldd [%g3+8], %g4
520 std %g4, [%g1+8]
521#endif
522 rd %tbr, %g1
523 andn %g1, 0xfff, %g1 ! proms trap table base
524 or %g0, (0x1e<<4), %g2 ! offset to lvl14 intr
525 or %g1, %g2, %g2
526 set t_irq14, %g3
527 sub %g3, %l6, %g3
528 ldd [%g2], %g4
529 std %g4, [%g3]
530 ldd [%g2 + 0x8], %g4
531 std %g4, [%g3 + 0x8] ! Copy proms handler
532
533/* Must determine whether we are on a sun4c MMU, SRMMU, or SUN4/400 MUTANT
534 * MMU so we can remap ourselves properly. DON'T TOUCH %l0 thru %l5 in these
535 * remapping routines, we need their values afterwards!
536 */
537 /* Now check whether we are already mapped, if we
538 * are we can skip all this garbage coming up.
539 */
540copy_prom_done:
541 cmp %l6, 0
542 be go_to_highmem ! this will be a nop then
543 nop
544
545 set LOAD_ADDR, %g6
546 cmp %g7, %g6
547 bne remap_not_a_sun4 ! This is not a Sun4
548 nop
549
550 or %g0, 0x1, %g1
551 lduba [%g1] ASI_CONTROL, %g1 ! Only safe to try on Sun4.
552 subcc %g1, 0x24, %g0 ! Is this a mutant Sun4/400???
553 be sun4_mutant_remap ! Ugh, it is...
554 nop
555
556 b sun4_normal_remap ! regular sun4, 2 level mmu
557 nop
558
559remap_not_a_sun4:
560 lda [%g0] ASI_M_MMUREGS, %g1 ! same as ASI_PTE on sun4c
561 and %g1, 0x1, %g1 ! Test SRMMU Enable bit ;-)
562 cmp %g1, 0x0
563 be sun4c_remap ! A sun4c MMU or normal Sun4
564 nop
565srmmu_remap:
566 /* First, check for a viking (TI) module. */
567 set 0x40000000, %g2
568 rd %psr, %g3
569 and %g2, %g3, %g3
570 subcc %g3, 0x0, %g0
571 bz srmmu_nviking
572 nop
573
574 /* Figure out what kind of viking we are on.
575 * We need to know if we have to play with the
576 * AC bit and disable traps or not.
577 */
578
579 /* I've only seen MicroSparc's on SparcClassics with this
580 * bit set.
581 */
582 set 0x800, %g2
583 lda [%g0] ASI_M_MMUREGS, %g3 ! peek in the control reg
584 and %g2, %g3, %g3
585 subcc %g3, 0x0, %g0
586 bnz srmmu_nviking ! is in mbus mode
587 nop
588
589 rd %psr, %g3 ! DO NOT TOUCH %g3
590 andn %g3, PSR_ET, %g2
591 wr %g2, 0x0, %psr
592 WRITE_PAUSE
593
594 /* Get context table pointer, then convert to
595 * a physical address, which is 36 bits.
596 */
597 set AC_M_CTPR, %g4
598 lda [%g4] ASI_M_MMUREGS, %g4
599 sll %g4, 0x4, %g4 ! We use this below
600 ! DO NOT TOUCH %g4
601
602 /* Set the AC bit in the Viking's MMU control reg. */
603 lda [%g0] ASI_M_MMUREGS, %g5 ! DO NOT TOUCH %g5
604 set 0x8000, %g6 ! AC bit mask
605 or %g5, %g6, %g6 ! Or it in...
606 sta %g6, [%g0] ASI_M_MMUREGS ! Close your eyes...
607
608 /* Grrr, why does it seem like every other load/store
609 * on the sun4m is in some ASI space...
610 * Fine with me, let's get the pointer to the level 1
611 * page table directory and fetch its entry.
612 */
613 lda [%g4] ASI_M_BYPASS, %o1 ! This is a level 1 ptr
614 srl %o1, 0x4, %o1 ! Clear low 4 bits
615 sll %o1, 0x8, %o1 ! Make physical
616
617 /* Ok, pull in the PTD. */
618 lda [%o1] ASI_M_BYPASS, %o2 ! This is the 0x0 16MB pgd
619
620 /* Calculate to KERNBASE entry. */
621 add %o1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %o3
622
623 /* Poke the entry into the calculated address. */
624 sta %o2, [%o3] ASI_M_BYPASS
625
626 /* I don't get it Sun, if you engineered all these
627 * boot loaders and the PROM (thank you for the debugging
628 * features btw) why did you not have them load kernel
629 * images up in high address space, since this is necessary
630 * for ABI compliance anyways? Does this low-mapping provide
631 * enhanced interoperability?
632 *
633 * "The PROM is the computer."
634 */
635
636 /* Ok, restore the MMU control register we saved in %g5 */
637 sta %g5, [%g0] ASI_M_MMUREGS ! POW... ouch
638
639 /* Turn traps back on. We saved it in %g3 earlier. */
640 wr %g3, 0x0, %psr ! tick tock, tick tock
641
642 /* Now we burn precious CPU cycles due to bad engineering. */
643 WRITE_PAUSE
644
645 /* Wow, all that just to move a 32-bit value from one
646 * place to another... Jump to high memory.
647 */
648 b go_to_highmem
649 nop
650
651 /* This works on viking's in Mbus mode and all
652 * other MBUS modules. It is virtually the same as
653 * the above madness sans turning traps off and flipping
654 * the AC bit.
655 */
656srmmu_nviking:
657 set AC_M_CTPR, %g1
658 lda [%g1] ASI_M_MMUREGS, %g1 ! get ctx table ptr
659 sll %g1, 0x4, %g1 ! make physical addr
660 lda [%g1] ASI_M_BYPASS, %g1 ! ptr to level 1 pg_table
661 srl %g1, 0x4, %g1
662 sll %g1, 0x8, %g1 ! make phys addr for l1 tbl
663
664 lda [%g1] ASI_M_BYPASS, %g2 ! get level1 entry for 0x0
665 add %g1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %g3
666 sta %g2, [%g3] ASI_M_BYPASS ! place at KERNBASE entry
667 b go_to_highmem
668 nop ! wheee....
669
670 /* This remaps the kernel on Sun4/4xx machines
671 * that have the Sun Mutant Three Level MMU.
672 * It's like a platypus, Sun didn't have the
673 * SRMMU in conception so they kludged the three
674 * level logic in the regular Sun4 MMU probably.
675 *
676 * Basically, you take each entry in the top level
677 * directory that maps the low 3MB starting at
678 * address zero and put the mapping in the KERNBASE
679 * slots. These top level pgd's are called regmaps.
680 */
681sun4_mutant_remap:
682 or %g0, %g0, %g3 ! source base
683 sethi %hi(KERNBASE), %g4 ! destination base
684 or %g4, %lo(KERNBASE), %g4
685 sethi %hi(0x300000), %g5
686 or %g5, %lo(0x300000), %g5 ! upper bound 3MB
687 or %g0, 0x1, %l6
688 sll %l6, 24, %l6 ! Regmap mapping size
689 add %g3, 0x2, %g3 ! Base magic
690 add %g4, 0x2, %g4 ! Base magic
691
692 /* Main remapping loop on Sun4-Mutant-MMU.
693 * "I am not an animal..." -Famous Mutant Person
694 */
695sun4_mutant_loop:
696 lduha [%g3] ASI_REGMAP, %g2 ! Get lower entry
697 stha %g2, [%g4] ASI_REGMAP ! Store in high entry
698 add %g4, %l6, %g4 ! Move up high memory ptr
699 subcc %g3, %g5, %g0 ! Reached our limit?
700 blu sun4_mutant_loop ! Nope, loop again
701 add %g3, %l6, %g3 ! delay, Move up low ptr
702 b go_to_highmem ! Jump to high memory.
703 nop
704
705 /* The following is for non-4/4xx sun4 MMU's. */
706sun4_normal_remap:
707 mov 0, %g3 ! source base
708 set KERNBASE, %g4 ! destination base
709 set 0x300000, %g5 ! upper bound 3MB
710 mov 1, %l6
711 sll %l6, 18, %l6 ! sun4 mmu segmap size
712sun4_normal_loop:
713 lduha [%g3] ASI_SEGMAP, %g6 ! load phys_seg
714 stha %g6, [%g4] ASI_SEGMAP ! stort new virt mapping
715 add %g3, %l6, %g3 ! increment source pointer
716 subcc %g3, %g5, %g0 ! reached limit?
717 blu sun4_normal_loop ! nope, loop again
718 add %g4, %l6, %g4 ! delay, increment dest ptr
719 b go_to_highmem
720 nop
721
722 /* The following works for Sun4c MMU's */
723sun4c_remap:
724 mov 0, %g3 ! source base
725 set KERNBASE, %g4 ! destination base
726 set 0x300000, %g5 ! upper bound 3MB
727 mov 1, %l6
728 sll %l6, 18, %l6 ! sun4c mmu segmap size
729sun4c_remap_loop:
730 lda [%g3] ASI_SEGMAP, %g6 ! load phys_seg
731 sta %g6, [%g4] ASI_SEGMAP ! store new virt mapping
732 add %g3, %l6, %g3 ! Increment source ptr
733 subcc %g3, %g5, %g0 ! Reached limit?
734 bl sun4c_remap_loop ! Nope, loop again
735 add %g4, %l6, %g4 ! delay, Increment dest ptr
736
737/* Now do a non-relative jump so that PC is in high-memory */
738go_to_highmem:
739 set execute_in_high_mem, %g1
740 jmpl %g1, %g0
741 nop
742
743/* The code above should be at beginning and we have to take care about
744 * short jumps, as branching to .text.init section from .text is usually
745 * impossible */
746 __INIT
747/* Acquire boot time privileged register values, this will help debugging.
748 * I figure out and store nwindows and nwindowsm1 later on.
749 */
750execute_in_high_mem:
751 mov %l0, %o0 ! put back romvec
752 mov %l1, %o1 ! and debug_vec
753
754 sethi %hi(prom_vector_p), %g1
755 st %o0, [%g1 + %lo(prom_vector_p)]
756
757 sethi %hi(linux_dbvec), %g1
758 st %o1, [%g1 + %lo(linux_dbvec)]
759
760 ld [%o0 + 0x4], %o3
761 and %o3, 0x3, %o5 ! get the version
762
763 cmp %o3, 0x2 ! a v2 prom?
764 be found_version
765 nop
766
767 /* paul@sfe.com.au */
768 cmp %o3, 0x3 ! a v3 prom?
769 be found_version
770 nop
771
772/* Old sun4's pass our load address into %o0 instead of the prom
773 * pointer. On sun4's you have to hard code the romvec pointer into
774 * your code. Sun probably still does that because they don't even
775 * trust their own "OpenBoot" specifications.
776 */
777 set LOAD_ADDR, %g6
778 cmp %o0, %g6 ! an old sun4?
779 be sun4_init
780 nop
781
782found_version:
783#ifdef CONFIG_SUN4
784/* For people who try sun4 kernels, even if Configure.help advises them. */
785 ld [%g7 + 0x68], %o1
786 set sun4cdm_notsup, %o0
787 call %o1
788 nop
789 b halt_me
790 nop
791#endif
792/* Get the machine type via the mysterious romvec node operations. */
793
794 add %g7, 0x1c, %l1
795 ld [%l1], %l0
796 ld [%l0], %l0
797 call %l0
798 or %g0, %g0, %o0 ! next_node(0) = first_node
799 or %o0, %g0, %g6
800
801 sethi %hi(cputypvar), %o1 ! First node has cpu-arch
802 or %o1, %lo(cputypvar), %o1
803 sethi %hi(cputypval), %o2 ! information, the string
804 or %o2, %lo(cputypval), %o2
805 ld [%l1], %l0 ! 'compatibility' tells
806 ld [%l0 + 0xc], %l0 ! that we want 'sun4x' where
807 call %l0 ! x is one of '', 'c', 'm',
808 nop ! 'd' or 'e'. %o2 holds pointer
809 ! to a buf where above string
810 ! will get stored by the prom.
811
812 subcc %o0, %g0, %g0
813 bpos got_prop ! Got the property
814 nop
815
816 or %g6, %g0, %o0
817 sethi %hi(cputypvar_sun4m), %o1
818 or %o1, %lo(cputypvar_sun4m), %o1
819 sethi %hi(cputypval), %o2
820 or %o2, %lo(cputypval), %o2
821 ld [%l1], %l0
822 ld [%l0 + 0xc], %l0
823 call %l0
824 nop
825
826got_prop:
827 set cputypval, %o2
828 ldub [%o2 + 0x4], %l1
829
830 cmp %l1, ' '
831 be 1f
832 cmp %l1, 'c'
833 be 1f
834 cmp %l1, 'm'
835 be 1f
836 cmp %l1, 's'
837 be 1f
838 cmp %l1, 'd'
839 be 1f
840 cmp %l1, 'e'
841 be no_sun4e_here ! Could be a sun4e.
842 nop
843 b no_sun4u_here ! AIEEE, a V9 sun4u... Get our BIG BROTHER kernel :))
844 nop
845
8461: set cputypval, %l1
847 ldub [%l1 + 0x4], %l1
848 cmp %l1, 'm' ! Test for sun4d, sun4e ?
849 be sun4m_init
850 cmp %l1, 's' ! Treat sun4s as sun4m
851 be sun4m_init
852 cmp %l1, 'd' ! Let us see how the beast will die
853 be sun4d_init
854 nop
855
856 /* Jump into mmu context zero. */
857 set AC_CONTEXT, %g1
858 stba %g0, [%g1] ASI_CONTROL
859
860 b sun4c_continue_boot
861 nop
862
863/* CPUID in bootbus can be found at PA 0xff0140000 */
864#define SUN4D_BOOTBUS_CPUID 0xf0140000
865
866sun4d_init:
867 /* Need to patch call to handler_irq */
868 set patch_handler_irq, %g4
869 set sun4d_handler_irq, %g5
870 sethi %hi(0x40000000), %g3 ! call
871 sub %g5, %g4, %g5
872 srl %g5, 2, %g5
873 or %g5, %g3, %g5
874 st %g5, [%g4]
875
876#ifdef CONFIG_SMP
877 /* Get our CPU id out of bootbus */
878 set SUN4D_BOOTBUS_CPUID, %g3
879 lduba [%g3] ASI_M_CTL, %g3
880 and %g3, 0xf8, %g3
881 srl %g3, 3, %g4
882 sta %g4, [%g0] ASI_M_VIKING_TMP1
883 sethi %hi(boot_cpu_id), %g5
884 stb %g4, [%g5 + %lo(boot_cpu_id)]
885 sll %g4, 2, %g4
886 sethi %hi(boot_cpu_id4), %g5
887 stb %g4, [%g5 + %lo(boot_cpu_id4)]
888#endif
889
890 /* Fall through to sun4m_init */
891
892sun4m_init:
893 /* XXX Fucking Cypress... */
894 lda [%g0] ASI_M_MMUREGS, %g5
895 srl %g5, 28, %g4
896
897 cmp %g4, 1
898 bne 1f
899 srl %g5, 24, %g4
900
901 and %g4, 0xf, %g4
902 cmp %g4, 7 /* This would be a HyperSparc. */
903
904 bne 2f
905 nop
906
9071:
908
909#define PATCH_IT(dst, src) \
910 set (dst), %g5; \
911 set (src), %g4; \
912 ld [%g4], %g3; \
913 st %g3, [%g5]; \
914 ld [%g4+0x4], %g3; \
915 st %g3, [%g5+0x4];
916
917 /* Signed multiply. */
918 PATCH_IT(.mul, .mul_patch)
919 PATCH_IT(.mul+0x08, .mul_patch+0x08)
920
921 /* Signed remainder. */
922 PATCH_IT(.rem, .rem_patch)
923 PATCH_IT(.rem+0x08, .rem_patch+0x08)
924 PATCH_IT(.rem+0x10, .rem_patch+0x10)
925 PATCH_IT(.rem+0x18, .rem_patch+0x18)
926 PATCH_IT(.rem+0x20, .rem_patch+0x20)
927 PATCH_IT(.rem+0x28, .rem_patch+0x28)
928
929 /* Signed division. */
930 PATCH_IT(.div, .div_patch)
931 PATCH_IT(.div+0x08, .div_patch+0x08)
932 PATCH_IT(.div+0x10, .div_patch+0x10)
933 PATCH_IT(.div+0x18, .div_patch+0x18)
934 PATCH_IT(.div+0x20, .div_patch+0x20)
935
936 /* Unsigned multiply. */
937 PATCH_IT(.umul, .umul_patch)
938 PATCH_IT(.umul+0x08, .umul_patch+0x08)
939
940 /* Unsigned remainder. */
941 PATCH_IT(.urem, .urem_patch)
942 PATCH_IT(.urem+0x08, .urem_patch+0x08)
943 PATCH_IT(.urem+0x10, .urem_patch+0x10)
944 PATCH_IT(.urem+0x18, .urem_patch+0x18)
945
946 /* Unsigned division. */
947 PATCH_IT(.udiv, .udiv_patch)
948 PATCH_IT(.udiv+0x08, .udiv_patch+0x08)
949 PATCH_IT(.udiv+0x10, .udiv_patch+0x10)
950
951#undef PATCH_IT
952
953/* Ok, the PROM could have done funny things and apple cider could still
954 * be sitting in the fault status/address registers. Read them all to
955 * clear them so we don't get magic faults later on.
956 */
957/* This sucks, apparently this makes Vikings call prom panic, will fix later */
9582:
959 rd %psr, %o1
960 srl %o1, 28, %o1 ! Get a type of the CPU
961
962 subcc %o1, 4, %g0 ! TI: Viking or MicroSPARC
963 be sun4c_continue_boot
964 nop
965
966 set AC_M_SFSR, %o0
967 lda [%o0] ASI_M_MMUREGS, %g0
968 set AC_M_SFAR, %o0
969 lda [%o0] ASI_M_MMUREGS, %g0
970
971 /* Fujitsu MicroSPARC-II has no asynchronous flavors of FARs */
972 subcc %o1, 0, %g0
973 be sun4c_continue_boot
974 nop
975
976 set AC_M_AFSR, %o0
977 lda [%o0] ASI_M_MMUREGS, %g0
978 set AC_M_AFAR, %o0
979 lda [%o0] ASI_M_MMUREGS, %g0
980 nop
981
982
983sun4c_continue_boot:
984
985
986/* Aieee, now set PC and nPC, enable traps, give ourselves a stack and it's
987 * show-time!
988 */
989
990 sethi %hi(cputyp), %o0
991 st %g4, [%o0 + %lo(cputyp)]
992
993 /* Turn on Supervisor, EnableFloating, and all the PIL bits.
994 * Also puts us in register window zero with traps off.
995 */
996 set (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
997 wr %g2, 0x0, %psr
998 WRITE_PAUSE
999
1000 /* I want a kernel stack NOW! */
1001 set init_thread_union, %g1
1002 set (THREAD_SIZE - STACKFRAME_SZ), %g2
1003 add %g1, %g2, %sp
1004 mov 0, %fp /* And for good luck */
1005
1006 /* Zero out our BSS section. */
1007 set __bss_start , %o0 ! First address of BSS
1008 set end , %o1 ! Last address of BSS
1009 add %o0, 0x1, %o0
10101:
1011 stb %g0, [%o0]
1012 subcc %o0, %o1, %g0
1013 bl 1b
1014 add %o0, 0x1, %o0
1015
1016 /* Initialize the uwinmask value for init task just in case.
1017 * But first make current_set[boot_cpu_id] point to something useful.
1018 */
1019 set init_thread_union, %g6
1020 set current_set, %g2
1021#ifdef CONFIG_SMP
1022 sethi %hi(boot_cpu_id4), %g3
1023 ldub [%g3 + %lo(boot_cpu_id4)], %g3
1024 st %g6, [%g2]
1025 add %g2, %g3, %g2
1026#endif
1027 st %g6, [%g2]
1028
1029 st %g0, [%g6 + TI_UWINMASK]
1030
1031/* Compute NWINDOWS and stash it away. Now uses %wim trick explained
1032 * in the V8 manual. Ok, this method seems to work, Sparc is cool...
1033 * No, it doesn't work, have to play the save/readCWP/restore trick.
1034 */
1035
1036 wr %g0, 0x0, %wim ! so we do not get a trap
1037 WRITE_PAUSE
1038
1039 save
1040
1041 rd %psr, %g3
1042
1043 restore
1044
1045 and %g3, 0x1f, %g3
1046 add %g3, 0x1, %g3
1047
1048 mov 2, %g1
1049 wr %g1, 0x0, %wim ! make window 1 invalid
1050 WRITE_PAUSE
1051
1052 cmp %g3, 0x7
1053 bne 2f
1054 nop
1055
1056 /* Adjust our window handling routines to
1057 * do things correctly on 7 window Sparcs.
1058 */
1059
1060#define PATCH_INSN(src, dest) \
1061 set src, %g5; \
1062 set dest, %g2; \
1063 ld [%g5], %g4; \
1064 st %g4, [%g2];
1065
1066 /* Patch for window spills... */
1067 PATCH_INSN(spnwin_patch1_7win, spnwin_patch1)
1068 PATCH_INSN(spnwin_patch2_7win, spnwin_patch2)
1069 PATCH_INSN(spnwin_patch3_7win, spnwin_patch3)
1070
1071 /* Patch for window fills... */
1072 PATCH_INSN(fnwin_patch1_7win, fnwin_patch1)
1073 PATCH_INSN(fnwin_patch2_7win, fnwin_patch2)
1074
1075 /* Patch for trap entry setup... */
1076 PATCH_INSN(tsetup_7win_patch1, tsetup_patch1)
1077 PATCH_INSN(tsetup_7win_patch2, tsetup_patch2)
1078 PATCH_INSN(tsetup_7win_patch3, tsetup_patch3)
1079 PATCH_INSN(tsetup_7win_patch4, tsetup_patch4)
1080 PATCH_INSN(tsetup_7win_patch5, tsetup_patch5)
1081 PATCH_INSN(tsetup_7win_patch6, tsetup_patch6)
1082
1083 /* Patch for returning from traps... */
1084 PATCH_INSN(rtrap_7win_patch1, rtrap_patch1)
1085 PATCH_INSN(rtrap_7win_patch2, rtrap_patch2)
1086 PATCH_INSN(rtrap_7win_patch3, rtrap_patch3)
1087 PATCH_INSN(rtrap_7win_patch4, rtrap_patch4)
1088 PATCH_INSN(rtrap_7win_patch5, rtrap_patch5)
1089
1090 /* Patch for killing user windows from the register file. */
1091 PATCH_INSN(kuw_patch1_7win, kuw_patch1)
1092
1093 /* Now patch the kernel window flush sequences.
1094 * This saves 2 traps on every switch and fork.
1095 */
1096 set 0x01000000, %g4
1097 set flush_patch_one, %g5
1098 st %g4, [%g5 + 0x18]
1099 st %g4, [%g5 + 0x1c]
1100 set flush_patch_two, %g5
1101 st %g4, [%g5 + 0x18]
1102 st %g4, [%g5 + 0x1c]
1103 set flush_patch_three, %g5
1104 st %g4, [%g5 + 0x18]
1105 st %g4, [%g5 + 0x1c]
1106 set flush_patch_four, %g5
1107 st %g4, [%g5 + 0x18]
1108 st %g4, [%g5 + 0x1c]
1109 set flush_patch_exception, %g5
1110 st %g4, [%g5 + 0x18]
1111 st %g4, [%g5 + 0x1c]
1112 set flush_patch_switch, %g5
1113 st %g4, [%g5 + 0x18]
1114 st %g4, [%g5 + 0x1c]
1115
11162:
1117 sethi %hi(nwindows), %g4
1118 st %g3, [%g4 + %lo(nwindows)] ! store final value
1119 sub %g3, 0x1, %g3
1120 sethi %hi(nwindowsm1), %g4
1121 st %g3, [%g4 + %lo(nwindowsm1)]
1122
1123 /* Here we go, start using Linux's trap table... */
1124 set trapbase, %g3
1125 wr %g3, 0x0, %tbr
1126 WRITE_PAUSE
1127
1128 /* Finally, turn on traps so that we can call c-code. */
1129 rd %psr, %g3
1130 wr %g3, 0x0, %psr
1131 WRITE_PAUSE
1132
1133 wr %g3, PSR_ET, %psr
1134 WRITE_PAUSE
1135
1136 /* First we call prom_init() to set up PROMLIB, then
1137 * off to start_kernel().
1138 */
1139
1140 sethi %hi(prom_vector_p), %g5
1141 ld [%g5 + %lo(prom_vector_p)], %o0
1142 call prom_init
1143 nop
1144
1145 call start_kernel
1146 nop
1147
1148 /* We should not get here. */
1149 call halt_me
1150 nop
1151
1152sun4_init:
1153#ifdef CONFIG_SUN4
1154/* There, happy now Adrian? */
1155 set cputypval, %o2 ! Let everyone know we
1156 set ' ', %o0 ! are a "sun4 " architecture
1157 stb %o0, [%o2 + 0x4]
1158
1159 b got_prop
1160 nop
1161#else
1162 sethi %hi(SUN4_PROM_VECTOR+0x84), %o1
1163 ld [%o1 + %lo(SUN4_PROM_VECTOR+0x84)], %o1
1164 set sun4_notsup, %o0
1165 call %o1 /* printf */
1166 nop
1167 sethi %hi(SUN4_PROM_VECTOR+0xc4), %o1
1168 ld [%o1 + %lo(SUN4_PROM_VECTOR+0xc4)], %o1
1169 call %o1 /* exittomon */
1170 nop
11711: ba 1b ! Cannot exit into KMON
1172 nop
1173#endif
1174no_sun4e_here:
1175 ld [%g7 + 0x68], %o1
1176 set sun4e_notsup, %o0
1177 call %o1
1178 nop
1179 b halt_me
1180 nop
1181
1182 __INITDATA
1183
1184sun4u_1:
1185 .asciz "finddevice"
1186 .align 4
1187sun4u_2:
1188 .asciz "/chosen"
1189 .align 4
1190sun4u_3:
1191 .asciz "getprop"
1192 .align 4
1193sun4u_4:
1194 .asciz "stdout"
1195 .align 4
1196sun4u_5:
1197 .asciz "write"
1198 .align 4
1199sun4u_6:
1200 .asciz "\n\rOn sun4u you have to use UltraLinux (64bit) kernel\n\rand not a 32bit sun4[cdem] version\n\r\n\r"
1201sun4u_6e:
1202 .align 4
1203sun4u_7:
1204 .asciz "exit"
1205 .align 8
1206sun4u_a1:
1207 .word 0, sun4u_1, 0, 1, 0, 1, 0, sun4u_2, 0
1208sun4u_r1:
1209 .word 0
1210sun4u_a2:
1211 .word 0, sun4u_3, 0, 4, 0, 1, 0
1212sun4u_i2:
1213 .word 0, 0, sun4u_4, 0, sun4u_1, 0, 8, 0
1214sun4u_r2:
1215 .word 0
1216sun4u_a3:
1217 .word 0, sun4u_5, 0, 3, 0, 1, 0
1218sun4u_i3:
1219 .word 0, 0, sun4u_6, 0, sun4u_6e - sun4u_6 - 1, 0
1220sun4u_r3:
1221 .word 0
1222sun4u_a4:
1223 .word 0, sun4u_7, 0, 0, 0, 0
1224sun4u_r4:
1225
1226 __INIT
1227no_sun4u_here:
1228 set sun4u_a1, %o0
1229 set current_pc, %l2
1230 cmp %l2, %g3
1231 be 1f
1232 mov %o4, %l0
1233 sub %g3, %l2, %l6
1234 add %o0, %l6, %o0
1235 mov %o0, %l4
1236 mov sun4u_r4 - sun4u_a1, %l3
1237 ld [%l4], %l5
12382:
1239 add %l4, 4, %l4
1240 cmp %l5, %l2
1241 add %l5, %l6, %l5
1242 bgeu,a 3f
1243 st %l5, [%l4 - 4]
12443:
1245 subcc %l3, 4, %l3
1246 bne 2b
1247 ld [%l4], %l5
12481:
1249 call %l0
1250 mov %o0, %l1
1251
1252 ld [%l1 + (sun4u_r1 - sun4u_a1)], %o1
1253 add %l1, (sun4u_a2 - sun4u_a1), %o0
1254 call %l0
1255 st %o1, [%o0 + (sun4u_i2 - sun4u_a2)]
1256
1257 ld [%l1 + (sun4u_1 - sun4u_a1)], %o1
1258 add %l1, (sun4u_a3 - sun4u_a1), %o0
1259 call %l0
1260 st %o1, [%o0 + (sun4u_i3 - sun4u_a3)]
1261
1262 call %l0
1263 add %l1, (sun4u_a4 - sun4u_a1), %o0
1264
1265 /* Not reached */
1266halt_me:
1267 ld [%g7 + 0x74], %o0
1268 call %o0 ! Get us out of here...
1269 nop ! Apparently Solaris is better.
1270
1271/* Ok, now we continue in the .data/.text sections */
1272
1273 .data
1274 .align 4
1275
1276/*
1277 * Fill up the prom vector, note in particular the kind first element,
1278 * no joke. I don't need all of them in here as the entire prom vector
1279 * gets initialized in c-code so all routines can use it.
1280 */
1281
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282prom_vector_p:
1283 .word 0
1284
1285/* We calculate the following at boot time, window fills/spills and trap entry
1286 * code uses these to keep track of the register windows.
1287 */
1288
1289 .align 4
1290 .globl nwindows
1291 .globl nwindowsm1
1292nwindows:
1293 .word 8
1294nwindowsm1:
1295 .word 7
1296
1297/* Boot time debugger vector value. We need this later on. */
1298
1299 .align 4
1300 .globl linux_dbvec
1301linux_dbvec:
1302 .word 0
1303 .word 0
1304
1305 .align 8
1306
1307 .globl lvl14_save
1308lvl14_save:
1309 .word 0
1310 .word 0
1311 .word 0
1312 .word 0
1313 .word t_irq14
1314
1315 .section ".fixup",#alloc,#execinstr
1316 .globl __ret_efault
1317__ret_efault:
1318 ret
1319 restore %g0, -EFAULT, %o0