OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [sparc/] [kernel/] [head.S] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1624 jcastillo
/* $Id: head.S,v 1.1 2005-12-20 09:50:43 jcastillo Exp $
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 Peter Zaitcev   (Zaitcev@ipmce.su)
6
 */
7
 
8
#include 
9
#include 
10
 
11
#include 
12
#include 
13
#include 
14
#include 
15
#include 
16
#include 
17
#include 
18
#include 
19
#include 
20
 
21
        .data
22
/*
23
 * The following are used with the prom_vector node-ops to figure out
24
 * the cpu-type
25
 */
26
 
27
        .align 4
28
        .globl  C_LABEL(cputyp)
29
C_LABEL(cputyp):
30
        .word   1
31
 
32
        .align 4
33
        .globl C_LABEL(cputypval)
34
C_LABEL(cputypval):
35
        .asciz "sun4c"
36
        .ascii "     "
37
 
38
C_LABEL(cputypvalend):
39
C_LABEL(cputypvallen) = C_LABEL(cputypvar) - C_LABEL(cputypval)
40
 
41
        .align 4
42
/*
43
 * Sun people can't spell worth damn. "compatability" indeed.
44
 * At least we *know* we can't spell, and use a spell-checker.
45
 */
46
 
47
/* Uh, actually Linus it is I who cannot spell. Too much murky
48
 * Sparc assembly will do this to ya.
49
 */
50
C_LABEL(cputypvar):
51
        .asciz "compatability"
52
 
53
/* Tested on SS-5, SS-10. Probably someone at Sun applied a spell-checker. */
54
        .align 4
55
C_LABEL(cputypvar_sun4m):
56
        .asciz "compatible"
57
 
58
        .align 4
59
sun4_notsup:
60
        .asciz  "Sparc-Linux sun4 support not implemented yet\n\n"
61
        .align 4
62
 
63
sun4d_notsup:
64
        .asciz  "Sparc-Linux sun4d support does not exist\n\n"
65
        .align 4
66
 
67
sun4e_notsup:
68
        .asciz  "Sparc-Linux sun4e support does not exist\n\n"
69
        .align 4
70
 
71
sun4u_notsup:
72
        .asciz  "Sparc-Linux sun4u support does not exist\n\n"
73
        .align 4
74
 
75
        /* The Sparc trap table, bootloader gives us control at _start. */
76
        .text
77
        .globl  start, _stext, _start, __stext
78
        .globl  C_LABEL(trapbase)
