1 /* $Id: head.S,v 1.105 2001/08/12 09:08:56 davem 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@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)
10 * CompactPCI platform by Eric Brower, 1999.
13 #include <linux/version.h>
14 #include <linux/init.h>
18 #include <asm/contregs.h>
19 #include <asm/ptrace.h>
22 #include <asm/kdebug.h>
23 #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 */
30 * The following are used with the prom_vector node-ops to figure out
46 cputypvallen = cputypvar - 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. */
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 #ifndef CONFIG_SUNOS_EMUL
82 #undef SUNOS_SYSCALL_TRAP
83 #define SUNOS_SYSCALL_TRAP SUNOS_NO_SYSCALL_TRAP
86 /* The Sparc trap table, bootloader gives us control at _start. */
88 .globl start, _stext, _start, __stext
90 _start: /* danger danger */
98 /* We get control passed to us here at t_zero. */
99 t_zero: b gokernel; nop; nop; nop;
100 t_tflt: SPARC_TFAULT /* Inst. Access Exception */
101 t_bins: TRAP_ENTRY(0x2, bad_instruction) /* Illegal Instruction */
102 t_pins: TRAP_ENTRY(0x3, priv_instruction) /* Privileged Instruction */
103 t_fpd: TRAP_ENTRY(0x4, fpd_trap_handler) /* Floating Point Disabled */
104 t_wovf: WINDOW_SPILL /* Window Overflow */
105 t_wunf: WINDOW_FILL /* Window Underflow */
106 t_mna: TRAP_ENTRY(0x7, mna_handler) /* Memory Address Not Aligned */
107 t_fpe: TRAP_ENTRY(0x8, fpe_trap_handler) /* Floating Point Exception */
108 t_dflt: SPARC_DFAULT /* Data Miss Exception */
109 t_tio: TRAP_ENTRY(0xa, do_tag_overflow) /* Tagged Instruction Ovrflw */
110 t_wpt: TRAP_ENTRY(0xb, do_watchpoint) /* Watchpoint Detected */
111 t_badc: BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
112 t_irq1: TRAP_ENTRY_INTERRUPT(1) /* IRQ Software/SBUS Level 1 */
113 t_irq2: TRAP_ENTRY_INTERRUPT(2) /* IRQ SBUS Level 2 */
114 t_irq3: TRAP_ENTRY_INTERRUPT(3) /* IRQ SCSI/DMA/SBUS Level 3 */
115 t_irq4: TRAP_ENTRY_INTERRUPT(4) /* IRQ Software Level 4 */
116 t_irq5: TRAP_ENTRY_INTERRUPT(5) /* IRQ SBUS/Ethernet Level 5 */
117 t_irq6: TRAP_ENTRY_INTERRUPT(6) /* IRQ Software Level 6 */
118 t_irq7: TRAP_ENTRY_INTERRUPT(7) /* IRQ Video/SBUS Level 5 */
119 t_irq8: TRAP_ENTRY_INTERRUPT(8) /* IRQ SBUS Level 6 */
120 t_irq9: TRAP_ENTRY_INTERRUPT(9) /* IRQ SBUS Level 7 */
121 t_irq10:TRAP_ENTRY_INTERRUPT(10) /* IRQ Timer #1 (one we use) */
122 t_irq11:TRAP_ENTRY_INTERRUPT(11) /* IRQ Floppy Intr. */
123 t_irq12:TRAP_ENTRY_INTERRUPT(12) /* IRQ Zilog serial chip */
124 t_irq13:TRAP_ENTRY_INTERRUPT(13) /* IRQ Audio Intr. */
125 t_irq14:TRAP_ENTRY_INTERRUPT(14) /* IRQ Timer #2 */
128 t_nmi: NMI_TRAP /* Level 15 (NMI) */
130 t_nmi: TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
132 t_racc: TRAP_ENTRY(0x20, do_reg_access) /* General Register Access Error */
133 t_iacce:BAD_TRAP(0x21) /* Instr Access Error */
134 t_bad22:BAD_TRAP(0x22) BAD_TRAP(0x23)
135 t_cpdis:TRAP_ENTRY(0x24, do_cp_disabled) /* Co-Processor Disabled */
136 t_uflsh:SKIP_TRAP(0x25, unimp_flush) /* Unimplemented FLUSH inst. */
137 t_bad26:BAD_TRAP(0x26) BAD_TRAP(0x27)
138 t_cpexc:TRAP_ENTRY(0x28, do_cp_exception) /* Co-Processor Exception */
139 t_dacce:SPARC_DFAULT /* Data Access Error */
140 t_hwdz: TRAP_ENTRY(0x2a, do_hw_divzero) /* Division by zero, you lose... */
141 t_dserr:BAD_TRAP(0x2b) /* Data Store Error */
142 t_daccm:BAD_TRAP(0x2c) /* Data Access MMU-Miss */
143 t_bad2d:BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
144 t_bad32:BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
145 t_bad37:BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
146 t_iaccm:BAD_TRAP(0x3c) /* Instr Access MMU-Miss */
147 t_bad3d:BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40) BAD_TRAP(0x41)
148 t_bad42:BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45) BAD_TRAP(0x46)
149 t_bad47:BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a) BAD_TRAP(0x4b)
150 t_bad4c:BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f) BAD_TRAP(0x50)
151 t_bad51:BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
152 t_bad56:BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
153 t_bad5b:BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
154 t_bad60:BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
155 t_bad65:BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
156 t_bad6a:BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
157 t_bad6f:BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
158 t_bad74:BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
159 t_bad79:BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
160 t_bad7e:BAD_TRAP(0x7e) BAD_TRAP(0x7f)
161 t_sunos:SUNOS_SYSCALL_TRAP /* SunOS System Call */
162 t_sbkpt:BREAKPOINT_TRAP /* Software Breakpoint/KGDB */
163 t_divz: TRAP_ENTRY(0x82, do_hw_divzero) /* Divide by zero trap */
164 t_flwin:TRAP_ENTRY(0x83, do_flush_windows) /* Flush Windows Trap */
165 t_clwin:BAD_TRAP(0x84) /* Clean Windows Trap */
166 t_rchk: BAD_TRAP(0x85) /* Range Check */
167 t_funal:BAD_TRAP(0x86) /* Fix Unaligned Access Trap */
168 t_iovf: BAD_TRAP(0x87) /* Integer Overflow Trap */
169 t_slowl:SOLARIS_SYSCALL_TRAP /* Slowaris System Call */
170 t_netbs:NETBSD_SYSCALL_TRAP /* Net-B.S. System Call */
171 t_bad8a:BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) BAD_TRAP(0x8d) BAD_TRAP(0x8e)
172 t_bad8f:BAD_TRAP(0x8f)
173 t_linux:LINUX_SYSCALL_TRAP /* Linux System Call */
174 t_bad91:BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94) BAD_TRAP(0x95)
175 t_bad96:BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99) BAD_TRAP(0x9a)
176 t_bad9b:BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e) BAD_TRAP(0x9f)
177 t_getcc:GETCC_TRAP /* Get Condition Codes */
178 t_setcc:SETCC_TRAP /* Set Condition Codes */
179 t_getpsr:GETPSR_TRAP /* Get PSR Register */
180 t_bada3:BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
181 t_slowi:INDIRECT_SOLARIS_SYSCALL(156)
182 t_bada8:BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
183 t_badac:BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
184 t_badb1:BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
185 t_badb6:BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
186 t_badbb:BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
187 t_badc0:BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
188 t_badc5:BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
189 t_badca:BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
190 t_badcf:BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
191 t_badd4:BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
192 t_badd9:BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
193 t_badde:BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
194 t_bade3:BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
195 t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
196 t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
197 t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
198 t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
199 t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd)
200 dbtrap: BAD_TRAP(0xfe) /* Debugger/PROM breakpoint #1 */
201 dbtrap2:BAD_TRAP(0xff) /* Debugger/PROM breakpoint #2 */
207 /* Trap tables for the other cpus. */
208 .globl trapbase_cpu1, trapbase_cpu2, trapbase_cpu3
210 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
211 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
212 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
213 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
214 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
215 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
216 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
217 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
218 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
219 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
220 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
221 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
222 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
223 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
224 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
225 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
226 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
227 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
228 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
229 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
230 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
231 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
232 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
233 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
234 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
236 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
237 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
238 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
239 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
240 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
241 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
242 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
243 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
244 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
245 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
248 TRAP_ENTRY(0x82, do_hw_divzero)
249 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
250 BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
251 NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
252 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
253 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
254 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
255 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
256 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
257 BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
258 INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
259 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
260 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
261 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
262 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
263 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
264 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
265 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
266 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
267 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
268 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
269 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
270 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
271 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
272 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
273 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
274 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
275 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
278 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
279 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
280 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
281 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
282 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
283 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
284 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
285 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
286 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
287 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
288 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
289 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
290 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
291 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
292 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
293 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
294 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
295 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
296 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
297 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
298 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
299 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
300 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
301 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
302 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
304 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
305 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
306 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
307 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
308 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
309 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
310 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
311 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
312 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
313 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
316 TRAP_ENTRY(0x82, do_hw_divzero)
317 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
318 BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
319 NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
320 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
321 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
322 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
323 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
324 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
325 BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
326 INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
327 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
328 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
329 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
330 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
331 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
332 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
333 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
334 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
335 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
336 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
337 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
338 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
339 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
340 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
341 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
342 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
343 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
346 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
347 TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
348 WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
349 TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
350 TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
351 BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
352 TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
353 TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
354 TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
355 TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
356 TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
357 TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
358 TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
359 TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
360 TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
361 BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
362 BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
363 SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
364 BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
365 BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
366 BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
367 BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
368 BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
369 BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
370 BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
372 BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
373 BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
374 BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
375 BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
376 BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
377 BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
378 BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
379 BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
380 BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
381 BAD_TRAP(0x7e) BAD_TRAP(0x7f)
384 TRAP_ENTRY(0x82, do_hw_divzero)
385 TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
386 BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
387 NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
388 BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
389 LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
390 BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
391 BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
392 BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
393 BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
394 INDIRECT_SOLARIS_SYSCALL(156) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
395 BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
396 BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
397 BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
398 BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
399 BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
400 BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
401 BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
402 BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
403 BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
404 BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
405 BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
406 BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
407 BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
408 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
409 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
410 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
411 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
416 /* This was the only reasonable way I could think of to properly align
417 * these page-table data structures.
419 .globl pg0, pg1, pg2, pg3
420 .globl empty_bad_page
421 .globl empty_bad_page_table
422 .globl empty_zero_page
423 .globl swapper_pg_dir
424 swapper_pg_dir: .skip PAGE_SIZE
429 empty_bad_page: .skip PAGE_SIZE
430 empty_bad_page_table: .skip PAGE_SIZE
431 empty_zero_page: .skip PAGE_SIZE
436 .global sparc_ramdisk_image
437 .global sparc_ramdisk_size
439 /* This stuff has to be in sync with SILO and other potential boot loaders
440 * Fields should be kept upward compatible and whenever any change is made,
441 * HdrS version should be incremented.
444 .word LINUX_VERSION_CODE
445 .half 0x0203 /* HdrS version */
460 /* Cool, here we go. Pick up the romvec pointer in %o0 and stash it in
461 * %g7 and at prom_vector_p. And also quickly check whether we are on
462 * a v0, v2, or v3 prom.
465 /* Ok, it's nice to know, as early as possible, if we
466 * are already mapped where we expect to be in virtual
467 * memory. The Solaris /boot elf format bootloader
468 * will peek into our elf header and load us where
469 * we want to be, otherwise we have to re-map.
471 * Some boot loaders don't place the jmp'rs address
472 * in %o7, so we do a pc-relative call to a local
473 * label, then see what %o7 has.
476 mov %o7, %g4 ! Save %o7
478 /* Jump to it, and pray... */
488 mov %g4, %o7 /* Previous %o7. */
490 mov %o0, %l0 ! stash away romvec
491 mov %o0, %g7 ! put it here too
492 mov %o1, %l1 ! stash away debug_vec too
494 /* Ok, let's check out our run time program counter. */
500 /* %l6 will hold the offset we have to subtract
501 * from absolute symbols in order to access areas
502 * in our own image. If already mapped this is
503 * just plain zero, else it is KERNBASE.
512 /* Copy over the Prom's level 14 clock handler. */
516 * preserve our linked/calculated instructions
520 sub %g1, %l6, %g1 ! translate to physical
521 sub %g3, %l6, %g3 ! translate to physical
528 andn %g1, 0xfff, %g1 ! proms trap table base
529 or %g0, (0x1e<<4), %g2 ! offset to lvl14 intr
536 std %g4, [%g3 + 0x8] ! Copy proms handler
538 /* Must determine whether we are on a sun4c MMU, SRMMU, or SUN4/400 MUTANT
539 * MMU so we can remap ourselves properly. DON'T TOUCH %l0 thru %l5 in these
540 * remapping routines, we need their values afterwards!
542 /* Now check whether we are already mapped, if we
543 * are we can skip all this garbage coming up.
547 be go_to_highmem ! this will be a nop then
552 bne remap_not_a_sun4 ! This is not a Sun4
556 lduba [%g1] ASI_CONTROL, %g1 ! Only safe to try on Sun4.
557 subcc %g1, 0x24, %g0 ! Is this a mutant Sun4/400???
558 be sun4_mutant_remap ! Ugh, it is...
561 b sun4_normal_remap ! regular sun4, 2 level mmu
565 lda [%g0] ASI_M_MMUREGS, %g1 ! same as ASI_PTE on sun4c
566 and %g1, 0x1, %g1 ! Test SRMMU Enable bit ;-)
568 be sun4c_remap ! A sun4c MMU or normal Sun4
571 /* First, check for a viking (TI) module. */
579 /* Figure out what kind of viking we are on.
580 * We need to know if we have to play with the
581 * AC bit and disable traps or not.
584 /* I've only seen MicroSparc's on SparcClassics with this
588 lda [%g0] ASI_M_MMUREGS, %g3 ! peek in the control reg
591 bnz srmmu_nviking ! is in mbus mode
594 rd %psr, %g3 ! DO NOT TOUCH %g3
595 andn %g3, PSR_ET, %g2
599 /* Get context table pointer, then convert to
600 * a physical address, which is 36 bits.
603 lda [%g4] ASI_M_MMUREGS, %g4
604 sll %g4, 0x4, %g4 ! We use this below
607 /* Set the AC bit in the Viking's MMU control reg. */
608 lda [%g0] ASI_M_MMUREGS, %g5 ! DO NOT TOUCH %g5
609 set 0x8000, %g6 ! AC bit mask
610 or %g5, %g6, %g6 ! Or it in...
611 sta %g6, [%g0] ASI_M_MMUREGS ! Close your eyes...
613 /* Grrr, why does it seem like every other load/store
614 * on the sun4m is in some ASI space...
615 * Fine with me, let's get the pointer to the level 1
616 * page table directory and fetch its entry.
618 lda [%g4] ASI_M_BYPASS, %o1 ! This is a level 1 ptr
619 srl %o1, 0x4, %o1 ! Clear low 4 bits
620 sll %o1, 0x8, %o1 ! Make physical
622 /* Ok, pull in the PTD. */
623 lda [%o1] ASI_M_BYPASS, %o2 ! This is the 0x0 16MB pgd
625 /* Calculate to KERNBASE entry. */
626 add %o1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %o3
628 /* Poke the entry into the calculated address. */
629 sta %o2, [%o3] ASI_M_BYPASS
631 /* I don't get it Sun, if you engineered all these
632 * boot loaders and the PROM (thank you for the debugging
633 * features btw) why did you not have them load kernel
634 * images up in high address space, since this is necessary
635 * for ABI compliance anyways? Does this low-mapping provide
636 * enhanced interoperability?
638 * "The PROM is the computer."
641 /* Ok, restore the MMU control register we saved in %g5 */
642 sta %g5, [%g0] ASI_M_MMUREGS ! POW... ouch
644 /* Turn traps back on. We saved it in %g3 earlier. */
645 wr %g3, 0x0, %psr ! tick tock, tick tock
647 /* Now we burn precious CPU cycles due to bad engineering. */
650 /* Wow, all that just to move a 32-bit value from one
651 * place to another... Jump to high memory.
656 /* This works on viking's in Mbus mode and all
657 * other MBUS modules. It is virtually the same as
658 * the above madness sans turning traps off and flipping
663 lda [%g1] ASI_M_MMUREGS, %g1 ! get ctx table ptr
664 sll %g1, 0x4, %g1 ! make physical addr
665 lda [%g1] ASI_M_BYPASS, %g1 ! ptr to level 1 pg_table
667 sll %g1, 0x8, %g1 ! make phys addr for l1 tbl
669 lda [%g1] ASI_M_BYPASS, %g2 ! get level1 entry for 0x0
670 add %g1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %g3
671 sta %g2, [%g3] ASI_M_BYPASS ! place at KERNBASE entry
675 /* This remaps the kernel on Sun4/4xx machines
676 * that have the Sun Mutant Three Level MMU.
677 * It's like a platypus, Sun didn't have the
678 * SRMMU in conception so they kludged the three
679 * level logic in the regular Sun4 MMU probably.
681 * Basically, you take each entry in the top level
682 * directory that maps the low 3MB starting at
683 * address zero and put the mapping in the KERNBASE
684 * slots. These top level pgd's are called regmaps.
687 or %g0, %g0, %g3 ! source base
688 sethi %hi(KERNBASE), %g4 ! destination base
689 or %g4, %lo(KERNBASE), %g4
690 sethi %hi(0x300000), %g5
691 or %g5, %lo(0x300000), %g5 ! upper bound 3MB
693 sll %l6, 24, %l6 ! Regmap mapping size
694 add %g3, 0x2, %g3 ! Base magic
695 add %g4, 0x2, %g4 ! Base magic
697 /* Main remapping loop on Sun4-Mutant-MMU.
698 * "I am not an animal..." -Famous Mutant Person
701 lduha [%g3] ASI_REGMAP, %g2 ! Get lower entry
702 stha %g2, [%g4] ASI_REGMAP ! Store in high entry
703 add %g4, %l6, %g4 ! Move up high memory ptr
704 subcc %g3, %g5, %g0 ! Reached our limit?
705 blu sun4_mutant_loop ! Nope, loop again
706 add %g3, %l6, %g3 ! delay, Move up low ptr
707 b go_to_highmem ! Jump to high memory.
710 /* The following is for non-4/4xx sun4 MMU's. */
712 mov 0, %g3 ! source base
713 set KERNBASE, %g4 ! destination base
714 set 0x300000, %g5 ! upper bound 3MB
716 sll %l6, 18, %l6 ! sun4 mmu segmap size
718 lduha [%g3] ASI_SEGMAP, %g6 ! load phys_seg
719 stha %g6, [%g4] ASI_SEGMAP ! stort new virt mapping
720 add %g3, %l6, %g3 ! increment source pointer
721 subcc %g3, %g5, %g0 ! reached limit?
722 blu sun4_normal_loop ! nope, loop again
723 add %g4, %l6, %g4 ! delay, increment dest ptr
727 /* The following works for Sun4c MMU's */
729 mov 0, %g3 ! source base
730 set KERNBASE, %g4 ! destination base
731 set 0x300000, %g5 ! upper bound 3MB
733 sll %l6, 18, %l6 ! sun4c mmu segmap size
735 lda [%g3] ASI_SEGMAP, %g6 ! load phys_seg
736 sta %g6, [%g4] ASI_SEGMAP ! store new virt mapping
737 add %g3, %l6, %g3 ! Increment source ptr
738 subcc %g3, %g5, %g0 ! Reached limit?
739 bl sun4c_remap_loop ! Nope, loop again
740 add %g4, %l6, %g4 ! delay, Increment dest ptr
742 /* Now do a non-relative jump so that PC is in high-memory */
744 set execute_in_high_mem, %g1
748 /* The code above should be at beginning and we have to take care about
749 * short jumps, as branching to .text.init section from .text is usually
752 /* Acquire boot time privileged register values, this will help debugging.
753 * I figure out and store nwindows and nwindowsm1 later on.
756 mov %l0, %o0 ! put back romvec
757 mov %l1, %o1 ! and debug_vec
759 sethi %hi(prom_vector_p), %g1
760 st %o0, [%g1 + %lo(prom_vector_p)]
762 sethi %hi(linux_dbvec), %g1
763 st %o1, [%g1 + %lo(linux_dbvec)]
766 and %o3, 0x3, %o5 ! get the version
768 cmp %o3, 0x2 ! a v2 prom?
772 /* paul@sfe.com.au */
773 cmp %o3, 0x3 ! a v3 prom?
777 /* Old sun4's pass our load address into %o0 instead of the prom
778 * pointer. On sun4's you have to hard code the romvec pointer into
779 * your code. Sun probably still does that because they don't even
780 * trust their own "OpenBoot" specifications.
783 cmp %o0, %g6 ! an old sun4?
789 /* For people who try sun4 kernels, even if Configure.help advises them. */
791 set sun4cdm_notsup, %o0
797 /* Get the machine type via the mysterious romvec node operations. */
803 or %g0, %g0, %o0 ! next_node(0) = first_node
806 sethi %hi(cputypvar), %o1 ! First node has cpu-arch
807 or %o1, %lo(cputypvar), %o1
808 sethi %hi(cputypval), %o2 ! information, the string
809 or %o2, %lo(cputypval), %o2
810 ld [%l1], %l0 ! 'compatibility' tells
811 ld [%l0 + 0xc], %l0 ! that we want 'sun4x' where
812 call %l0 ! x is one of '', 'c', 'm',
813 nop ! 'd' or 'e'. %o2 holds pointer
814 ! to a buf where above string
815 ! will get stored by the prom.
818 bpos got_prop ! Got the property
822 sethi %hi(cputypvar_sun4m), %o1
823 or %o1, %lo(cputypvar_sun4m), %o1
824 sethi %hi(cputypval), %o2
825 or %o2, %lo(cputypval), %o2
833 ldub [%o2 + 0x4], %l1
846 be no_sun4e_here ! Could be a sun4e.
848 b no_sun4u_here ! AIEEE, a V9 sun4u... Get our BIG BROTHER kernel :))
851 1: set cputypval, %l1
852 ldub [%l1 + 0x4], %l1
853 cmp %l1, 'm' ! Test for sun4d, sun4e ?
855 cmp %l1, 's' ! Treat sun4s as sun4m
857 cmp %l1, 'd' ! Let us see how the beast will die
861 /* Jump into mmu context zero. */
863 stba %g0, [%g1] ASI_CONTROL
865 b sun4c_continue_boot
868 /* CPUID in bootbus can be found at PA 0xff0140000 */
869 #define SUN4D_BOOTBUS_CPUID 0xf0140000
872 /* Need to patch call to handler_irq */
873 set patch_handler_irq, %g4
874 set sun4d_handler_irq, %g5
875 sethi %hi(0x40000000), %g3 ! call
882 /* Get our CPU id out of bootbus */
883 set SUN4D_BOOTBUS_CPUID, %g3
884 lduba [%g3] ASI_M_CTL, %g3
887 sta %g4, [%g0] ASI_M_VIKING_TMP1
888 sethi %hi(boot_cpu_id), %g5
889 stb %g4, [%g5 + %lo(boot_cpu_id)]
891 sethi %hi(boot_cpu_id4), %g5
892 stb %g4, [%g5 + %lo(boot_cpu_id4)]
895 /* Fall through to sun4m_init */
898 /* XXX Fucking Cypress... */
899 lda [%g0] ASI_M_MMUREGS, %g5
907 cmp %g4, 7 /* This would be a HyperSparc. */
914 #define PATCH_IT(dst, src) \
922 /* Signed multiply. */
923 PATCH_IT(.mul, .mul_patch)
924 PATCH_IT(.mul+0x08, .mul_patch+0x08)
926 /* Signed remainder. */
927 PATCH_IT(.rem, .rem_patch)
928 PATCH_IT(.rem+0x08, .rem_patch+0x08)
929 PATCH_IT(.rem+0x10, .rem_patch+0x10)
930 PATCH_IT(.rem+0x18, .rem_patch+0x18)
931 PATCH_IT(.rem+0x20, .rem_patch+0x20)
932 PATCH_IT(.rem+0x28, .rem_patch+0x28)
934 /* Signed division. */
935 PATCH_IT(.div, .div_patch)
936 PATCH_IT(.div+0x08, .div_patch+0x08)
937 PATCH_IT(.div+0x10, .div_patch+0x10)
938 PATCH_IT(.div+0x18, .div_patch+0x18)
939 PATCH_IT(.div+0x20, .div_patch+0x20)
941 /* Unsigned multiply. */
942 PATCH_IT(.umul, .umul_patch)
943 PATCH_IT(.umul+0x08, .umul_patch+0x08)
945 /* Unsigned remainder. */
946 PATCH_IT(.urem, .urem_patch)
947 PATCH_IT(.urem+0x08, .urem_patch+0x08)
948 PATCH_IT(.urem+0x10, .urem_patch+0x10)
949 PATCH_IT(.urem+0x18, .urem_patch+0x18)
951 /* Unsigned division. */
952 PATCH_IT(.udiv, .udiv_patch)
953 PATCH_IT(.udiv+0x08, .udiv_patch+0x08)
954 PATCH_IT(.udiv+0x10, .udiv_patch+0x10)
958 /* Ok, the PROM could have done funny things and apple cider could still
959 * be sitting in the fault status/address registers. Read them all to
960 * clear them so we don't get magic faults later on.
962 /* This sucks, apparently this makes Vikings call prom panic, will fix later */
965 srl %o1, 28, %o1 ! Get a type of the CPU
967 subcc %o1, 4, %g0 ! TI: Viking or MicroSPARC
968 be sun4c_continue_boot
972 lda [%o0] ASI_M_MMUREGS, %g0
974 lda [%o0] ASI_M_MMUREGS, %g0
976 /* Fujitsu MicroSPARC-II has no asynchronous flavors of FARs */
978 be sun4c_continue_boot
982 lda [%o0] ASI_M_MMUREGS, %g0
984 lda [%o0] ASI_M_MMUREGS, %g0
991 /* Aieee, now set PC and nPC, enable traps, give ourselves a stack and it's
995 sethi %hi(cputyp), %o0
996 st %g4, [%o0 + %lo(cputyp)]
998 /* Turn on Supervisor, EnableFloating, and all the PIL bits.
999 * Also puts us in register window zero with traps off.
1001 set (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
1005 /* I want a kernel stack NOW! */
1006 set init_thread_union, %g1
1007 set (THREAD_SIZE - STACKFRAME_SZ), %g2
1009 mov 0, %fp /* And for good luck */
1011 /* Zero out our BSS section. */
1012 set __bss_start , %o0 ! First address of BSS
1013 set end , %o1 ! Last address of BSS
1021 /* Initialize the uwinmask value for init task just in case.
1022 * But first make current_set[boot_cpu_id] point to something useful.
1024 set init_thread_union, %g6
1025 set current_set, %g2
1027 sethi %hi(boot_cpu_id4), %g3
1028 ldub [%g3 + %lo(boot_cpu_id4)], %g3
1034 st %g0, [%g6 + TI_UWINMASK]
1036 /* Compute NWINDOWS and stash it away. Now uses %wim trick explained
1037 * in the V8 manual. Ok, this method seems to work, Sparc is cool...
1038 * No, it doesn't work, have to play the save/readCWP/restore trick.
1041 wr %g0, 0x0, %wim ! so we do not get a trap
1054 wr %g1, 0x0, %wim ! make window 1 invalid
1061 /* Adjust our window handling routines to
1062 * do things correctly on 7 window Sparcs.
1065 #define PATCH_INSN(src, dest) \
1071 /* Patch for window spills... */
1072 PATCH_INSN(spnwin_patch1_7win, spnwin_patch1)
1073 PATCH_INSN(spnwin_patch2_7win, spnwin_patch2)
1074 PATCH_INSN(spnwin_patch3_7win, spnwin_patch3)
1076 /* Patch for window fills... */
1077 PATCH_INSN(fnwin_patch1_7win, fnwin_patch1)
1078 PATCH_INSN(fnwin_patch2_7win, fnwin_patch2)
1080 /* Patch for trap entry setup... */
1081 PATCH_INSN(tsetup_7win_patch1, tsetup_patch1)
1082 PATCH_INSN(tsetup_7win_patch2, tsetup_patch2)
1083 PATCH_INSN(tsetup_7win_patch3, tsetup_patch3)
1084 PATCH_INSN(tsetup_7win_patch4, tsetup_patch4)
1085 PATCH_INSN(tsetup_7win_patch5, tsetup_patch5)
1086 PATCH_INSN(tsetup_7win_patch6, tsetup_patch6)
1088 /* Patch for returning from traps... */
1089 PATCH_INSN(rtrap_7win_patch1, rtrap_patch1)
1090 PATCH_INSN(rtrap_7win_patch2, rtrap_patch2)
1091 PATCH_INSN(rtrap_7win_patch3, rtrap_patch3)
1092 PATCH_INSN(rtrap_7win_patch4, rtrap_patch4)
1093 PATCH_INSN(rtrap_7win_patch5, rtrap_patch5)
1095 /* Patch for killing user windows from the register file. */
1096 PATCH_INSN(kuw_patch1_7win, kuw_patch1)
1098 /* Now patch the kernel window flush sequences.
1099 * This saves 2 traps on every switch and fork.
1102 set flush_patch_one, %g5
1103 st %g4, [%g5 + 0x18]
1104 st %g4, [%g5 + 0x1c]
1105 set flush_patch_two, %g5
1106 st %g4, [%g5 + 0x18]
1107 st %g4, [%g5 + 0x1c]
1108 set flush_patch_three, %g5
1109 st %g4, [%g5 + 0x18]
1110 st %g4, [%g5 + 0x1c]
1111 set flush_patch_four, %g5
1112 st %g4, [%g5 + 0x18]
1113 st %g4, [%g5 + 0x1c]
1114 set flush_patch_exception, %g5
1115 st %g4, [%g5 + 0x18]
1116 st %g4, [%g5 + 0x1c]
1117 set flush_patch_switch, %g5
1118 st %g4, [%g5 + 0x18]
1119 st %g4, [%g5 + 0x1c]
1122 sethi %hi(nwindows), %g4
1123 st %g3, [%g4 + %lo(nwindows)] ! store final value
1125 sethi %hi(nwindowsm1), %g4
1126 st %g3, [%g4 + %lo(nwindowsm1)]
1128 /* Here we go, start using Linux's trap table... */
1133 /* Finally, turn on traps so that we can call c-code. */
1138 wr %g3, PSR_ET, %psr
1141 /* First we call prom_init() to set up PROMLIB, then
1142 * off to start_kernel().
1145 sethi %hi(prom_vector_p), %g5
1146 ld [%g5 + %lo(prom_vector_p)], %o0
1153 /* We should not get here. */
1159 /* There, happy now Adrian? */
1160 set cputypval, %o2 ! Let everyone know we
1161 set ' ', %o0 ! are a "sun4 " architecture
1162 stb %o0, [%o2 + 0x4]
1167 sethi %hi(SUN4_PROM_VECTOR+0x84), %o1
1168 ld [%o1 + %lo(SUN4_PROM_VECTOR+0x84)], %o1
1169 set sun4_notsup, %o0
1170 call %o1 /* printf */
1172 sethi %hi(SUN4_PROM_VECTOR+0xc4), %o1
1173 ld [%o1 + %lo(SUN4_PROM_VECTOR+0xc4)], %o1
1174 call %o1 /* exittomon */
1176 1: ba 1b ! Cannot exit into KMON
1180 ld [%g7 + 0x68], %o1
1181 set sun4e_notsup, %o0
1205 .asciz "\n\rOn sun4u you have to use UltraLinux (64bit) kernel\n\rand not a 32bit sun4[cdem] version\n\r\n\r"
1212 .word 0, sun4u_1, 0, 1, 0, 1, 0, sun4u_2, 0
1216 .word 0, sun4u_3, 0, 4, 0, 1, 0
1218 .word 0, 0, sun4u_4, 0, sun4u_1, 0, 8, 0
1222 .word 0, sun4u_5, 0, 3, 0, 1, 0
1224 .word 0, 0, sun4u_6, 0, sun4u_6e - sun4u_6 - 1, 0
1228 .word 0, sun4u_7, 0, 0, 0, 0
1241 mov sun4u_r4 - sun4u_a1, %l3
1257 ld [%l1 + (sun4u_r1 - sun4u_a1)], %o1
1258 add %l1, (sun4u_a2 - sun4u_a1), %o0
1260 st %o1, [%o0 + (sun4u_i2 - sun4u_a2)]
1262 ld [%l1 + (sun4u_1 - sun4u_a1)], %o1
1263 add %l1, (sun4u_a3 - sun4u_a1), %o0
1265 st %o1, [%o0 + (sun4u_i3 - sun4u_a3)]
1268 add %l1, (sun4u_a4 - sun4u_a1), %o0
1272 ld [%g7 + 0x74], %o0
1273 call %o0 ! Get us out of here...
1274 nop ! Apparently Solaris is better.
1276 /* Ok, now we continue in the .data/.text sections */
1282 * Fill up the prom vector, note in particular the kind first element,
1283 * no joke. I don't need all of them in here as the entire prom vector
1284 * gets initialized in c-code so all routines can use it.
1287 .globl prom_vector_p
1291 /* We calculate the following at boot time, window fills/spills and trap entry
1292 * code uses these to keep track of the register windows.
1303 /* Boot time debugger vector value. We need this later on. */
1321 .section ".fixup",#alloc,#execinstr
1325 restore %g0, -EFAULT, %o0