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