79
_start:   /* danger danger */
80
__stext:
81
_stext:
82
start:
83
C_LABEL(trapbase):
84
#ifdef __SMP__
85
C_LABEL(trapbase_cpu0):
86
#endif
87
/* We get control passed to us here at t_zero. */
88
t_zero: b gokernel; nop; nop; nop;
89
t_tflt: SPARC_TFAULT                        /* Inst. Access Exception        */
90
t_bins: TRAP_ENTRY(0x2, bad_instruction)    /* Illegal Instruction           */
91
t_pins: TRAP_ENTRY(0x3, priv_instruction)   /* Privileged Instruction        */
92
t_fpd:  TRAP_ENTRY(0x4, fpd_trap_handler)   /* Floating Point Disabled       */
93
t_wovf: WINDOW_SPILL                        /* Window Overflow               */
94
t_wunf: WINDOW_FILL                         /* Window Underflow              */
95
t_mna:  TRAP_ENTRY(0x7, mna_handler)        /* Memory Address Not Aligned    */
96
t_fpe:  TRAP_ENTRY(0x8, fpe_trap_handler)   /* Floating Point Exception      */
97
t_dflt: SPARC_DFAULT                        /* Data Miss Exception           */
98
t_tio:  TRAP_ENTRY(0xa, do_tag_overflow)    /* Tagged Instruction Ovrflw     */
99
t_wpt:  TRAP_ENTRY(0xb, do_watchpoint)      /* Watchpoint Detected           */
100
t_badc: BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
101
t_irq1: TRAP_ENTRY_INTERRUPT(1)             /* IRQ Software/SBUS Level 1     */
102
t_irq2: TRAP_ENTRY_INTERRUPT(2)             /* IRQ SBUS Level 2              */
103
t_irq3: TRAP_ENTRY_INTERRUPT(3)             /* IRQ SCSI/DMA/SBUS Level 3     */
104
t_irq4: TRAP_ENTRY_INTERRUPT(4)             /* IRQ Software Level 4          */
105
t_irq5: TRAP_ENTRY_INTERRUPT(5)             /* IRQ SBUS/Ethernet Level 5     */
106
t_irq6: TRAP_ENTRY_INTERRUPT(6)             /* IRQ Software Level 6          */
107
t_irq7: TRAP_ENTRY_INTERRUPT(7)             /* IRQ Video/SBUS Level 5        */
108
t_irq8: TRAP_ENTRY_INTERRUPT(8)             /* IRQ SBUS Level 6              */
109
t_irq9: TRAP_ENTRY_INTERRUPT(9)             /* IRQ SBUS Level 7              */
110
t_irq10:TRAP_ENTRY_INTERRUPT(10)            /* IRQ Timer #1 (one we use)     */
111
t_irq11:TRAP_ENTRY_INTERRUPT(11)            /* IRQ Floppy Intr.              */
112
t_irq12:TRAP_ENTRY_INTERRUPT(12)            /* IRQ Zilog serial chip         */
113
t_irq13:TRAP_ENTRY_INTERRUPT(13)            /* IRQ Audio Intr.               */
114
t_irq14:TRAP_ENTRY_INTERRUPT(14)            /* IRQ Timer #2                  */
115
#ifndef __SMP__
116
t_nmi:  NMI_TRAP                            /* Level 15 (NMI)                */
117
#else
118
        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:TRAP_ENTRY(0x25, do_bad_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_sunos:SUNOS_SYSCALL_TRAP                  /* SunOS System Call             */
150
t_sbkpt:BAD_TRAP(0x81)                      /* Software Breakpoint/KGDB      */
151
t_divz: BAD_TRAP(0x82)                      /* 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_slowl:SOLARIS_SYSCALL_TRAP                /* Slowaris System Call          */
158
t_netbs:NETBSD_SYSCALL_TRAP                 /* 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_bada2:BAD_TRAP(0xa2) BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
168
t_bada7:BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
169
t_badac:BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
170
t_badb1:BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
171
t_badb6:BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
172
t_badbb:BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
173
t_badc0:BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
174
t_badc5:BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
175
t_badca:BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
176
t_badcf:BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
177
t_badd4:BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
178
t_badd9:BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
179
t_badde:BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
180
t_bade3:BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
181
t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
182
t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
183
t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
184
t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
185
t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd)
186
dbtrap: BAD_TRAP(0xfe)                      /* Debugger/PROM breakpoint #1   */
187
dbtrap2:BAD_TRAP(0xff)                      /* Debugger/PROM breakpoint #2   */
188
 
189
        .globl  C_LABEL(end_traptable)
190
C_LABEL(end_traptable):
191
 
192
#ifdef __SMP__
193
        /* Trap tables for the other cpus. */
194
        .globl  C_LABEL(trapbase_cpu1), C_LABEL(trapbase_cpu2), C_LABEL(trapbase_cpu3)
195
C_LABEL(trapbase_cpu1):
196
        BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
197
        TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
198
        WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
199
        TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
200
        TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
201
        BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
202
        TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
203
        TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
204
        TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
205
        TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
206
        TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
207
        TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
208
        TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
209
        TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
210
        TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
211
        BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) TRAP_ENTRY(0x25, do_bad_flush)
212
        BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
213
        SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
214
        BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
215
        BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
216
        BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
217
        BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
218
        BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
219
        BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
220
        BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
221
        BAD_TRAP(0x50)
222
        BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
223
        BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
224
        BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
225
        BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
226
        BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
227
        BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
228
        BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
229
        BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
230
        BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
231
        BAD_TRAP(0x7e) BAD_TRAP(0x7f)
232
        SUNOS_SYSCALL_TRAP BAD_TRAP(0x81) BAD_TRAP(0x82)
233
        TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
234
        BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
235
        NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
236
        BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
237
        LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
238
        BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
239
        BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
240
        BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP
241
        BAD_TRAP(0xa2) BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
242
        BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
243
        BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
244
        BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
245
        BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
246
        BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
247
        BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
248
        BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
249
        BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
250
        BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
251
        BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
252
        BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
253
        BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
254
        BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
255
        BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
256
        BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
257
        BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
258
        BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
259
        BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
260
 
261
C_LABEL(trapbase_cpu2):
262
        BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
263
        TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
264
        WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
265
        TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
266
        TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
267
        BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
268
        TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
269
        TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
270
        TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
271
        TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
272
        TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
273
        TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
274
        TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
275
        TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
276
        TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
277
        BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) TRAP_ENTRY(0x25, do_bad_flush)
278
        BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
279
        SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
280
        BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
281
        BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
282
        BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
283
        BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
284
        BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
285
        BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
286
        BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
287
        BAD_TRAP(0x50)
288
        BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
289
        BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
290
        BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
291
        BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
292
        BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
293
        BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
294
        BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
295
        BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
296
        BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
297
        BAD_TRAP(0x7e) BAD_TRAP(0x7f)
298
        SUNOS_SYSCALL_TRAP BAD_TRAP(0x81) BAD_TRAP(0x82)
299
        TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
300
        BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
301
        NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
302
        BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
303
        LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
304
        BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
305
        BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
306
        BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP
307
        BAD_TRAP(0xa2) BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
308
        BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
