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