blob: 5aa0d5e4e7042af301a186789b93527b143c8072 [file] [log] [blame]
Robin Getz2a12c462010-03-11 16:24:18 +00001/* provide some functions which dump the trace buffer, in a nice way for people
2 * to read it, and understand what is going on
3 *
4 * Copyright 2004-2010 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later
7 */
8
9#include <linux/kernel.h>
10#include <linux/hardirq.h>
11#include <linux/thread_info.h>
12#include <linux/mm.h>
13#include <linux/uaccess.h>
14#include <linux/module.h>
15#include <linux/kallsyms.h>
16#include <linux/err.h>
17#include <linux/fs.h>
18#include <asm/dma.h>
19#include <asm/trace.h>
20#include <asm/fixed_code.h>
21#include <asm/traps.h>
Robin Getzd60805a2010-03-12 21:17:44 +000022#include <asm/irq_handler.h>
Robin Getz2a12c462010-03-11 16:24:18 +000023
Robin Getz2a12c462010-03-11 16:24:18 +000024void decode_address(char *buf, unsigned long address)
25{
Robin Getz2a12c462010-03-11 16:24:18 +000026 struct task_struct *p;
27 struct mm_struct *mm;
28 unsigned long flags, offset;
29 unsigned char in_atomic = (bfin_read_IPEND() & 0x10) || in_atomic();
30 struct rb_node *n;
31
32#ifdef CONFIG_KALLSYMS
33 unsigned long symsize;
34 const char *symname;
35 char *modname;
36 char *delim = ":";
37 char namebuf[128];
38#endif
39
40 buf += sprintf(buf, "<0x%08lx> ", address);
41
42#ifdef CONFIG_KALLSYMS
43 /* look up the address and see if we are in kernel space */
44 symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
45
46 if (symname) {
47 /* yeah! kernel space! */
48 if (!modname)
49 modname = delim = "";
50 sprintf(buf, "{ %s%s%s%s + 0x%lx }",
51 delim, modname, delim, symname,
52 (unsigned long)offset);
53 return;
54 }
55#endif
56
57 if (address >= FIXED_CODE_START && address < FIXED_CODE_END) {
58 /* Problem in fixed code section? */
59 strcat(buf, "/* Maybe fixed code section */");
60 return;
61
62 } else if (address < CONFIG_BOOT_LOAD) {
63 /* Problem somewhere before the kernel start address */
64 strcat(buf, "/* Maybe null pointer? */");
65 return;
66
67 } else if (address >= COREMMR_BASE) {
68 strcat(buf, "/* core mmrs */");
69 return;
70
71 } else if (address >= SYSMMR_BASE) {
72 strcat(buf, "/* system mmrs */");
73 return;
74
75 } else if (address >= L1_ROM_START && address < L1_ROM_START + L1_ROM_LENGTH) {
76 strcat(buf, "/* on-chip L1 ROM */");
77 return;
78 }
79
80 /*
81 * Don't walk any of the vmas if we are oopsing, it has been known
82 * to cause problems - corrupt vmas (kernel crashes) cause double faults
83 */
84 if (oops_in_progress) {
85 strcat(buf, "/* kernel dynamic memory (maybe user-space) */");
86 return;
87 }
88
89 /* looks like we're off in user-land, so let's walk all the
90 * mappings of all our processes and see if we can't be a whee
91 * bit more specific
92 */
93 write_lock_irqsave(&tasklist_lock, flags);
94 for_each_process(p) {
95 mm = (in_atomic ? p->mm : get_task_mm(p));
96 if (!mm)
97 continue;
98
99 if (!down_read_trylock(&mm->mmap_sem)) {
100 if (!in_atomic)
101 mmput(mm);
102 continue;
103 }
104
105 for (n = rb_first(&mm->mm_rb); n; n = rb_next(n)) {
106 struct vm_area_struct *vma;
107
108 vma = rb_entry(n, struct vm_area_struct, vm_rb);
109
110 if (address >= vma->vm_start && address < vma->vm_end) {
111 char _tmpbuf[256];
112 char *name = p->comm;
113 struct file *file = vma->vm_file;
114
115 if (file) {
116 char *d_name = d_path(&file->f_path, _tmpbuf,
117 sizeof(_tmpbuf));
118 if (!IS_ERR(d_name))
119 name = d_name;
120 }
121
122 /* FLAT does not have its text aligned to the start of
123 * the map while FDPIC ELF does ...
124 */
125
126 /* before we can check flat/fdpic, we need to
127 * make sure current is valid
128 */
129 if ((unsigned long)current >= FIXED_CODE_START &&
130 !((unsigned long)current & 0x3)) {
131 if (current->mm &&
132 (address > current->mm->start_code) &&
133 (address < current->mm->end_code))
134 offset = address - current->mm->start_code;
135 else
136 offset = (address - vma->vm_start) +
137 (vma->vm_pgoff << PAGE_SHIFT);
138
139 sprintf(buf, "[ %s + 0x%lx ]", name, offset);
140 } else
141 sprintf(buf, "[ %s vma:0x%lx-0x%lx]",
142 name, vma->vm_start, vma->vm_end);
143
144 up_read(&mm->mmap_sem);
145 if (!in_atomic)
146 mmput(mm);
147
148 if (buf[0] == '\0')
149 sprintf(buf, "[ %s ] dynamic memory", name);
150
151 goto done;
152 }
153 }
154
155 up_read(&mm->mmap_sem);
156 if (!in_atomic)
157 mmput(mm);
158 }
159
160 /*
161 * we were unable to find this address anywhere,
162 * or some MMs were skipped because they were in use.
163 */
164 sprintf(buf, "/* kernel dynamic memory */");
165
166done:
167 write_unlock_irqrestore(&tasklist_lock, flags);
Robin Getz2a12c462010-03-11 16:24:18 +0000168}
169
170#define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1)
171
172/*
173 * Similar to get_user, do some address checking, then dereference
174 * Return true on success, false on bad address
175 */
176bool get_instruction(unsigned short *val, unsigned short *address)
177{
178 unsigned long addr = (unsigned long)address;
179
180 /* Check for odd addresses */
181 if (addr & 0x1)
182 return false;
183
184 /* MMR region will never have instructions */
185 if (addr >= SYSMMR_BASE)
186 return false;
187
188 switch (bfin_mem_access_type(addr, 2)) {
189 case BFIN_MEM_ACCESS_CORE:
190 case BFIN_MEM_ACCESS_CORE_ONLY:
191 *val = *address;
192 return true;
193 case BFIN_MEM_ACCESS_DMA:
194 dma_memcpy(val, address, 2);
195 return true;
196 case BFIN_MEM_ACCESS_ITEST:
197 isram_memcpy(val, address, 2);
198 return true;
199 default: /* invalid access */
200 return false;
201 }
202}
203
204/*
205 * decode the instruction if we are printing out the trace, as it
206 * makes things easier to follow, without running it through objdump
207 * These are the normal instructions which cause change of flow, which
208 * would be at the source of the trace buffer
209 */
Robin Getzd28cff42010-03-11 19:26:38 +0000210#if defined(CONFIG_DEBUG_BFIN_HWTRACE_ON)
Robin Getz2a12c462010-03-11 16:24:18 +0000211static void decode_instruction(unsigned short *address)
212{
213 unsigned short opcode;
214
215 if (get_instruction(&opcode, address)) {
216 if (opcode == 0x0010)
Robin Getzd28cff42010-03-11 19:26:38 +0000217 pr_cont("RTS");
Robin Getz2a12c462010-03-11 16:24:18 +0000218 else if (opcode == 0x0011)
Robin Getzd28cff42010-03-11 19:26:38 +0000219 pr_cont("RTI");
Robin Getz2a12c462010-03-11 16:24:18 +0000220 else if (opcode == 0x0012)
Robin Getzd28cff42010-03-11 19:26:38 +0000221 pr_cont("RTX");
Robin Getz2a12c462010-03-11 16:24:18 +0000222 else if (opcode == 0x0013)
Robin Getzd28cff42010-03-11 19:26:38 +0000223 pr_cont("RTN");
Robin Getz2a12c462010-03-11 16:24:18 +0000224 else if (opcode == 0x0014)
Robin Getzd28cff42010-03-11 19:26:38 +0000225 pr_cont("RTE");
Robin Getz2a12c462010-03-11 16:24:18 +0000226 else if (opcode == 0x0025)
Robin Getzd28cff42010-03-11 19:26:38 +0000227 pr_cont("EMUEXCPT");
Robin Getz2a12c462010-03-11 16:24:18 +0000228 else if (opcode >= 0x0040 && opcode <= 0x0047)
Robin Getzd28cff42010-03-11 19:26:38 +0000229 pr_cont("STI R%i", opcode & 7);
Robin Getz2a12c462010-03-11 16:24:18 +0000230 else if (opcode >= 0x0050 && opcode <= 0x0057)
Robin Getzd28cff42010-03-11 19:26:38 +0000231 pr_cont("JUMP (P%i)", opcode & 7);
Robin Getz2a12c462010-03-11 16:24:18 +0000232 else if (opcode >= 0x0060 && opcode <= 0x0067)
Robin Getzd28cff42010-03-11 19:26:38 +0000233 pr_cont("CALL (P%i)", opcode & 7);
Robin Getz2a12c462010-03-11 16:24:18 +0000234 else if (opcode >= 0x0070 && opcode <= 0x0077)
Robin Getzd28cff42010-03-11 19:26:38 +0000235 pr_cont("CALL (PC+P%i)", opcode & 7);
Robin Getz2a12c462010-03-11 16:24:18 +0000236 else if (opcode >= 0x0080 && opcode <= 0x0087)
Robin Getzd28cff42010-03-11 19:26:38 +0000237 pr_cont("JUMP (PC+P%i)", opcode & 7);
Robin Getz2a12c462010-03-11 16:24:18 +0000238 else if (opcode >= 0x0090 && opcode <= 0x009F)
Robin Getzd28cff42010-03-11 19:26:38 +0000239 pr_cont("RAISE 0x%x", opcode & 0xF);
Robin Getz2a12c462010-03-11 16:24:18 +0000240 else if (opcode >= 0x00A0 && opcode <= 0x00AF)
Robin Getzd28cff42010-03-11 19:26:38 +0000241 pr_cont("EXCPT 0x%x", opcode & 0xF);
Robin Getz2a12c462010-03-11 16:24:18 +0000242 else if ((opcode >= 0x1000 && opcode <= 0x13FF) || (opcode >= 0x1800 && opcode <= 0x1BFF))
Robin Getzd28cff42010-03-11 19:26:38 +0000243 pr_cont("IF !CC JUMP");
Robin Getz2a12c462010-03-11 16:24:18 +0000244 else if ((opcode >= 0x1400 && opcode <= 0x17ff) || (opcode >= 0x1c00 && opcode <= 0x1fff))
Robin Getzd28cff42010-03-11 19:26:38 +0000245 pr_cont("IF CC JUMP");
Robin Getz2a12c462010-03-11 16:24:18 +0000246 else if (opcode >= 0x2000 && opcode <= 0x2fff)
Robin Getzd28cff42010-03-11 19:26:38 +0000247 pr_cont("JUMP.S");
Robin Getz2a12c462010-03-11 16:24:18 +0000248 else if (opcode >= 0xe080 && opcode <= 0xe0ff)
Robin Getzd28cff42010-03-11 19:26:38 +0000249 pr_cont("LSETUP");
Robin Getz2a12c462010-03-11 16:24:18 +0000250 else if (opcode >= 0xe200 && opcode <= 0xe2ff)
Robin Getzd28cff42010-03-11 19:26:38 +0000251 pr_cont("JUMP.L");
Robin Getz2a12c462010-03-11 16:24:18 +0000252 else if (opcode >= 0xe300 && opcode <= 0xe3ff)
Robin Getzd28cff42010-03-11 19:26:38 +0000253 pr_cont("CALL pcrel");
Robin Getz2a12c462010-03-11 16:24:18 +0000254 else
Robin Getzd28cff42010-03-11 19:26:38 +0000255 pr_cont("0x%04x", opcode);
Robin Getz2a12c462010-03-11 16:24:18 +0000256 }
257
258}
259#endif
260
261void dump_bfin_trace_buffer(void)
262{
Robin Getz2a12c462010-03-11 16:24:18 +0000263#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
Robin Getzd60805a2010-03-12 21:17:44 +0000264 int tflags, i = 0, fault = 0;
Robin Getz2a12c462010-03-11 16:24:18 +0000265 char buf[150];
266 unsigned short *addr;
Robin Getzd60805a2010-03-12 21:17:44 +0000267 unsigned int cpu = raw_smp_processor_id();
Robin Getz2a12c462010-03-11 16:24:18 +0000268#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
269 int j, index;
270#endif
271
272 trace_buffer_save(tflags);
273
Robin Getzd28cff42010-03-11 19:26:38 +0000274 pr_notice("Hardware Trace:\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000275
276#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
Robin Getzd28cff42010-03-11 19:26:38 +0000277 pr_notice("WARNING: Expanded trace turned on - can not trace exceptions\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000278#endif
279
280 if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) {
281 for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) {
Robin Getzd60805a2010-03-12 21:17:44 +0000282 addr = (unsigned short *)bfin_read_TBUF();
283 decode_address(buf, (unsigned long)addr);
Robin Getzd28cff42010-03-11 19:26:38 +0000284 pr_notice("%4i Target : %s\n", i, buf);
Robin Getzd60805a2010-03-12 21:17:44 +0000285 /* Normally, the faulting instruction doesn't go into
286 * the trace buffer, (since it doesn't commit), so
287 * we print out the fault address here
288 */
289 if (!fault && addr == (unsigned short *)trap &&
290 (cpu_pda[cpu].seqstat & SEQSTAT_EXCAUSE) > VEC_EXCPT15) {
291 decode_address(buf, cpu_pda[cpu].icplb_fault_addr);
292 pr_notice(" FAULT : %s ", buf);
293 decode_instruction((unsigned short *)cpu_pda[cpu].icplb_fault_addr);
294 pr_cont("\n");
295 fault = 1;
296 }
Robin Getz2a12c462010-03-11 16:24:18 +0000297 addr = (unsigned short *)bfin_read_TBUF();
298 decode_address(buf, (unsigned long)addr);
Robin Getzd28cff42010-03-11 19:26:38 +0000299 pr_notice(" Source : %s ", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000300 decode_instruction(addr);
Robin Getzd28cff42010-03-11 19:26:38 +0000301 pr_cont("\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000302 }
303 }
304
305#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
306 if (trace_buff_offset)
307 index = trace_buff_offset / 4;
308 else
309 index = EXPAND_LEN;
310
311 j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128;
312 while (j) {
313 decode_address(buf, software_trace_buff[index]);
Robin Getzd28cff42010-03-11 19:26:38 +0000314 pr_notice("%4i Target : %s\n", i, buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000315 index -= 1;
316 if (index < 0)
317 index = EXPAND_LEN;
318 decode_address(buf, software_trace_buff[index]);
Robin Getzd28cff42010-03-11 19:26:38 +0000319 pr_notice(" Source : %s ", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000320 decode_instruction((unsigned short *)software_trace_buff[index]);
Robin Getzd28cff42010-03-11 19:26:38 +0000321 pr_cont("\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000322 index -= 1;
323 if (index < 0)
324 index = EXPAND_LEN;
325 j--;
326 i++;
327 }
328#endif
329
330 trace_buffer_restore(tflags);
331#endif
Robin Getz2a12c462010-03-11 16:24:18 +0000332}
333EXPORT_SYMBOL(dump_bfin_trace_buffer);
334
335void dump_bfin_process(struct pt_regs *fp)
336{
Robin Getz2a12c462010-03-11 16:24:18 +0000337 /* We should be able to look at fp->ipend, but we don't push it on the
338 * stack all the time, so do this until we fix that */
339 unsigned int context = bfin_read_IPEND();
340
341 if (oops_in_progress)
Robin Getzd28cff42010-03-11 19:26:38 +0000342 pr_emerg("Kernel OOPS in progress\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000343
344 if (context & 0x0020 && (fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR)
Robin Getzd28cff42010-03-11 19:26:38 +0000345 pr_notice("HW Error context\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000346 else if (context & 0x0020)
Robin Getzd28cff42010-03-11 19:26:38 +0000347 pr_notice("Deferred Exception context\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000348 else if (context & 0x3FC0)
Robin Getzd28cff42010-03-11 19:26:38 +0000349 pr_notice("Interrupt context\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000350 else if (context & 0x4000)
Robin Getzd28cff42010-03-11 19:26:38 +0000351 pr_notice("Deferred Interrupt context\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000352 else if (context & 0x8000)
Robin Getzd28cff42010-03-11 19:26:38 +0000353 pr_notice("Kernel process context\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000354
355 /* Because we are crashing, and pointers could be bad, we check things
356 * pretty closely before we use them
357 */
358 if ((unsigned long)current >= FIXED_CODE_START &&
359 !((unsigned long)current & 0x3) && current->pid) {
Robin Getzd28cff42010-03-11 19:26:38 +0000360 pr_notice("CURRENT PROCESS:\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000361 if (current->comm >= (char *)FIXED_CODE_START)
Robin Getzd28cff42010-03-11 19:26:38 +0000362 pr_notice("COMM=%s PID=%d",
Robin Getz2a12c462010-03-11 16:24:18 +0000363 current->comm, current->pid);
364 else
Robin Getzd28cff42010-03-11 19:26:38 +0000365 pr_notice("COMM= invalid");
Robin Getz2a12c462010-03-11 16:24:18 +0000366
Robin Getzd28cff42010-03-11 19:26:38 +0000367 pr_cont(" CPU=%d\n", current_thread_info()->cpu);
368 if (!((unsigned long)current->mm & 0x3) &&
369 (unsigned long)current->mm >= FIXED_CODE_START) {
370 pr_notice("TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000371 (void *)current->mm->start_code,
372 (void *)current->mm->end_code,
373 (void *)current->mm->start_data,
Robin Getzd28cff42010-03-11 19:26:38 +0000374 (void *)current->mm->end_data);
375 pr_notice(" BSS = 0x%p-0x%p USER-STACK = 0x%p\n\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000376 (void *)current->mm->end_data,
377 (void *)current->mm->brk,
378 (void *)current->mm->start_stack);
Robin Getzd28cff42010-03-11 19:26:38 +0000379 } else
380 pr_notice("invalid mm\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000381 } else
Robin Getzd28cff42010-03-11 19:26:38 +0000382 pr_notice("No Valid process in current context\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000383}
384
385void dump_bfin_mem(struct pt_regs *fp)
386{
Robin Getz2a12c462010-03-11 16:24:18 +0000387 unsigned short *addr, *erraddr, val = 0, err = 0;
388 char sti = 0, buf[6];
389
390 erraddr = (void *)fp->pc;
391
Robin Getzd28cff42010-03-11 19:26:38 +0000392 pr_notice("return address: [0x%p]; contents of:", erraddr);
Robin Getz2a12c462010-03-11 16:24:18 +0000393
394 for (addr = (unsigned short *)((unsigned long)erraddr & ~0xF) - 0x10;
395 addr < (unsigned short *)((unsigned long)erraddr & ~0xF) + 0x10;
396 addr++) {
397 if (!((unsigned long)addr & 0xF))
Robin Getzd28cff42010-03-11 19:26:38 +0000398 pr_notice("0x%p: ", addr);
Robin Getz2a12c462010-03-11 16:24:18 +0000399
400 if (!get_instruction(&val, addr)) {
401 val = 0;
402 sprintf(buf, "????");
403 } else
404 sprintf(buf, "%04x", val);
405
406 if (addr == erraddr) {
Robin Getzd28cff42010-03-11 19:26:38 +0000407 pr_cont("[%s]", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000408 err = val;
409 } else
Robin Getzd28cff42010-03-11 19:26:38 +0000410 pr_cont(" %s ", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000411
412 /* Do any previous instructions turn on interrupts? */
413 if (addr <= erraddr && /* in the past */
414 ((val >= 0x0040 && val <= 0x0047) || /* STI instruction */
415 val == 0x017b)) /* [SP++] = RETI */
416 sti = 1;
417 }
418
Robin Getzd28cff42010-03-11 19:26:38 +0000419 pr_cont("\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000420
421 /* Hardware error interrupts can be deferred */
422 if (unlikely(sti && (fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR &&
423 oops_in_progress)){
Robin Getzd28cff42010-03-11 19:26:38 +0000424 pr_notice("Looks like this was a deferred error - sorry\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000425#ifndef CONFIG_DEBUG_HWERR
Robin Getzd28cff42010-03-11 19:26:38 +0000426 pr_notice("The remaining message may be meaningless\n");
427 pr_notice("You should enable CONFIG_DEBUG_HWERR to get a better idea where it came from\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000428#else
429 /* If we are handling only one peripheral interrupt
430 * and current mm and pid are valid, and the last error
431 * was in that user space process's text area
432 * print it out - because that is where the problem exists
433 */
434 if ((!(((fp)->ipend & ~0x30) & (((fp)->ipend & ~0x30) - 1))) &&
435 (current->pid && current->mm)) {
436 /* And the last RETI points to the current userspace context */
437 if ((fp + 1)->pc >= current->mm->start_code &&
438 (fp + 1)->pc <= current->mm->end_code) {
Robin Getzd28cff42010-03-11 19:26:38 +0000439 pr_notice("It might be better to look around here :\n");
440 pr_notice("-------------------------------------------\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000441 show_regs(fp + 1);
Robin Getzd28cff42010-03-11 19:26:38 +0000442 pr_notice("-------------------------------------------\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000443 }
444 }
445#endif
446 }
Robin Getz2a12c462010-03-11 16:24:18 +0000447}
448
449void show_regs(struct pt_regs *fp)
450{
Robin Getz2a12c462010-03-11 16:24:18 +0000451 char buf[150];
452 struct irqaction *action;
453 unsigned int i;
454 unsigned long flags = 0;
455 unsigned int cpu = raw_smp_processor_id();
456 unsigned char in_atomic = (bfin_read_IPEND() & 0x10) || in_atomic();
457
Robin Getzd28cff42010-03-11 19:26:38 +0000458 pr_notice("\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000459 if (CPUID != bfin_cpuid())
Robin Getzd28cff42010-03-11 19:26:38 +0000460 pr_notice("Compiled for cpu family 0x%04x (Rev %d), "
Robin Getz2a12c462010-03-11 16:24:18 +0000461 "but running on:0x%04x (Rev %d)\n",
462 CPUID, bfin_compiled_revid(), bfin_cpuid(), bfin_revid());
463
Robin Getzd28cff42010-03-11 19:26:38 +0000464 pr_notice("ADSP-%s-0.%d",
Robin Getz2a12c462010-03-11 16:24:18 +0000465 CPU, bfin_compiled_revid());
466
467 if (bfin_compiled_revid() != bfin_revid())
Robin Getzd28cff42010-03-11 19:26:38 +0000468 pr_cont("(Detected 0.%d)", bfin_revid());
Robin Getz2a12c462010-03-11 16:24:18 +0000469
Robin Getzd28cff42010-03-11 19:26:38 +0000470 pr_cont(" %lu(MHz CCLK) %lu(MHz SCLK) (%s)\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000471 get_cclk()/1000000, get_sclk()/1000000,
472#ifdef CONFIG_MPU
473 "mpu on"
474#else
475 "mpu off"
476#endif
477 );
478
Robin Getzd28cff42010-03-11 19:26:38 +0000479 pr_notice("%s", linux_banner);
Robin Getz2a12c462010-03-11 16:24:18 +0000480
Robin Getzd28cff42010-03-11 19:26:38 +0000481 pr_notice("\nSEQUENCER STATUS:\t\t%s\n", print_tainted());
482 pr_notice(" SEQSTAT: %08lx IPEND: %04lx IMASK: %04lx SYSCFG: %04lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000483 (long)fp->seqstat, fp->ipend, cpu_pda[raw_smp_processor_id()].ex_imask, fp->syscfg);
484 if (fp->ipend & EVT_IRPTEN)
Robin Getzd28cff42010-03-11 19:26:38 +0000485 pr_notice(" Global Interrupts Disabled (IPEND[4])\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000486 if (!(cpu_pda[raw_smp_processor_id()].ex_imask & (EVT_IVG13 | EVT_IVG12 | EVT_IVG11 |
487 EVT_IVG10 | EVT_IVG9 | EVT_IVG8 | EVT_IVG7 | EVT_IVTMR)))
Robin Getzd28cff42010-03-11 19:26:38 +0000488 pr_notice(" Peripheral interrupts masked off\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000489 if (!(cpu_pda[raw_smp_processor_id()].ex_imask & (EVT_IVG15 | EVT_IVG14)))
Robin Getzd28cff42010-03-11 19:26:38 +0000490 pr_notice(" Kernel interrupts masked off\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000491 if ((fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR) {
Robin Getzd28cff42010-03-11 19:26:38 +0000492 pr_notice(" HWERRCAUSE: 0x%lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000493 (fp->seqstat & SEQSTAT_HWERRCAUSE) >> 14);
494#ifdef EBIU_ERRMST
495 /* If the error was from the EBIU, print it out */
496 if (bfin_read_EBIU_ERRMST() & CORE_ERROR) {
Robin Getzd28cff42010-03-11 19:26:38 +0000497 pr_notice(" EBIU Error Reason : 0x%04x\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000498 bfin_read_EBIU_ERRMST());
Robin Getzd28cff42010-03-11 19:26:38 +0000499 pr_notice(" EBIU Error Address : 0x%08x\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000500 bfin_read_EBIU_ERRADD());
501 }
502#endif
503 }
Robin Getzd28cff42010-03-11 19:26:38 +0000504 pr_notice(" EXCAUSE : 0x%lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000505 fp->seqstat & SEQSTAT_EXCAUSE);
506 for (i = 2; i <= 15 ; i++) {
507 if (fp->ipend & (1 << i)) {
508 if (i != 4) {
509 decode_address(buf, bfin_read32(EVT0 + 4*i));
Robin Getzd28cff42010-03-11 19:26:38 +0000510 pr_notice(" physical IVG%i asserted : %s\n", i, buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000511 } else
Robin Getzd28cff42010-03-11 19:26:38 +0000512 pr_notice(" interrupts disabled\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000513 }
514 }
515
516 /* if no interrupts are going off, don't print this out */
517 if (fp->ipend & ~0x3F) {
518 for (i = 0; i < (NR_IRQS - 1); i++) {
519 if (!in_atomic)
520 raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
521
522 action = irq_desc[i].action;
523 if (!action)
524 goto unlock;
525
526 decode_address(buf, (unsigned int)action->handler);
Robin Getzd28cff42010-03-11 19:26:38 +0000527 pr_notice(" logical irq %3d mapped : %s", i, buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000528 for (action = action->next; action; action = action->next) {
529 decode_address(buf, (unsigned int)action->handler);
Robin Getzd28cff42010-03-11 19:26:38 +0000530 pr_cont(", %s", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000531 }
Robin Getzd28cff42010-03-11 19:26:38 +0000532 pr_cont("\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000533unlock:
534 if (!in_atomic)
535 raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
536 }
537 }
538
539 decode_address(buf, fp->rete);
Robin Getzd28cff42010-03-11 19:26:38 +0000540 pr_notice(" RETE: %s\n", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000541 decode_address(buf, fp->retn);
Robin Getzd28cff42010-03-11 19:26:38 +0000542 pr_notice(" RETN: %s\n", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000543 decode_address(buf, fp->retx);
Robin Getzd28cff42010-03-11 19:26:38 +0000544 pr_notice(" RETX: %s\n", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000545 decode_address(buf, fp->rets);
Robin Getzd28cff42010-03-11 19:26:38 +0000546 pr_notice(" RETS: %s\n", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000547 decode_address(buf, fp->pc);
Robin Getzd28cff42010-03-11 19:26:38 +0000548 pr_notice(" PC : %s\n", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000549
550 if (((long)fp->seqstat & SEQSTAT_EXCAUSE) &&
551 (((long)fp->seqstat & SEQSTAT_EXCAUSE) != VEC_HWERR)) {
552 decode_address(buf, cpu_pda[cpu].dcplb_fault_addr);
Robin Getzd28cff42010-03-11 19:26:38 +0000553 pr_notice("DCPLB_FAULT_ADDR: %s\n", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000554 decode_address(buf, cpu_pda[cpu].icplb_fault_addr);
Robin Getzd28cff42010-03-11 19:26:38 +0000555 pr_notice("ICPLB_FAULT_ADDR: %s\n", buf);
Robin Getz2a12c462010-03-11 16:24:18 +0000556 }
557
Robin Getzd28cff42010-03-11 19:26:38 +0000558 pr_notice("PROCESSOR STATE:\n");
559 pr_notice(" R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000560 fp->r0, fp->r1, fp->r2, fp->r3);
Robin Getzd28cff42010-03-11 19:26:38 +0000561 pr_notice(" R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000562 fp->r4, fp->r5, fp->r6, fp->r7);
Robin Getzd28cff42010-03-11 19:26:38 +0000563 pr_notice(" P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000564 fp->p0, fp->p1, fp->p2, fp->p3);
Robin Getzd28cff42010-03-11 19:26:38 +0000565 pr_notice(" P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000566 fp->p4, fp->p5, fp->fp, (long)fp);
Robin Getzd28cff42010-03-11 19:26:38 +0000567 pr_notice(" LB0: %08lx LT0: %08lx LC0: %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000568 fp->lb0, fp->lt0, fp->lc0);
Robin Getzd28cff42010-03-11 19:26:38 +0000569 pr_notice(" LB1: %08lx LT1: %08lx LC1: %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000570 fp->lb1, fp->lt1, fp->lc1);
Robin Getzd28cff42010-03-11 19:26:38 +0000571 pr_notice(" B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000572 fp->b0, fp->l0, fp->m0, fp->i0);
Robin Getzd28cff42010-03-11 19:26:38 +0000573 pr_notice(" B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000574 fp->b1, fp->l1, fp->m1, fp->i1);
Robin Getzd28cff42010-03-11 19:26:38 +0000575 pr_notice(" B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000576 fp->b2, fp->l2, fp->m2, fp->i2);
Robin Getzd28cff42010-03-11 19:26:38 +0000577 pr_notice(" B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000578 fp->b3, fp->l3, fp->m3, fp->i3);
Robin Getzd28cff42010-03-11 19:26:38 +0000579 pr_notice("A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000580 fp->a0w, fp->a0x, fp->a1w, fp->a1x);
581
Robin Getzd28cff42010-03-11 19:26:38 +0000582 pr_notice("USP : %08lx ASTAT: %08lx\n",
Robin Getz2a12c462010-03-11 16:24:18 +0000583 rdusp(), fp->astat);
584
Robin Getzd28cff42010-03-11 19:26:38 +0000585 pr_notice("\n");
Robin Getz2a12c462010-03-11 16:24:18 +0000586}