309
        BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
310
        BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
311
        BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
312
        BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
313
        BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
314
        BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
315
        BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
316
        BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
317
        BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
318
        BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
319
        BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
320
        BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
321
        BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
322
        BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
323
        BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
324
        BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
325
        BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
326
 
327
C_LABEL(trapbase_cpu3):
328
        BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
329
        TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
330
        WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
331
        TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
332
        TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
333
        BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
334
        TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
335
        TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
336
        TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
337
        TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
338
        TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
339
        TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
340
        TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
341
        TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
342
        TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
343
        BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) TRAP_ENTRY(0x25, do_bad_flush)
344
        BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
345
        SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
346
        BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
347
        BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
348
        BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
349
        BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
350
        BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
351
        BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
352
        BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
353
        BAD_TRAP(0x50)
354
        BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
355
        BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
356
        BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
357
        BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
358
        BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
359
        BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
360
        BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
361
        BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
362
        BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
363
        BAD_TRAP(0x7e) BAD_TRAP(0x7f)
364
        SUNOS_SYSCALL_TRAP BAD_TRAP(0x81) BAD_TRAP(0x82)
365
        TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
366
        BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
367
        NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
368
        BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
369
        LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
370
        BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
371
        BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
372
        BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP
373
        BAD_TRAP(0xa2) BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
374
        BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
375
        BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
376
        BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
377
        BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
378
        BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
379
        BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
380
        BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
381
        BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
382
        BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
383
        BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
384
        BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
385
        BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
386
        BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
387
        BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
388
        BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
389
        BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
390
        BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
391
        BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
392
 
393
        .globl  C_LABEL(cpu0_stack), C_LABEL(cpu1_stack), C_LABEL(cpu2_stack)
394
        .globl  C_LABEL(cpu3_stack)
395
C_LABEL(cpu0_stack):                    .skip 0x2000
396
C_LABEL(cpu1_stack):                    .skip 0x2000
397
C_LABEL(cpu2_stack):                    .skip 0x2000
398
C_LABEL(cpu3_stack):                    .skip 0x2000
399
#endif
400
        .skip 4096
401
 
402
/* This was the only reasonable way I could think of to properly align
403
 * these page-table data structures.
404
 */
405
        .globl C_LABEL(bootup_user_stack)
406
        .globl C_LABEL(bootup_kernel_stack)
407
        .globl C_LABEL(pg0)
408
        .globl C_LABEL(empty_bad_page)
409
        .globl C_LABEL(empty_bad_page_table)
410
        .globl C_LABEL(empty_zero_page)
411
        .globl C_LABEL(swapper_pg_dir)
412
C_LABEL(bootup_user_stack):             .skip 0x2000
413
C_LABEL(bootup_kernel_stack):           .skip 0x2000
414
C_LABEL(swapper_pg_dir):                .skip 0x1000
415
C_LABEL(pg0):                           .skip 0x1000
416
C_LABEL(empty_bad_page):                .skip 0x1000
417
C_LABEL(empty_bad_page_table):          .skip 0x1000
418
C_LABEL(empty_zero_page):               .skip 0x1000
419
 
420
 
421
/* Cool, here we go. Pick up the romvec pointer in %o0 and stash it in
422
 * %g7 and at prom_vector_p. And also quickly check whether we are on
423
 * a v0, v2, or v3 prom.
424
 */
425
gokernel:
426
                /* Ok, it's nice to know, as early as possible, if we
427
                 * are already mapped where we expect to be in virtual
428
                 * memory.  The Solaris /boot elf format bootloader
429
                 * will peek into our elf header and load us where
430
                 * we want to be, otherwise we have to re-map.
431
                 *
432
                 * Some boot loaders don't place the jmp'rs address
433
                 * in %o7, so we do a pc-relative call to a local
434
                 * label, then see what %o7 has.
435
                 */
436
 
437
                mov     %o7, %g4                ! Save %o7
438
 
439
                /* Jump to it, and pray... */
440
current_pc:
441
                call    1f
442
                 nop
443
 
444
1:
445
                mov     %o7, %g3
446
 
447
got_pc:
448
                mov     %g4, %o7                /* Previous %o7. */
449
 
450
                mov     %o0, %l0                ! stash away romvec
451
                mov     %o0, %g7                ! put it here too
452
                mov     %o1, %l1                ! stash away debug_vec too
453
 
454
                /* Ok, let's check out our run time program counter. */
455
                set     current_pc, %g5
456
                cmp     %g3, %g5
457
                be      already_mapped
458
                 nop
459
 
460
                /* %l6 will hold the offset we have to subtract
461
                 * from absolute symbols in order to access areas
462
                 * in our own image.  If already mapped this is
463
                 * just plain zero, else it is PAGE_OFFSET which is
464
                 * also KERNBASE.
465
                 */
466
                set     PAGE_OFFSET, %l6
