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