1 /* $Id: head.S,v 1.97 1999/08/14 03:51:10 anton Exp $
2 * head.S: The initial boot code for the Sparc port of Linux.
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1995,1999 Pete Zaitcev (zaitcev@metabyte.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)
10 * CompactPCI platform by Eric Brower, 1999.
13 #include <linux/version.h>
14 #include <linux/config.h>
15 #include <linux/init.h>
17 #include <asm/cprefix.h>
20 #include <asm/contregs.h>
21 #include <asm/ptrace.h>
24 #include <asm/kdebug.h>
25 #include <asm/winmacro.h>
26 #include <asm/errno.h>
30 * The following are used with the prom_vector node-ops to figure out
35 .globl C_LABEL(cputyp)
40 .globl C_LABEL(cputypval)
45 C_LABEL(cputypvalend):
46 C_LABEL(cputypvallen) = C_LABEL(cputypvar) - C_LABEL(cputypval)
50 * Sun people can't spell worth damn. "compatability" indeed.
51 * At least we *know* we can't spell, and use a spell-checker.
54 /* Uh, actually Linus it is I who cannot spell. Too much murky
55 * Sparc assembly will do this to ya.
58 .asciz "compatability"
60 /* Tested on SS-5, SS-10. Probably someone at Sun applied a spell-checker. */
62 C_LABEL(cputypvar_sun4m):
69 .asciz "Sparc-Linux sun4 needs a specially compiled kernel, turn CONFIG_SUN4 on.\n\n"
73 .asciz "Kernel compiled with CONFIG_SUN4 cannot run on SUN4C/SUN4M/SUN4D\nTurn CONFIG_SUN4 off.\n\n"
78 .asciz "Sparc-Linux sun4e support does not exist\n\n"
81 /* The Sparc trap table, bootloader gives us control at _start. */
83 .globl start, _stext, _start, __stext
84 .globl C_LABEL(trapbase)
85 _start: /* danger danger */
91 C_LABEL(trapbase_cpu0):
93 /* We get control passed to us here at t_zero. */
94 t_zero: b gokernel; nop; nop; nop;
95 t_tflt: SPARC_TFAULT /* Inst. Access Exception */
96 t_bins: TRAP_ENTRY(0x2, bad_instruction) /* Illegal Instruction */
97 t_pins: TRAP_ENTRY(0x3, priv_instruction) /* Privileged Instruction */
98 t_fpd: TRAP_ENTRY(0x4, fpd_trap_handler) /* Floating Point Disabled */
99 t_wovf: WINDOW_SPILL /* Window Overflow */
100 t_wunf: WINDOW_FILL /* Window Underflow */
101 t_mna: TRAP_ENTRY(0x7, mna_handler) /* Memory Address Not Aligned */
102 t_fpe: TRAP_ENTRY(0x8, fpe_trap_handler) /* Floating Point Exception */
103 t_dflt: SPARC_DFAULT /* Data Miss Exception */
104 t_tio: TRAP_ENTRY(0xa, do_tag_overflow) /* Tagged Instruction Ovrflw */
105 t_wpt: TRAP_ENTRY(0xb, do_watchpoint) /* Watchpoint Detected */
106 t_badc: BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
107 t_irq1: TRAP_ENTRY_INTERRUPT(1) /* IRQ Software/SBUS Level 1 */
108 t_irq2: TRAP_ENTRY_INTERRUPT(2) /* IRQ SBUS Level 2 */
109 t_irq3: TRAP_ENTRY_INTERRUPT(3) /* IRQ SCSI/DMA/SBUS Level 3 */
110 t_irq4: TRAP_ENTRY_INTERRUPT(4) /* IRQ Software Level 4 */
111 t_irq5: TRAP_ENTRY_INTERRUPT(5) /* IRQ SBUS/Ethernet Level 5 */
112 t_irq6: TRAP_ENTRY_INTERRUPT(6) /* IRQ Software Level 6 */
113 t_irq7: TRAP_ENTRY_INTERRUPT(7) /* IRQ Video/SBUS Level 5 */
114 t_irq8: TRAP_ENTRY_INTERRUPT(8) /* IRQ SBUS Level 6 */
115 t_irq9: TRAP_ENTRY_INTERRUPT(9) /* IRQ SBUS Level 7 */
116 t_irq10:TRAP_ENTRY_INTERRUPT(10) /* IRQ Timer #1 (one we use) */
117 t_irq11:TRAP_ENTRY_INTERRUPT(11) /* IRQ Floppy Intr. */
118 t_irq12:TRAP_ENTRY_INTERRUPT(12) /* IRQ Zilog serial chip */
119 t_irq13:TRAP_ENTRY_INTERRUPT(13) /* IRQ Audio Intr. */
120 t_irq14:TRAP_ENTRY_INTERRUPT(14) /* IRQ Timer #2 */
123 t_nmi: NMI_TRAP /* Level 15 (NMI) */
125 t_nmi: TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
127 t_racc: TRAP_ENTRY(0x20, do_reg_access) /* General Register Access Error */
128 t_iacce:BAD_TRAP(0x21) /* Instr Access Error */
129 t_bad22:BAD_TRAP(0x22) BAD_TRAP(0x23)
130 t_cpdis:TRAP_ENTRY(0x24, do_cp_disabled) /* Co-Processor Disabled */
131 t_uflsh:SKIP_TRAP(0x25, unimp_flush) /* Unimplemented FLUSH inst. */
132 t_bad26:BAD_TRAP(0x26) BAD_TRAP(0x27)
133 t_cpexc:TRAP_ENTRY(0x28, do_cp_exception) /* Co-Processor Exception */
134 t_dacce:SPARC_DFAULT /* Data Access Error */
135 t_hwdz: TRAP_ENTRY(0x2a, do_hw_divzero) /* Division by zero, you lose... */
136 t_dserr:BAD_TRAP(0x2b) /* Data Store Error */
137 t_daccm:BAD_TRAP(0x2c) /* Data Access MMU-Miss */
138 t_bad2d:BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
139 t_bad32:BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
140 t_bad37:BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
141 t_iaccm:BAD_TRAP(0x3c) /* Instr Access MMU-Miss */
142 t_bad3d:BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40) BAD_TRAP(0x41)
143 t_bad42:BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45) BAD_TRAP(0x46)
144 t_bad47:BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a) BAD_TRAP(0x4b)
145 t_bad4c:BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f) BAD_TRAP(0x50)
146 t_bad51:BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
147 t_bad56:BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
148 t_bad5b:BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
149 t_bad60:BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
150 t_bad65:BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
151 t_bad6a:BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
152 t_bad6f:BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
153 t_bad74:BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
154 t_bad79:BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
155 t_bad7e:BAD_TRAP(0x7e) BAD_TRAP(0x7f)
156 t_sunos:SUNOS_SYSCALL_TRAP /* SunOS System Call */
157 t_sbkpt:BREAKPOINT_TRAP /* Software Breakpoint/KGDB */
158 t_divz: BAD_TRAP(0x82) /* Divide by zero trap */
159 t_flwin:TRAP_ENTRY(0x83, do_flush_windows) /* Flush Windows Trap */
160 t_clwin:BAD_TRAP(0x84) /* Clean Windows Trap */
161 t_rchk: BAD_TRAP(0x85) /* Range Check */
162 t_funal:BAD_TRAP(0x86) /* Fix Unaligned Access Trap */
163 t_iovf: BAD_TRAP(0x87) /* Integer Overflow Trap */
164 t_slowl:SOLARIS_SYSCALL_TRAP /* Slowaris System Call */
165 t_netbs:NETBSD_SYSCALL_TRAP /* Net-B.S. System Call */
166 t_bad8a:BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) BAD_TRAP(0x8d) BAD_TRAP(0x8e)
167 t_bad8f:BAD_TRAP(0x8f)
168 t_linux:LINUX_SYSCALL_TRAP /* Linux System Call */
169 t_bad91:BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94) BAD_TRAP(0x95)
170 t_bad96:BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99) BAD_TRAP(0x9a)
171 t_bad9b:BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e) BAD_TRAP(0x9f)
172 t_getcc:GETCC_TRAP /* Get Condition Codes */
173 t_setcc:SETCC_TRAP /* Set Condition Codes */
174 t_bada2:BAD_TRAP(0xa2) BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
175 t_slowi:INDIRECT_SOLARIS_SYSCALL(156)
176 t_bada8:BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
177 t_badac:BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
178 t_badb1:BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
179 t_badb6:BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
180 t_badbb:BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
181 t_badc0:BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
182 t_badc5:BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
183 t_badca:BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
184 t_badcf:BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
185 t_badd4:BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
186 t_badd9:BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
187 t_badde:BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
188 t_bade3:BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
189 t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
190 t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
191 t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
192 t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
193 t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd)
194 dbtrap: BAD_TRAP(0xfe) /* Debugger/PROM breakpoint #1 */
195 dbtrap2:BAD_TRAP(0xff) /* Debugger/PROM breakpoint #2 */
197 .globl C_LABEL(end_traptable)
198 C_LABEL(end_traptable):
201 /* Trap tables for the other cpus. */
202 .globl C_LABEL(trapbase_cpu1), C_LABEL(trapbase_cpu2), C_LABEL(trapbase_cpu3)
203 C_LABEL(trapbase_cpu1):
204 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
205 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
206 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
207 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
208 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
209 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
210 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
211 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
212 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
213 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
214 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
215 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
216 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
217 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
218 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
219 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
220 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
221 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
222 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
223 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
224 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
225 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
226 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
227 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
228 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
230 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
231 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
232 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
233 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
234 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
235 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
236 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
237 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
238 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
239 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
243 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
244 BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
245 NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
246 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
247 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
248 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
249 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
250 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP
251 BAD_TRAP(0xa2) BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
252 INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
253 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
254 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
255 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
256 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
257 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
258 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
259 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
260 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
261 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
262 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
263 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
264 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
265 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
266 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
267 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
268 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
269 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
271 C_LABEL(trapbase_cpu2):
272 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
273 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
274 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
275 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
276 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
277 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
278 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
279 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
280 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
281 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
282 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
283 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
284 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
285 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
286 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
287 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
288 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
289 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
290 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
291 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
292 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
293 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
294 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
295 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
296 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
298 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
299 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
300 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
301 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
302 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
303 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
304 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
305 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
306 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
307 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
311 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
312 BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
313 NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
314 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
315 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
316 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
317 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
318 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP
319 BAD_TRAP(0xa2) BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
320 INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
321 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
322 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
323 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
324 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
325 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
326 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
327 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
328 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
329 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
330 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
331 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
332 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
333 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
334 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
335 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
336 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
337 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
339 C_LABEL(trapbase_cpu3):
340 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
341 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
342 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
343 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
344 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
345 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
346 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
347 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
348 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
349 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
350 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
351 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
352 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
353 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
354 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
355 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
356 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
357 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
358 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
359 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
360 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
361 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
362 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
363 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
364 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
366 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
367 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
368 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
369 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
370 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
371 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
372 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
373 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
374 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
375 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
379 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
380 BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
381 NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
382 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
383 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
384 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
385 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
386 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP
387 BAD_TRAP(0xa2) BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
388 INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
389 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
390 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
391 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
392 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
393 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
394 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
395 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
396 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
397 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
398 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
399 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
400 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
401 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
402 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
403 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
404 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
405 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
410 /* This was the only reasonable way I could think of to properly align
411 * these page-table data structures.
413 .globl C_LABEL(pg0), C_LABEL(pg1), C_LABEL(pg2), C_LABEL(pg3)
414 .globl C_LABEL(empty_bad_page)
415 .globl C_LABEL(empty_bad_page_table)
416 .globl C_LABEL(empty_zero_page)
417 .globl C_LABEL(swapper_pg_dir)
418 C_LABEL(swapper_pg_dir): .skip PAGE_SIZE
419 C_LABEL(pg0): .skip PAGE_SIZE
420 C_LABEL(pg1): .skip PAGE_SIZE
421 C_LABEL(pg2): .skip PAGE_SIZE
422 C_LABEL(pg3): .skip PAGE_SIZE
423 C_LABEL(empty_bad_page): .skip PAGE_SIZE
424 C_LABEL(empty_bad_page_table): .skip PAGE_SIZE
425 C_LABEL(empty_zero_page): .skip PAGE_SIZE
427 .global C_LABEL(root_flags)
428 .global C_LABEL(ram_flags)
429 .global C_LABEL(root_dev)
430 .global C_LABEL(sparc_ramdisk_image)
431 .global C_LABEL(sparc_ramdisk_size)
433 /* This stuff has to be in sync with SILO and other potential boot loaders
434 * Fields should be kept upward compatible and whenever any change is made,
435 * HdrS version should be incremented.
438 .word LINUX_VERSION_CODE
439 .half 0x0201 /* HdrS version */
446 C_LABEL(sparc_ramdisk_image):
448 C_LABEL(sparc_ramdisk_size):
450 .word C_LABEL(reboot_command)
452 /* Cool, here we go. Pick up the romvec pointer in %o0 and stash it in
453 * %g7 and at prom_vector_p. And also quickly check whether we are on
454 * a v0, v2, or v3 prom.
457 /* Ok, it's nice to know, as early as possible, if we
458 * are already mapped where we expect to be in virtual
459 * memory. The Solaris /boot elf format bootloader
460 * will peek into our elf header and load us where
461 * we want to be, otherwise we have to re-map.
463 * Some boot loaders don't place the jmp'rs address
464 * in %o7, so we do a pc-relative call to a local
465 * label, then see what %o7 has.
468 mov %o7, %g4 ! Save %o7
470 /* Jump to it, and pray... */
478 #ifndef CONFIG_AP1000
482 mov %g4, %o7 /* Previous %o7. */
484 mov %o0, %l0 ! stash away romvec
485 mov %o0, %g7 ! put it here too
486 mov %o1, %l1 ! stash away debug_vec too
488 /* Ok, let's check out our run time program counter. */
494 /* %l6 will hold the offset we have to subtract
495 * from absolute symbols in order to access areas
496 * in our own image. If already mapped this is
497 * just plain zero, else it is KERNBASE.
506 /* Copy over the Prom's level 14 clock handler. */
510 * preserve our linked/calculated instructions
512 set C_LABEL(lvl14_save), %g1
514 sub %g1, %l6, %g1 ! translate to physical
515 sub %g3, %l6, %g3 ! translate to physical
522 andn %g1, 0xfff, %g1 ! proms trap table base
523 or %g0, (0x1e<<4), %g2 ! offset to lvl14 intr
530 std %g4, [%g3 + 0x8] ! Copy proms handler
532 /* Must determine whether we are on a sun4c MMU, SRMMU, or SUN4/400 MUTANT
533 * MMU so we can remap ourselves properly. DON'T TOUCH %l0 thru %l5 in these
534 * remapping routines, we need their values afterwards!
536 /* Now check whether we are already mapped, if we
537 * are we can skip all this garbage coming up.
541 be go_to_highmem ! this will be a nop then
546 bne remap_not_a_sun4 ! This is not a Sun4
550 lduba [%g1] ASI_CONTROL, %g1 ! Only safe to try on Sun4.
551 subcc %g1, 0x24, %g0 ! Is this a mutant Sun4/400???
552 be sun4_mutant_remap ! Ugh, it is...
555 b sun4_normal_remap ! regular sun4, 2 level mmu
559 lda [%g0] ASI_M_MMUREGS, %g1 ! same as ASI_PTE on sun4c
560 and %g1, 0x1, %g1 ! Test SRMMU Enable bit ;-)
562 be sun4c_remap ! A sun4c MMU or normal Sun4
565 /* First, check for a viking (TI) module. */
573 /* Figure out what kind of viking we are on.
574 * We need to know if we have to play with the
575 * AC bit and disable traps or not.
578 /* I've only seen MicroSparc's on SparcClassics with this
582 lda [%g0] ASI_M_MMUREGS, %g3 ! peek in the control reg
585 bnz srmmu_nviking ! is in mbus mode
588 rd %psr, %g3 ! DO NOT TOUCH %g3
589 andn %g3, PSR_ET, %g2
593 /* Get context table pointer, then convert to
594 * a physical address, which is 36 bits.
597 lda [%g4] ASI_M_MMUREGS, %g4
598 sll %g4, 0x4, %g4 ! We use this below
601 /* Set the AC bit in the Viking's MMU control reg. */
602 lda [%g0] ASI_M_MMUREGS, %g5 ! DO NOT TOUCH %g5
603 set 0x8000, %g6 ! AC bit mask
604 or %g5, %g6, %g6 ! Or it in...
605 sta %g6, [%g0] ASI_M_MMUREGS ! Close your eyes...
607 /* Grrr, why does it seem like every other load/store
608 * on the sun4m is in some ASI space...
609 * Fine with me, let's get the pointer to the level 1
610 * page table directory and fetch its entry.
612 lda [%g4] ASI_M_BYPASS, %o1 ! This is a level 1 ptr
613 srl %o1, 0x4, %o1 ! Clear low 4 bits
614 sll %o1, 0x8, %o1 ! Make physical
616 /* Ok, pull in the PTD. */
617 lda [%o1] ASI_M_BYPASS, %o2 ! This is the 0x0 16MB pgd
619 /* Calculate to KERNBASE entry.
621 * XXX Should not use empirical constant, but Gas gets an XXX
622 * XXX upset stomach with the bitshift I would have to use XXX
626 /* Poke the entry into the calculated address. */
627 sta %o2, [%o3] ASI_M_BYPASS
629 /* I don't get it Sun, if you engineered all these
630 * boot loaders and the PROM (thank you for the debugging
631 * features btw) why did you not have them load kernel
632 * images up in high address space, since this is necessary
633 * for ABI compliance anyways? Does this low-mapping provide
634 * enhanced interoperability?
636 * "The PROM is the computer."
639 /* Ok, restore the MMU control register we saved in %g5 */
640 sta %g5, [%g0] ASI_M_MMUREGS ! POW... ouch
642 /* Turn traps back on. We saved it in %g3 earlier. */
643 wr %g3, 0x0, %psr ! tick tock, tick tock
645 /* Now we burn precious CPU cycles due to bad engineering. */
648 /* Wow, all that just to move a 32-bit value from one
649 * place to another... Jump to high memory.
654 /* This works on viking's in Mbus mode and all
655 * other MBUS modules. It is virtually the same as
656 * the above madness sans turning traps off and flipping
661 lda [%g1] ASI_M_MMUREGS, %g1 ! get ctx table ptr
662 sll %g1, 0x4, %g1 ! make physical addr
663 lda [%g1] ASI_M_BYPASS, %g1 ! ptr to level 1 pg_table
665 sll %g1, 0x8, %g1 ! make phys addr for l1 tbl
667 lda [%g1] ASI_M_BYPASS, %g2 ! get level1 entry for 0x0
668 add %g1, 0x3c0, %g3 ! XXX AWAY WITH EMPIRICALS
669 sta %g2, [%g3] ASI_M_BYPASS ! place at KERNBASE entry
673 /* This remaps the kernel on Sun4/4xx machines
674 * that have the Sun Mutant Three Level MMU.
675 * It's like a platypus, Sun didn't have the
676 * SRMMU in conception so they kludged the three
677 * level logic in the regular Sun4 MMU probably.
679 * Basically, you take each entry in the top level
680 * directory that maps the low 3MB starting at
681 * address zero and put the mapping in the KERNBASE
682 * slots. These top level pgd's are called regmaps.
685 or %g0, %g0, %g3 ! source base
686 sethi %hi(KERNBASE), %g4 ! destination base
687 or %g4, %lo(KERNBASE), %g4
688 sethi %hi(0x300000), %g5
689 or %g5, %lo(0x300000), %g5 ! upper bound 3MB
691 sll %l6, 24, %l6 ! Regmap mapping size
692 add %g3, 0x2, %g3 ! Base magic
693 add %g4, 0x2, %g4 ! Base magic
695 /* Main remapping loop on Sun4-Mutant-MMU.
696 * "I am not an animal..." -Famous Mutant Person
699 lduha [%g3] ASI_REGMAP, %g2 ! Get lower entry
700 stha %g2, [%g4] ASI_REGMAP ! Store in high entry
701 add %g4, %l6, %g4 ! Move up high memory ptr
702 subcc %g3, %g5, %g0 ! Reached our limit?
703 blu sun4_mutant_loop ! Nope, loop again
704 add %g3, %l6, %g3 ! delay, Move up low ptr
705 b go_to_highmem ! Jump to high memory.
708 /* The following is for non-4/4xx sun4 MMU's. */
710 mov 0, %g3 ! source base
711 set KERNBASE, %g4 ! destination base
712 set 0x300000, %g5 ! upper bound 3MB
714 sll %l6, 18, %l6 ! sun4 mmu segmap size
716 lduha [%g3] ASI_SEGMAP, %g6 ! load phys_seg
717 stha %g6, [%g4] ASI_SEGMAP ! stort new virt mapping
718 add %g3, %l6, %g3 ! increment source pointer
719 subcc %g3, %g5, %g0 ! reached limit?
720 blu sun4_normal_loop ! nope, loop again
721 add %g4, %l6, %g4 ! delay, increment dest ptr
725 /* The following works for Sun4c MMU's */
727 mov 0, %g3 ! source base
728 set KERNBASE, %g4 ! destination base
729 set 0x300000, %g5 ! upper bound 3MB
731 sll %l6, 18, %l6 ! sun4c mmu segmap size
733 lda [%g3] ASI_SEGMAP, %g6 ! load phys_seg
734 sta %g6, [%g4] ASI_SEGMAP ! store new virt mapping
735 add %g3, %l6, %g3 ! Increment source ptr
736 subcc %g3, %g5, %g0 ! Reached limit?
737 bl sun4c_remap_loop ! Nope, loop again
738 add %g4, %l6, %g4 ! delay, Increment dest ptr
740 /* Now do a non-relative jump so that PC is in high-memory */
742 set execute_in_high_mem, %g1
746 /* This is to align init_task_union properly, be careful. -DaveM */
749 /* The code above should be at beginning and we have to take care about
750 * short jumps, as branching to .text.init section from .text is usually
753 /* Acquire boot time privileged register values, this will help debugging.
754 * I figure out and store nwindows and nwindowsm1 later on.
758 /* we don't have a prom :-( */
762 mov %l0, %o0 ! put back romvec
763 mov %l1, %o1 ! and debug_vec
765 sethi %hi( C_LABEL(prom_vector_p) ), %g1
766 st %o0, [%g1 + %lo( C_LABEL(prom_vector_p) )]
768 sethi %hi( C_LABEL(linux_dbvec) ), %g1
769 st %o1, [%g1 + %lo( C_LABEL(linux_dbvec) )]
772 and %o3, 0x3, %o5 ! get the version
774 cmp %o3, 0x2 ! a v2 prom?
778 /* paul@sfe.com.au */
779 cmp %o3, 0x3 ! a v3 prom?
783 /* Old sun4's pass our load address into %o0 instead of the prom
784 * pointer. On sun4's you have to hard code the romvec pointer into
785 * your code. Sun probably still does that because they don't even
786 * trust their own "OpenBoot" specifications.
789 cmp %o0, %g6 ! an old sun4?
795 /* For people who try sun4 kernels, even if Configure.help advises them. */
797 set sun4cdm_notsup, %o0
803 /* Get the machine type via the mysterious romvec node operations. */
809 or %g0, %g0, %o0 ! next_node(0) = first_node
812 sethi %hi( C_LABEL(cputypvar) ), %o1 ! First node has cpu-arch
813 or %o1, %lo( C_LABEL(cputypvar) ), %o1
814 sethi %hi( C_LABEL(cputypval) ), %o2 ! information, the string
815 or %o2, %lo( C_LABEL(cputypval) ), %o2
816 ld [%l1], %l0 ! 'compatibility' tells
817 ld [%l0 + 0xc], %l0 ! that we want 'sun4x' where
818 call %l0 ! x is one of '', 'c', 'm',
819 nop ! 'd' or 'e'. %o2 holds pointer
820 ! to a buf where above string
821 ! will get stored by the prom.
824 bpos got_prop ! Got the property
828 sethi %hi( C_LABEL(cputypvar_sun4m) ), %o1
829 or %o1, %lo( C_LABEL(cputypvar_sun4m) ), %o1
830 sethi %hi( C_LABEL(cputypval) ), %o2
831 or %o2, %lo( C_LABEL(cputypval) ), %o2
838 set C_LABEL(cputypval), %o2
839 ldub [%o2 + 0x4], %l1
852 be no_sun4e_here ! Could be a sun4e.
854 b no_sun4u_here ! AIEEE, a V9 sun4u... Get our BIG BROTHER kernel :))
857 1: set C_LABEL(cputypval), %l1
858 ldub [%l1 + 0x4], %l1
859 cmp %l1, 'm' ! Test for sun4d, sun4e ?
861 cmp %l1, 's' ! Treat sun4s as sun4m
863 cmp %l1, 'd' ! Let us see how the beast will die
867 /* Jump into mmu context zero. */
869 stba %g0, [%g1] ASI_CONTROL
871 b sun4c_continue_boot
874 /* CPUID in bootbus can be found at PA 0xff0140000 */
875 #define SUN4D_BOOTBUS_CPUID 0xf0140000
878 /* Need to patch call to handler_irq */
879 set C_LABEL(patch_handler_irq), %g4
880 set C_LABEL(sun4d_handler_irq), %g5
881 sethi %hi(0x40000000), %g3 ! call
888 /* Get our CPU id out of bootbus */
889 set SUN4D_BOOTBUS_CPUID, %g3
890 lduba [%g3] ASI_M_CTL, %g3
893 sta %g4, [%g0] ASI_M_VIKING_TMP1
894 sethi %hi(boot_cpu_id), %g5
895 stb %g4, [%g5 + %lo(boot_cpu_id)]
897 sethi %hi(boot_cpu_id4), %g5
898 stb %g4, [%g5 + %lo(boot_cpu_id4)]
901 /* Fall through to sun4m_init */
904 /* XXX Fucking Cypress... */
905 lda [%g0] ASI_M_MMUREGS, %g5
913 cmp %g4, 7 /* This would be a HyperSparc. */
920 #define PATCH_IT(dst, src) \
928 /* Signed multiply. */
929 PATCH_IT(.mul, .mul_patch)
930 PATCH_IT(.mul+0x08, .mul_patch+0x08)
932 /* Signed remainder. */
933 PATCH_IT(.rem, .rem_patch)
934 PATCH_IT(.rem+0x08, .rem_patch+0x08)
935 PATCH_IT(.rem+0x10, .rem_patch+0x10)
936 PATCH_IT(.rem+0x18, .rem_patch+0x18)
937 PATCH_IT(.rem+0x20, .rem_patch+0x20)
938 PATCH_IT(.rem+0x28, .rem_patch+0x28)
940 /* Signed division. */
941 PATCH_IT(.div, .div_patch)
942 PATCH_IT(.div+0x08, .div_patch+0x08)
943 PATCH_IT(.div+0x10, .div_patch+0x10)
944 PATCH_IT(.div+0x18, .div_patch+0x18)
945 PATCH_IT(.div+0x20, .div_patch+0x20)
947 /* Unsigned multiply. */
948 PATCH_IT(.umul, .umul_patch)
949 PATCH_IT(.umul+0x08, .umul_patch+0x08)
951 /* Unsigned remainder. */
952 PATCH_IT(.urem, .urem_patch)
953 PATCH_IT(.urem+0x08, .urem_patch+0x08)
954 PATCH_IT(.urem+0x10, .urem_patch+0x10)
955 PATCH_IT(.urem+0x18, .urem_patch+0x18)
957 /* Unsigned division. */
958 PATCH_IT(.udiv, .udiv_patch)
959 PATCH_IT(.udiv+0x08, .udiv_patch+0x08)
960 PATCH_IT(.udiv+0x10, .udiv_patch+0x10)
964 /* Ok, the PROM could have done funny things and apple cider could still
965 * be sitting in the fault status/address registers. Read them all to
966 * clear them so we don't get magic faults later on.
968 /* This sucks, apparently this makes Vikings call prom panic, will fix later */
971 srl %o1, 28, %o1 ! Get a type of the CPU
973 subcc %o1, 4, %g0 ! TI: Viking or MicroSPARC
974 be sun4c_continue_boot
978 lda [%o0] ASI_M_MMUREGS, %g0
980 lda [%o0] ASI_M_MMUREGS, %g0
982 /* Fujitsu MicroSPARC-II has no asynchronous flavors of FARs */
984 be sun4c_continue_boot
988 lda [%o0] ASI_M_MMUREGS, %g0
990 lda [%o0] ASI_M_MMUREGS, %g0
997 /* Aieee, now set PC and nPC, enable traps, give ourselves a stack and it's
1001 sethi %hi( C_LABEL(cputyp) ), %o0
1002 st %g4, [%o0 + %lo( C_LABEL(cputyp) )]
1004 /* Turn on Supervisor, EnableFloating, and all the PIL bits.
1005 * Also puts us in register window zero with traps off.
1007 set (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
1011 /* I want a kernel stack NOW! */
1012 set C_LABEL(init_task_union), %g1
1013 set (TASK_UNION_SIZE - REGWIN_SZ), %g2
1015 mov 0, %fp /* And for good luck */
1017 /* Zero out our BSS section. */
1018 set C_LABEL(__bss_start) , %o0 ! First address of BSS
1019 set C_LABEL(end) , %o1 ! Last address of BSS
1027 /* Initialize the umask value for init_task just in case.
1028 * But first make current_set[boot_cpu_id] point to something useful.
1030 set C_LABEL(init_task_union), %g6
1031 set C_LABEL(current_set), %g2
1033 sethi %hi(C_LABEL(boot_cpu_id4)), %g3
1034 ldub [%g3 + %lo(C_LABEL(boot_cpu_id4))], %g3
1040 st %g0, [%g6 + AOFF_task_thread + AOFF_thread_uwinmask]
1042 /* Compute NWINDOWS and stash it away. Now uses %wim trick explained
1043 * in the V8 manual. Ok, this method seems to work, Sparc is cool...
1044 * No, it doesn't work, have to play the save/readCWP/restore trick.
1047 wr %g0, 0x0, %wim ! so we do not get a trap
1060 wr %g1, 0x0, %wim ! make window 1 invalid
1067 /* Adjust our window handling routines to
1068 * do things correctly on 7 window Sparcs.
1071 #define PATCH_INSN(src, dest) \
1077 /* Patch for window spills... */
1078 PATCH_INSN(spnwin_patch1_7win, spnwin_patch1)
1079 PATCH_INSN(spnwin_patch2_7win, spnwin_patch2)
1080 PATCH_INSN(spnwin_patch3_7win, spnwin_patch3)
1082 /* Patch for window fills... */
1083 PATCH_INSN(fnwin_patch1_7win, fnwin_patch1)
1084 PATCH_INSN(fnwin_patch2_7win, fnwin_patch2)
1086 /* Patch for trap entry setup... */
1087 PATCH_INSN(tsetup_7win_patch1, tsetup_patch1)
1088 PATCH_INSN(tsetup_7win_patch2, tsetup_patch2)
1089 PATCH_INSN(tsetup_7win_patch3, tsetup_patch3)
1090 PATCH_INSN(tsetup_7win_patch4, tsetup_patch4)
1091 PATCH_INSN(tsetup_7win_patch5, tsetup_patch5)
1092 PATCH_INSN(tsetup_7win_patch6, tsetup_patch6)
1094 /* Patch for returning from traps... */
1095 PATCH_INSN(rtrap_7win_patch1, rtrap_patch1)
1096 PATCH_INSN(rtrap_7win_patch2, rtrap_patch2)
1097 PATCH_INSN(rtrap_7win_patch3, rtrap_patch3)
1098 PATCH_INSN(rtrap_7win_patch4, rtrap_patch4)
1099 PATCH_INSN(rtrap_7win_patch5, rtrap_patch5)
1101 /* Patch for killing user windows from the register file. */
1102 PATCH_INSN(kuw_patch1_7win, kuw_patch1)
1104 /* Now patch the kernel window flush sequences.
1105 * This saves 2 traps on every switch and fork.
1108 set flush_patch_one, %g5
1109 st %g4, [%g5 + 0x18]
1110 st %g4, [%g5 + 0x1c]
1111 set flush_patch_two, %g5
1112 st %g4, [%g5 + 0x18]
1113 st %g4, [%g5 + 0x1c]
1114 set flush_patch_three, %g5
1115 st %g4, [%g5 + 0x18]
1116 st %g4, [%g5 + 0x1c]
1117 set flush_patch_four, %g5
1118 st %g4, [%g5 + 0x18]
1119 st %g4, [%g5 + 0x1c]
1120 set flush_patch_exception, %g5
1121 st %g4, [%g5 + 0x18]
1122 st %g4, [%g5 + 0x1c]
1123 set flush_patch_switch, %g5
1124 st %g4, [%g5 + 0x18]
1125 st %g4, [%g5 + 0x1c]
1128 sethi %hi( C_LABEL(nwindows) ), %g4
1129 st %g3, [%g4 + %lo( C_LABEL(nwindows) )] ! store final value
1131 sethi %hi( C_LABEL(nwindowsm1) ), %g4
1132 st %g3, [%g4 + %lo( C_LABEL(nwindowsm1) )]
1134 /* Here we go, start using Linux's trap table... */
1135 set C_LABEL(trapbase), %g3
1139 /* Finally, turn on traps so that we can call c-code. */
1144 wr %g3, PSR_ET, %psr
1147 /* First we call prom_init() to set up PROMLIB, then
1148 * off to start_kernel().
1151 sethi %hi( C_LABEL(prom_vector_p) ), %g5
1152 ld [%g5 + %lo( C_LABEL(prom_vector_p) )], %o0
1153 call C_LABEL(prom_init)
1156 call C_LABEL(start_kernel)
1159 /* We should not get here. */
1165 /* There, happy now Adrian? */
1166 set C_LABEL(cputypval), %o2 ! Let everyone know we
1167 set ' ', %o0 ! are a "sun4 " architecture
1168 stb %o0, [%o2 + 0x4]
1173 sethi %hi(SUN4_PROM_VECTOR+0x84), %o1
1174 ld [%o1 + %lo(SUN4_PROM_VECTOR+0x84)], %o1
1175 set sun4_notsup, %o0
1176 call %o1 /* printf */
1178 sethi %hi(SUN4_PROM_VECTOR+0xc4), %o1
1179 ld [%o1 + %lo(SUN4_PROM_VECTOR+0xc4)], %o1
1180 call %o1 /* exittomon */
1182 1: ba 1b ! Cannot exit into KMON
1186 ld [%g7 + 0x68], %o1
1187 set sun4e_notsup, %o0
1211 .asciz "\n\rOn sun4u you have to use UltraLinux (64bit) kernel\n\rand not a 32bit sun4[cdem] version\n\r\n\r"
1218 .word 0, sun4u_1, 0, 1, 0, 1, 0, sun4u_2, 0
1222 .word 0, sun4u_3, 0, 4, 0, 1, 0
1224 .word 0, 0, sun4u_4, 0, sun4u_1, 0, 8, 0
1228 .word 0, sun4u_5, 0, 3, 0, 1, 0
1230 .word 0, 0, sun4u_6, 0, sun4u_6e - sun4u_6 - 1, 0
1234 .word 0, sun4u_7, 0, 0, 0, 0
1247 mov sun4u_r4 - sun4u_a1, %l3
1263 ld [%l1 + (sun4u_r1 - sun4u_a1)], %o1
1264 add %l1, (sun4u_a2 - sun4u_a1), %o0
1266 st %o1, [%o0 + (sun4u_i2 - sun4u_a2)]
1268 ld [%l1 + (sun4u_1 - sun4u_a1)], %o1
1269 add %l1, (sun4u_a3 - sun4u_a1), %o0
1271 st %o1, [%o0 + (sun4u_i3 - sun4u_a3)]
1274 add %l1, (sun4u_a4 - sun4u_a1), %o0
1278 ld [%g7 + 0x74], %o0
1279 call %o0 ! Get us out of here...
1280 nop ! Apparently Solaris is better.
1282 /* Ok, now we continue in the .data/.text sections */
1288 * Fill up the prom vector, note in particular the kind first element,
1289 * no joke. I don't need all of them in here as the entire prom vector
1290 * gets initialized in c-code so all routines can use it.
1293 .globl C_LABEL(prom_vector_p)
1294 C_LABEL(prom_vector_p):
1297 /* We calculate the following at boot time, window fills/spills and trap entry
1298 * code uses these to keep track of the register windows.
1302 .globl C_LABEL(nwindows)
1303 .globl C_LABEL(nwindowsm1)
1306 C_LABEL(nwindowsm1):
1309 /* Boot time debugger vector value. We need this later on. */
1312 .globl C_LABEL(linux_dbvec)
1313 C_LABEL(linux_dbvec):
1319 .globl C_LABEL(lvl14_save)
1320 C_LABEL(lvl14_save):
1327 .section ".fixup",#alloc,#execinstr
1331 restore %g0, -EFAULT, %o0