467
                b       copy_prom_lvl14
468
                 nop
469
 
470
already_mapped:
471
                mov     0, %l6
472
 
473
                /* Copy over the Prom's level 14 clock handler. */
474
copy_prom_lvl14:
475
#if 1
476
                /* DJHR
477
                 * preserve our linked/calculated instructions
478
                 */
479
                set     C_LABEL(lvl14_save), %g1
480
                set     t_irq14, %g3
481
                sub     %g1, %l6, %g1           ! translate to physical
482
                sub     %g3, %l6, %g3           ! translate to physical
483
                ldd     [%g3], %g4
484
                std     %g4, [%g1]
485
                ldd     [%g3+8], %g4
486
                std     %g4, [%g1+8]
487
#endif
488
                rd      %tbr, %g1
489
                andn    %g1, 0xfff, %g1         ! proms trap table base
490
                or      %g0, (0x1e<<4), %g2     ! offset to lvl14 intr
491
                or      %g1, %g2, %g2
492
                set     t_irq14, %g3
493
                sub     %g3, %l6, %g3
494
                ldd     [%g2], %g4
495
                std     %g4, [%g3]
496
                ldd     [%g2 + 0x8], %g4
497
                std     %g4, [%g3 + 0x8]        ! Copy proms handler
498
 
499
/* Must determine whether we are on a sun4c MMU, SRMMU, or SUN4/400 MUTANT
500
 * MMU so we can remap ourselves properly.  DON'T TOUCH %l0 thru %l5 in these
501
 * remapping routines, we need their values afterwards!
502
 */
503
                /* Now check whether we are already mapped, if we
504
                 * are we can skip all this garbage coming up.
505
                 */
506
copy_prom_done:
507
                cmp     %l6, 0
508
                be      go_to_highmem           ! this will be a nop then
509
                 nop
510
 
511
                set     LOAD_ADDR, %g6
512
                cmp     %g7, %g6
513
                bne     remap_not_a_sun4        ! This is not a Sun4
514
                 nop
515
 
516
                or      %g0, 0x1, %g1
517
                lduba   [%g1] ASI_CONTROL, %g1  ! Only safe to try on Sun4.
518
                subcc   %g1, 0x24, %g0          ! Is this a mutant Sun4/400???
519
                be      sun4_mutant_remap       ! Ugh, it is...
520
                 nop
521
 
522
remap_not_a_sun4:
523
                lda     [%g0] ASI_M_MMUREGS, %g1 ! same as ASI_PTE on sun4c
524
                and     %g1, 0x1, %g1           ! Test SRMMU Enable bit ;-)
525
                cmp     %g1, 0x0
526
                be      sun4c_remap             ! A sun4c MMU or normal Sun4
527
                 nop
528
srmmu_remap:
529
                /* First, check for a viking (TI) module. */
530
                set     0x40000000, %g2
531
                rd      %psr, %g3
532
                and     %g2, %g3, %g3
533
                subcc   %g3, 0x0, %g0
534
                bz      srmmu_nviking
535
                 nop
536
 
537
                /* Figure out what kind of viking we are on.
538
                 * We need to know if we have to play with the
539
                 * AC bit and disable traps or not.
540
                 */
541
 
542
                /* I've only seen MicroSparc's on SparcClassics with this
543
                 * bit set.
544
                 */
545
                set     0x800, %g2
546
                lda     [%g0] ASI_M_MMUREGS, %g3        ! peek in the control reg
547
                and     %g2, %g3, %g3
548
                subcc   %g3, 0x0, %g0
549
                bnz     srmmu_nviking                   ! is in mbus mode
550
                 nop
551
 
552
                rd      %psr, %g3                       ! DO NOT TOUCH %g3
553
                andn    %g3, PSR_ET, %g2
554
                wr      %g2, 0x0, %psr
555
                WRITE_PAUSE
556
 
557
                /* Get context table pointer, then convert to
558
                 * a physical address, which is 36 bits.
559
                 */
560
                set     AC_M_CTPR, %g4
561
                lda     [%g4] ASI_M_MMUREGS, %g4
562
                sll     %g4, 0x4, %g4                   ! We use this below
563
                                                        ! DO NOT TOUCH %g4
564
 
565
                /* Set the AC bit in the Viking's MMU control reg. */
566
                lda     [%g0] ASI_M_MMUREGS, %g5        ! DO NOT TOUCH %g5
567
                set     0x8000, %g6                     ! AC bit mask
568
                or      %g5, %g6, %g6                   ! Or it in...
569
                sta     %g6, [%g0] ASI_M_MMUREGS        ! Close your eyes...
570
 
571
                /* Grrr, why does it seem like every other load/store
572
                 * on the sun4m is in some ASI space...
573
                 * Fine with me, let's get the pointer to the level 1
574
                 * page table directory and fetch its entry.
575
                 */
