This source file includes following definitions.
- syscall_trace_entry
- syscall_trace_exit
- do_cwp_assertion_failure
- do_hw_interrupt
- do_illegal_instruction
- do_priv_instruction
- do_memaccess_unaligned
- do_fpd_trap
- do_fpe_trap
- handle_tag_overflow
- handle_watchpoint
- handle_reg_access
- handle_cp_disabled
- handle_bad_flush
- handle_cp_exception
- handle_hw_divzero
- do_ast
- trap_init
- die_if_kernel
1
2
3
4
5
6
7
8
9
10
11 #include <linux/sched.h>
12 #include <linux/kernel.h>
13
14 #include <asm/delay.h>
15 #include <asm/system.h>
16 #include <asm/ptrace.h>
17 #include <asm/oplib.h>
18 #include <asm/page.h>
19 #include <asm/pgtable.h>
20 #include <asm/mp.h>
21 #include <asm/kdebug.h>
22
23 void
24 syscall_trace_entry(struct pt_regs *regs)
25 {
26 printk("%s[%d]: sys[%d](%d, %d, %d, %d) ",
27 current->comm, current->pid,
28 regs->u_regs[UREG_G1], regs->u_regs[UREG_I0],
29 regs->u_regs[UREG_I1], regs->u_regs[UREG_I2],
30 regs->u_regs[UREG_I3]);
31 return;
32 }
33
34 void
35 syscall_trace_exit(struct pt_regs *regs)
36 {
37 printk("retvals[%d,%d] at pc<%08lx>\n",
38 regs->u_regs[UREG_I0], regs->u_regs[UREG_I1],
39 regs->pc, regs->npc);
40 return;
41 }
42
43 void
44 do_cwp_assertion_failure(struct pt_regs *regs, unsigned long psr)
45 {
46 printk("CWP return from trap assertion fails:\n");
47 printk("Current psr %08lx, new psr %08lx\n", psr, regs->psr);
48 show_regs(regs);
49 panic("bogus CWP");
50 }
51
52 void
53 do_hw_interrupt(unsigned long type, unsigned long psr, unsigned long pc)
54 {
55
56 printk("Unimplemented Sparc TRAP, type = %02lx psr = %08lx pc = %08lx\n",
57 type, psr, pc);
58 halt();
59
60 return;
61 }
62
63 void
64 do_illegal_instruction(struct pt_regs *regs, unsigned long pc, unsigned long npc,
65 unsigned long psr)
66 {
67 printk("Illegal instruction at PC %08lx NPC %08lx PSR %08lx\n",
68 pc, npc, psr);
69 if(psr & PSR_PS)
70 panic("Kernel illegal instruction, how are ya!");
71 current->tss.sig_address = pc;
72 current->tss.sig_desc = SUBSIG_ILLINST;
73 send_sig(SIGILL, current, 1);
74 return;
75 }
76
77 void
78 do_priv_instruction(struct pt_regs *regs, unsigned long pc, unsigned long npc,
79 unsigned long psr)
80 {
81 printk("Privileged instruction at PC %08lx NPC %08lx PSR %08lx\n",
82 pc, npc, psr);
83 current->tss.sig_address = pc;
84 current->tss.sig_desc = SUBSIG_PRIVINST;
85 send_sig(SIGILL, current, 1);
86 return;
87 }
88
89
90
91 void
92 do_memaccess_unaligned(struct pt_regs *regs, unsigned long pc, unsigned long npc,
93 unsigned long psr)
94 {
95 printk("Unaligned memory access at PC %08lx NPC %08lx PSR %08lx\n",
96 pc, npc, psr);
97 if(regs->psr & PSR_PS)
98 panic("Kernel does unaligned memory access, yuck!");
99 current->tss.sig_address = pc;
100 current->tss.sig_desc = SUBSIG_PRIVINST;
101 send_sig(SIGBUS, current, 1);
102 return;
103 }
104
105 void
106 do_fpd_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc,
107 unsigned long psr)
108 {
109
110 if(psr & PSR_PS)
111 panic("FPE disabled trap from kernel, die die die...");
112
113 put_psr(get_psr() | PSR_EF);
114 if(last_task_used_math == current) {
115
116 regs->psr |= PSR_EF;
117 return;
118 }
119 if(last_task_used_math) {
120
121 __asm__ __volatile__("st %%fsr, [%0]\n\t" : :
122 "r" (¤t->tss.fsr) : "memory");
123
124
125 if(current->tss.fsr & 0x2000)
126 __asm__ __volatile__("mov 0x0, %%g2\n\t"
127 "1: std %%fq, [%2 + %%g2]\n\t"
128 "st %%fsr, [%0]\n\t"
129 "ld [%0], %%g3\n\t"
130 "andcc %%g3, %1, %%g0\n\t"
131 "bne 1b\n\t"
132 "add %%g2, 0x8, %%g2\n\t"
133 "srl %%g2, 0x3, %%g2\n\t"
134 "st %%g2, [%3]\n\t" : :
135 "r" (¤t->tss.fsr), "r" (0x2000),
136 "r" (¤t->tss.fpqueue[0]),
137 "r" (¤t->tss.fpqdepth) :
138 "g2", "g3", "memory");
139 else
140 current->tss.fpqdepth = 0;
141
142 __asm__ __volatile__("std %%f0, [%0 + 0x00]\n\t"
143 "std %%f2, [%0 + 0x08]\n\t"
144 "std %%f4, [%0 + 0x10]\n\t"
145 "std %%f6, [%0 + 0x18]\n\t"
146 "std %%f8, [%0 + 0x20]\n\t"
147 "std %%f10, [%0 + 0x28]\n\t"
148 "std %%f12, [%0 + 0x30]\n\t"
149 "std %%f14, [%0 + 0x38]\n\t"
150 "std %%f16, [%0 + 0x40]\n\t"
151 "std %%f18, [%0 + 0x48]\n\t"
152 "std %%f20, [%0 + 0x50]\n\t"
153 "std %%f22, [%0 + 0x58]\n\t"
154 "std %%f24, [%0 + 0x60]\n\t"
155 "std %%f26, [%0 + 0x68]\n\t"
156 "std %%f28, [%0 + 0x70]\n\t"
157 "std %%f30, [%0 + 0x78]\n\t" : :
158 "r" (¤t->tss.float_regs[0]) :
159 "memory");
160 }
161 last_task_used_math = current;
162 if(current->used_math) {
163
164 __asm__ __volatile__("ldd [%0 + 0x00], %%f0\n\t"
165 "ldd [%0 + 0x08], %%f2\n\t"
166 "ldd [%0 + 0x10], %%f4\n\t"
167 "ldd [%0 + 0x18], %%f6\n\t"
168 "ldd [%0 + 0x20], %%f8\n\t"
169 "ldd [%0 + 0x28], %%f10\n\t"
170 "ldd [%0 + 0x30], %%f12\n\t"
171 "ldd [%0 + 0x38], %%f14\n\t"
172 "ldd [%0 + 0x40], %%f16\n\t"
173 "ldd [%0 + 0x48], %%f18\n\t"
174 "ldd [%0 + 0x50], %%f20\n\t"
175 "ldd [%0 + 0x58], %%f22\n\t"
176 "ldd [%0 + 0x60], %%f24\n\t"
177 "ldd [%0 + 0x68], %%f26\n\t"
178 "ldd [%0 + 0x70], %%f28\n\t"
179 "ldd [%0 + 0x78], %%f30\n\t"
180 "ld [%1], %%fsr\n\t" : :
181 "r" (¤t->tss.float_regs[0]),
182 "r" (¤t->tss.fsr));
183 } else {
184
185 auto unsigned long init_fsr = 0x0UL;
186 auto unsigned long init_fregs[32] __attribute__ ((aligned (8))) =
187 { ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL,
188 ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL,
189 ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL,
190 ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL, ~0UL };
191 __asm__ __volatile__("ldd [%0 + 0x00], %%f0\n\t"
192 "ldd [%0 + 0x08], %%f2\n\t"
193 "ldd [%0 + 0x10], %%f4\n\t"
194 "ldd [%0 + 0x18], %%f6\n\t"
195 "ldd [%0 + 0x20], %%f8\n\t"
196 "ldd [%0 + 0x28], %%f10\n\t"
197 "ldd [%0 + 0x30], %%f12\n\t"
198 "ldd [%0 + 0x38], %%f14\n\t"
199 "ldd [%0 + 0x40], %%f16\n\t"
200 "ldd [%0 + 0x48], %%f18\n\t"
201 "ldd [%0 + 0x50], %%f20\n\t"
202 "ldd [%0 + 0x58], %%f22\n\t"
203 "ldd [%0 + 0x60], %%f24\n\t"
204 "ldd [%0 + 0x68], %%f26\n\t"
205 "ldd [%0 + 0x70], %%f28\n\t"
206 "ldd [%0 + 0x78], %%f30\n\t"
207 "ld [%1], %%fsr\n\t" : :
208 "r" (&init_fregs[0]),
209 "r" (&init_fsr) : "memory");
210 current->used_math = 1;
211 }
212 }
213
214 void
215 do_fpe_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc,
216 unsigned long psr)
217 {
218 if(psr & PSR_PS)
219 panic("FPE exception trap from kernel, die die die...");
220
221 regs->psr &= ~PSR_EF;
222 last_task_used_math = (struct task_struct *) 0;
223 current->tss.sig_address = pc;
224 current->tss.sig_desc = SUBSIG_FPERROR;
225 send_sig(SIGFPE, current, 1);
226 return;
227 }
228
229 void
230 handle_tag_overflow(struct pt_regs *regs, unsigned long pc, unsigned long npc,
231 unsigned long psr)
232 {
233 printk("Tag overflow trap at PC %08lx NPC %08lx PSR %08lx\n",
234 pc, npc, psr);
235 if(psr & PSR_PS)
236 panic("KERNEL tag overflow trap, wowza!");
237 current->tss.sig_address = pc;
238 current->tss.sig_desc = SUBSIG_TAG;
239 send_sig(SIGEMT, current, 1);
240 return;
241 }
242
243 void
244 handle_watchpoint(struct pt_regs *regs, unsigned long pc, unsigned long npc,
245 unsigned long psr)
246 {
247 printk("Watchpoint detected at PC %08lx NPC %08lx PSR %08lx\n",
248 pc, npc, psr);
249 if(psr & PSR_PS)
250 panic("Tell me what a watchpoint trap is, and I'll then deal "
251 "with such a beast...");
252 return;
253 }
254
255 void
256 handle_reg_access(struct pt_regs *regs, unsigned long pc, unsigned long npc,
257 unsigned long psr)
258 {
259 printk("Register Access Exception at PC %08lx NPC %08lx PSR %08lx\n",
260 pc, npc, psr);
261 halt();
262 return;
263 }
264
265 void
266 handle_cp_disabled(struct pt_regs *regs, unsigned long pc, unsigned long npc,
267 unsigned long psr)
268 {
269 printk("Co-Processor disabled trap at PC %08lx NPC %08lx PSR %08lx\n",
270 pc, npc, psr);
271 halt();
272 return;
273 }
274
275 void
276 handle_bad_flush(struct pt_regs *regs, unsigned long pc, unsigned long npc,
277 unsigned long psr)
278 {
279 printk("Unimplemented FLUSH Exception at PC %08lx NPC %08lx PSR %08lx\n",
280 pc, npc, psr);
281 halt();
282 return;
283 }
284
285 void
286 handle_cp_exception(struct pt_regs *regs, unsigned long pc, unsigned long npc,
287 unsigned long psr)
288 {
289 printk("Co-Processor Exception at PC %08lx NPC %08lx PSR %08lx\n",
290 pc, npc, psr);
291 halt();
292 return;
293 }
294
295 void
296 handle_hw_divzero(struct pt_regs *regs, unsigned long pc, unsigned long npc,
297 unsigned long psr)
298 {
299 printk("Divide By Zero Exception at PC %08lx NPC %08lx PSR %08lx\n",
300 pc, npc, psr);
301 halt();
302 return;
303 }
304
305 void do_ast(struct pt_regs *regs)
306 {
307 panic("Don't know how to handle AST traps yet ;-(\n");
308 return;
309 }
310
311
312
313
314
315 extern void sparc_cpu_startup(void);
316
317 extern int linux_num_cpus;
318 extern pgd_t *lnx_root;
319
320 int linux_smp_still_initting;
321 unsigned int thiscpus_tbr;
322 int thiscpus_mid;
323
324 void
325 trap_init(void)
326 {
327 struct linux_prom_registers ctx_reg;
328 int i;
329
330 if(linux_num_cpus == 1) {
331 printk("trap_init: Uniprocessor detected.\n");
332 return;
333 }
334 if(sparc_cpu_model != sun4m) {
335 prom_printf("trap_init: Multiprocessor on a non-sun4m! Aieee...\n");
336 prom_printf("trap_init: Cannot continue, bailing out.\n");
337 prom_halt();
338 }
339
340 prom_printf("trap_init: Multiprocessor detected, initiating CPU-startup. cpus=%d\n",
341 linux_num_cpus);
342 linux_smp_still_initting = 1;
343 ctx_reg.which_io = 0x0;
344 ctx_reg.phys_addr = (char *) (((unsigned long) lnx_root) - PAGE_OFFSET);
345 ctx_reg.reg_size = 0x0;
346
347
348
349
350 for(i=0; i<linux_num_cpus; i++) {
351 if((linux_cpus[i].mid & (~8)) != 0x0) {
352 static int cpuid = 0;
353 cpuid = (linux_cpus[i].mid & (~8));
354 percpu_table[cpuid].cpu_is_alive = 0;
355 thiscpus_mid = linux_cpus[i].mid;
356 thiscpus_tbr = (unsigned int)
357 percpu_table[cpuid].trap_table;
358 prom_startcpu(linux_cpus[i].prom_node, &ctx_reg, 0x0,
359 (char *) sparc_cpu_startup);
360 prom_printf("Waiting for cpu %d to start up...\n", i);
361 while(percpu_table[cpuid].cpu_is_alive == 0) {
362 static int counter = 0;
363 counter++;
364 if(counter>200)
365 break;
366 __delay(200000);
367 }
368 }
369 }
370
371 linux_smp_still_initting = 1;
372
373 return;
374 }
375
376 void
377 die_if_kernel(char * str, struct pt_regs * regs, long err)
378 {
379 return;
380 }