576
                lda     [%g4] ASI_M_BYPASS, %o1         ! This is a level 1 ptr
577
                srl     %o1, 0x4, %o1                   ! Clear low 4 bits
578
                sll     %o1, 0x8, %o1                   ! Make physical
579
 
580
                /* Ok, pull in the PTD. */
581
                lda     [%o1] ASI_M_BYPASS, %o2         ! This is the 0x0 16MB pgd
582
 
583
                /* Calculate to KERNBASE entry.
584
                 *
585
                 * XXX Should not use empirical constant, but Gas gets an  XXX
586
                 * XXX upset stomach with the bitshift I would have to use XXX
587
                 */
588
                add     %o1, 0x3c0, %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, 0x3c0, %g3                 ! XXX AWAY WITH EMPIRICALS
633
                sta     %g2, [%g3] ASI_M_BYPASS         ! place at KERNBASE entry
634
                b       go_to_highmem
635
                 nop                                    ! wheee....
636
 
637
                /* This remaps the kernel on Sun4/4xx machines
638
                 * that have the Sun Mutant Three Level MMU.
639
                 * It's like a platypus, Sun didn't have the
640
                 * SRMMU in conception so they kludged the three
641
                 * level logic in the regular Sun4 MMU probably.
642
                 *
643
                 * Basically, you take each entry in the top level
644
                 * directory that maps the low 3MB starting at
645
                 * address zero and put the mapping in the KERNBASE
646
                 * slots.  These top level pgd's are called regmaps.
647
                 */
648
sun4_mutant_remap:
649
                or      %g0, %g0, %g3           ! source base
650
                sethi   %hi(KERNBASE), %g4      ! destination base
651
                or      %g4, %lo(KERNBASE), %g4
652
                sethi   %hi(0x300000), %g5
653
                or      %g5, %lo(0x300000), %g5 ! upper bound 3MB
654
                or      %g0, 0x1, %l6
655
                sll     %l6, 24, %l6            ! Regmap mapping size
656
                add     %g3, 0x2, %g3           ! Base magic
657
                add     %g4, 0x2, %g4           ! Base magic
658
 
659
                /* Main remapping loop on Sun4-Mutant-MMU.
660
                 * "I am not an animal..." -Famous Mutant Person
661
                 */
662
sun4_mutant_loop:
663
                lduha   [%g3] ASI_REGMAP, %g2   ! Get lower entry
664
                stha    %g2, [%g4] ASI_REGMAP   ! Store in high entry
665
                add     %g4, %l6, %g4           ! Move up high memory ptr
666
                subcc   %g3, %g5, %g0           ! Reached our limit?
667
                blu     sun4_mutant_loop        ! Nope, loop again
668
                 add    %g3, %l6, %g3           ! delay, Move up low ptr
669
                b       go_to_highmem           ! Jump to high memory.
670
                 nop
671
 
672
/* The following works for normal (ie. non Sun4/400) Sun4 MMU's */
673
sun4c_remap:
674
                mov     0, %g3                  ! source base
675
                set     KERNBASE, %g4           ! destination base
676
                set     0x300000, %g5           ! upper bound 3MB
677
                mov     1, %l6
678
                sll     %l6, 18, %l6            ! sun4c mmu segmap size
679
sun4c_remap_loop:
680
                lda     [%g3] ASI_SEGMAP, %g6   ! load phys_seg
681
                sta     %g6, [%g4] ASI_SEGMAP   ! store new virt mapping
682
                add     %g3, %l6, %g3           ! Increment source ptr
683
                subcc   %g3, %g5, %g0           ! Reached limit?
684
                bl      sun4c_remap_loop        ! Nope, loop again
685
                 add    %g4, %l6, %g4           ! delay, Increment dest ptr
686
 
687
/* Now do a non-relative jump so that PC is in high-memory */
688
go_to_highmem:
689
                set     execute_in_high_mem, %g1
690
                jmpl    %g1, %g0
691
                 nop
692
 
693
/* Acquire boot time privileged register values, this will help debugging.
694
 * I figure out and store nwindows and nwindowsm1 later on.
695
 */
696
execute_in_high_mem:
697
#if CONFIG_AP1000
698
                /* we don't have a prom :-( */
699
                b sun4m_init
700
                nop
701
#endif
702
                mov     %l0, %o0                ! put back romvec
703
                mov     %l1, %o1                ! and debug_vec
704
 
705
                sethi   %hi( C_LABEL(prom_vector_p) ), %g1
706
                st      %o0, [%g1 + %lo( C_LABEL(prom_vector_p) )]
707
 
708
                sethi   %hi( C_LABEL(linux_dbvec) ), %g1
709
                st      %o1, [%g1 + %lo( C_LABEL(linux_dbvec) )]
710
 
711
                ld      [%o0 + 0x4], %o3
712
                and     %o3, 0x3, %o5                   ! get the version
713
 
714
                cmp     %o3, 0x2                        ! a v2 prom?
715
                be      found_version
716
                 nop
717
 
718
                /* paul@sfe.com.au */
719
                cmp     %o3, 0x3                        ! a v3 prom?
720
                be      found_version
721
                 nop
722
 
723
/* Old sun4's pass our load address into %o0 instead of the prom
724
 * pointer. On sun4's you have to hard code the romvec pointer into
725
 * your code. Sun probably still does that because they don't even
726
 * trust their own "OpenBoot" specifications.
727
 */
728
 
729
                set     LOAD_ADDR, %g6
730
                cmp     %o0, %g6                ! an old sun4?
731
                be      no_sun4_here
732
                 nop
733
 
734
found_version:
735
 
736
/* Get the machine type via the mysterious romvec node operations. */
737
 
738
                or      %g0, %g7, %l1
739
                add     %l1, 0x1c, %l1
740
                ld      [%l1], %l0
741
                ld      [%l0], %l0
742
                call    %l0
743
                 or     %g0, %g0, %o0           ! next_node(0) = first_node
744
                or      %o0, %g0, %g6
745
 
746
                sethi   %hi( C_LABEL(cputypvar) ), %o1  ! First node has cpu-arch
747
                or      %o1, %lo( C_LABEL(cputypvar) ), %o1
748
                sethi   %hi( C_LABEL(cputypval) ), %o2  ! information, the string
749
                or      %o2, %lo( C_LABEL(cputypval) ), %o2
750
                ld      [%l1], %l0              ! 'compatibility' tells
751
                ld      [%l0 + 0xc], %l0        ! that we want 'sun4x' where
752
                call    %l0                     ! x is one of '', 'c', 'm',
753
                 nop                            ! 'd' or 'e'. %o2 holds pointer
754
                                                ! to a buf where above string
755
                                                ! will get stored by the prom.
756
 
757
                subcc   %o0, %g0, %g0
758
                bpos    got_prop                ! Got the property
759
                 nop
760
 
761
                or      %g6, %g0, %o0
762
                sethi   %hi( C_LABEL(cputypvar_sun4m) ), %o1
763
                or      %o1, %lo( C_LABEL(cputypvar_sun4m) ), %o1
764
                sethi   %hi( C_LABEL(cputypval) ), %o2
765
                or      %o2, %lo( C_LABEL(cputypval) ), %o2
766
                ld      [%l1], %l0
767
                ld      [%l0 + 0xc], %l0
768
                call    %l0
769
                 nop
770
 
771
got_prop:
772
                set     C_LABEL(cputypval), %o2
773
                ldub    [%o2 + 0x4], %l1
774
 
775
                cmp     %l1, 'c'                ! We already know we are not
776
                be      1f                      ! on a plain sun4 because of
777
                 nop                            ! the check for 0x4000 in %o0
778
 
779
                cmp     %l1, 'm'                ! at start
780
                be      1f
781
                 nop
782
 
783
                cmp     %l1, 'd'
784
                be      no_sun4d_here           ! God bless the person who
785
                 nop                            ! tried to run this on sun4d.
786
 
787
                cmp     %l1, 'e'
788
                be      no_sun4e_here           ! Could be a sun4e.
789
                 nop
790
 
791
                b       no_sun4u_here           ! AIEEE, a V9 sun4u...
792
                 nop
793
 
794
 
795
1:
796
                set     C_LABEL(cputypval), %l1
797
                ldub    [%l1 + 0x4], %l1
798
                cmp     %l1, 'm'                ! Test for sun4d, sun4e ?
799
                be      sun4m_init
800
                 nop
801
 
802
                /* Jump into mmu context zero. */
803
                set     AC_CONTEXT, %g1
804
                stba    %g0, [%g1] ASI_CONTROL
805
 
806
                b       sun4c_continue_boot
807
                 nop
808
 
809
sun4m_init:
810
 
811
/* Ok, the PROM could have done funny things and apple cider could still
812
 * be sitting in the fault status/address registers.  Read them all to
813
 * clear them so we don't get magic faults later on.
814
 */
815
/* This sucks, apparently this makes Vikings call prom panic, will fix later */
816
 
817
                rd      %psr, %o1
818
                srl     %o1, 28, %o1            ! Get a type of the CPU
819
 
820
                subcc   %o1, 4, %g0             ! TI: Viking or MicroSPARC
821
                be      sun4c_continue_boot
822
                 nop
823
 
824
                set     AC_M_SFSR, %o0
825
                lda     [%o0] ASI_M_MMUREGS, %g0
826
                set     AC_M_SFAR, %o0
827
                lda     [%o0] ASI_M_MMUREGS, %g0
828
 
829
                /* Fujitsu MicroSPARC-II has no asynchronous flavors of FARs */
830
                subcc   %o1, 0, %g0
831
                be      sun4c_continue_boot
832
                 nop
833
 
834
                set     AC_M_AFSR, %o0
835
                lda     [%o0] ASI_M_MMUREGS, %g0
836
                set     AC_M_AFAR, %o0
837
                lda     [%o0] ASI_M_MMUREGS, %g0
838
                 nop
839
 
840
 
841
sun4c_continue_boot:
842
 
843
 
844
/* Aieee, now set PC and nPC, enable traps, give ourselves a stack and it's
845
 * show-time!
846
 */
847
 
848
                sethi   %hi( C_LABEL(cputyp) ), %o0
849
                st      %g4, [%o0 + %lo( C_LABEL(cputyp) )]
850
 
851
                /* Turn on Supervisor, EnableFloating, and all the PIL bits.
852
                 * Also puts us in register window zero with traps off.
853
                 */
854
                set     (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
855
                wr      %g2, 0x0, %psr
856
                WRITE_PAUSE
857
 
858
                /* I want a kernel stack NOW! */
859
                set     C_LABEL(bootup_user_stack), %g1
860
                add     %g1, (PAGE_SIZE - REGWIN_SZ), %sp
861
                mov     0, %fp                  /* And for good luck */
862
 
863
                /* Zero out our BSS section. */
864
                set     C_LABEL(edata) , %o0    ! First address of BSS
865
                set     C_LABEL(end) , %o1      ! Last address of BSS
866
                add     %o0, 0x1, %o0
867
1:
868
                stb     %g0, [%o0]
869
                subcc   %o0, %o1, %g0
870
                bl      1b
871
                 add    %o0, 0x1, %o0
872
 
873
                /* Initialize the umask value for init_task just in case.
874
                 * But first make current_set[0] point to something useful.
875
                 */
876
                set     C_LABEL(init_task), %g4
877
                set     C_LABEL(current_set), %g2
878
                st      %g4, [%g2]
879
 
880
                set     C_LABEL(bootup_kernel_stack), %g3
881
                st      %g3, [%g4 + TASK_KSTACK_PG]
882
                st      %g0, [%g4 + THREAD_UMASK]
883
 
884
/* Compute NWINDOWS and stash it away. Now uses %wim trick explained
885
 * in the V8 manual. Ok, this method seems to work, Sparc is cool...
886
 * No, it doesn't work, have to play the save/readCWP/restore trick.
887
 */
888
 
889
                wr      %g0, 0x0, %wim                  ! so we do not get a trap
890
                WRITE_PAUSE
891
 
892
                save
893
 
894
                rd      %psr, %g3
895
 
896
                restore
897
 
898
                and     %g3, 0x1f, %g3
899
                add     %g3, 0x1, %g3
900
 
901
                mov     2, %g1
902
                wr      %g1, 0x0, %wim                  ! make window 1 invalid
903
                WRITE_PAUSE
904
 
905
                cmp     %g3, 0x7
906
                bne     2f
907
                 nop
908
 
909
                /* Adjust our window handling routines to
910
                 * do things correctly on 7 window Sparcs.
911
                 */
912
 
913
#define         PATCH_INSN(src, dest) \
914
                set     src, %g5; \
915
                set     dest, %g6; \
916
                ld      [%g5], %g4; \
917
                st      %g4, [%g6];
918
 
919
                /* Patch for window spills... */
920
                PATCH_INSN(spnwin_patch1_7win, spnwin_patch1)
921
                PATCH_INSN(spnwin_patch2_7win, spnwin_patch2)
922
                PATCH_INSN(spnwin_patch3_7win, spnwin_patch3)
923
 
924
                /* Patch for window fills... */
925
                PATCH_INSN(fnwin_patch1_7win, fnwin_patch1)
926
                PATCH_INSN(fnwin_patch2_7win, fnwin_patch2)
927
 
928
                /* Patch for trap entry setup... */
929
                PATCH_INSN(tsetup_7win_patch1, tsetup_patch1)
930
                PATCH_INSN(tsetup_7win_patch2, tsetup_patch2)
931
                PATCH_INSN(tsetup_7win_patch3, tsetup_patch3)
932
                PATCH_INSN(tsetup_7win_patch4, tsetup_patch4)
933
                PATCH_INSN(tsetup_7win_patch5, tsetup_patch5)
934
                PATCH_INSN(tsetup_7win_patch6, tsetup_patch6)
935
 
936
                /* Patch for returning from traps... */
937
                PATCH_INSN(rtrap_7win_patch1, rtrap_patch1)
938
                PATCH_INSN(rtrap_7win_patch2, rtrap_patch2)
939
                PATCH_INSN(rtrap_7win_patch3, rtrap_patch3)
940
                PATCH_INSN(rtrap_7win_patch4, rtrap_patch4)
941
                PATCH_INSN(rtrap_7win_patch5, rtrap_patch5)
942
 
943
#ifdef __SMP__
944
 
945
                /* Patch for returning from an ipi... */
946
                PATCH_INSN(rirq_7win_patch1, rirq_patch1)
947
                PATCH_INSN(rirq_7win_patch2, rirq_patch2)
948
                PATCH_INSN(rirq_7win_patch3, rirq_patch3)
949
                PATCH_INSN(rirq_7win_patch4, rirq_patch4)
950
                PATCH_INSN(rirq_7win_patch5, rirq_patch5)
951
 
952
#endif
953
 
954
2:
955
                sethi   %hi( C_LABEL(nwindows) ), %g4
956
                st      %g3, [%g4 + %lo( C_LABEL(nwindows) )]   ! store final value
957
                sub     %g3, 0x1, %g3
958
                sethi   %hi( C_LABEL(nwindowsm1) ), %g4
959
                st      %g3, [%g4 + %lo( C_LABEL(nwindowsm1) )]
960
 
961
                /* Here we go, start using Linux's trap table... */
962
                set     C_LABEL(trapbase), %g3
963
                wr      %g3, 0x0, %tbr
964
                WRITE_PAUSE
965
 
966
                /* Finally, turn on traps so that we can call c-code. */
967
                rd      %psr, %g3
968
                wr      %g3, 0x0, %psr
969
                WRITE_PAUSE
970
 
971
                wr      %g3, PSR_ET, %psr
972
                WRITE_PAUSE
973
 
974
                /* First we call prom_init() to set up PROMLIB, then
975
                 * off to start_kernel().
976
                 */
977
 
978
                sethi   %hi( C_LABEL(prom_vector_p) ), %g5
979
                ld      [%g5 + %lo( C_LABEL(prom_vector_p) )], %o0
980
                call    C_LABEL(prom_init)
981
                 nop
982
 
983
                call    C_LABEL(start_kernel)
984
                 nop
985
 
986
                /* We should not get here. */
987
                call    halt_me
988
                 nop
989
 
990
/* There, happy now Adrian? */
991
 
992
                /* XXX Fix this... XXX */
993
no_sun4_here:
994
                sethi   %hi(SUN4_PROM_VECTOR+SUN4_PRINTF), %o1
995
                ld      [%o1 + %lo(SUN4_PROM_VECTOR+SUN4_PRINTF)], %o1
996
                set     sun4_notsup, %o0
997
                call    %o1
998
                 nop
999
1:
1000
                ba      1b                      ! Cannot exit into KMON
1001
                 nop
1002
 
1003
no_sun4d_here:
1004
                ld      [%g7 + 0x68], %o1
1005
                set     sun4d_notsup, %o0
1006
                call    %o1
1007
                 nop
1008
                b       halt_me
1009
                 nop
1010
 
1011
no_sun4e_here:
1012
                ld      [%g7 + 0x68], %o1
1013
                set     sun4e_notsup, %o0
1014
                call    %o1
1015
                 nop
1016
                b       halt_me
1017
                 nop
1018
 
1019
no_sun4u_here:
1020
                ld      [%g7 + 0x68], %o1
1021
                set     sun4u_notsup, %o0
1022
                call    %o1
1023
                 nop
1024
                b       halt_me
1025
                 nop
1026
 
1027
halt_me:
1028
                ld      [%g7 + 0x74], %o0
1029
                call    %o0                     ! Get us out of here...
1030
                 nop                            ! Apparently Solaris is better.
1031
 
1032
        .data
1033
        .align 4
1034
 
1035
/*
1036
 * Fill up the prom vector, note in particular the kind first element,
1037
 * no joke. I don't need all of them in here as the entire prom vector
1038
 * gets initialized in c-code so all routines can use it.
1039
 */
1040
 
1041
        .globl  C_LABEL(prom_vector_p)
1042
C_LABEL(prom_vector_p):
1043
                .word 0
1044
 
1045
/* We calculate the following at boot time, window fills/spills and trap entry
1046
 * code uses these to keep track of the register windows.
1047
 */
1048
 
1049
        .align 4
1050
        .globl  C_LABEL(nwindows)
1051
        .globl  C_LABEL(nwindowsm1)
1052
C_LABEL(nwindows):
1053
        .word   8
1054
C_LABEL(nwindowsm1):
1055
        .word   7
1056
 
1057
/* Boot time debugger vector value.  We need this later on. */
1058
 
1059
        .align 4
1060
        .globl  C_LABEL(linux_dbvec)
1061
C_LABEL(linux_dbvec):
1062
        .word   0
1063
        .word   0
1064
 
1065
        .align 8
1066
 
1067
        .globl  C_LABEL(lvl14_save)
1068
C_LABEL(lvl14_save):
1069
        .word   0
1070
        .word   0
1071
        .word   0
1072
        .word   0
1073
        .word   t_irq14
1074
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.