1 | /* |
---|
2 | * M68340/349 registers and stack dump if an exception is raised |
---|
3 | * |
---|
4 | * Author: |
---|
5 | * Pascal Cadic |
---|
6 | * France Telecom - CNET/DSM/TAM/CAT |
---|
7 | * 4, rue du Clos Courtel |
---|
8 | * 35512 CESSON-SEVIGNE |
---|
9 | * FRANCE |
---|
10 | * |
---|
11 | * COPYRIGHT (c) 1989-1998. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * Copyright assigned to U.S. Government, 1994. |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * |
---|
18 | * http://www.OARcorp.com/rtems/license.html. |
---|
19 | * |
---|
20 | * $Id$ |
---|
21 | */ |
---|
22 | |
---|
23 | #include <stdio.h> |
---|
24 | |
---|
25 | const char *exceptionName[] = |
---|
26 | { |
---|
27 | "INITIAL STACK POINTER", |
---|
28 | "INITIAL PROGRAM COUNTER", |
---|
29 | "BUS ERROR", |
---|
30 | "ADDRESS ERROR", |
---|
31 | "ILLEGAL INSTRUCTION", |
---|
32 | "DIVISION BY ZERO", |
---|
33 | "CHK, CHK2", |
---|
34 | "TRAPcc, TRAPv", |
---|
35 | "PRIVILEGE VIOLATION", |
---|
36 | "TRACE", |
---|
37 | "LINE A EMULATOR", |
---|
38 | "LINE F EMULATOR", |
---|
39 | "HARDWARE BREAK", |
---|
40 | "COPROCESSOR PROTOCOL VIOLATION", |
---|
41 | "FORMAT ERROR", |
---|
42 | "UNINITIALIZED INTERRUPT", |
---|
43 | "RESERVED 16", |
---|
44 | "RESERVED 17", |
---|
45 | "RESERVED 18", |
---|
46 | "RESERVED 19", |
---|
47 | "RESERVED 20", |
---|
48 | "RESERVED 21", |
---|
49 | "RESERVED 22", |
---|
50 | "RESERVED 23", |
---|
51 | "SPURIOUS INTERRUPT", |
---|
52 | "LEVEL 1 AUTOVECTOR", |
---|
53 | "LEVEL 2 AUTOVECTOR", |
---|
54 | "LEVEL 3 AUTOVECTOR", |
---|
55 | "LEVEL 4 AUTOVECTOR", |
---|
56 | "LEVEL 5 AUTOVECTOR", |
---|
57 | "LEVEL 6 AUTOVECTOR", |
---|
58 | "LEVEL 7 AUTOVECTOR", |
---|
59 | "TRAP 1", |
---|
60 | "TRAP 2", |
---|
61 | "TRAP 3", |
---|
62 | "TRAP 4", |
---|
63 | "TRAP 5", |
---|
64 | "TRAP 6", |
---|
65 | "TRAP 7", |
---|
66 | "TRAP 8", |
---|
67 | "TRAP 9", |
---|
68 | "TRAP 10", |
---|
69 | "TRAP 11", |
---|
70 | "TRAP 12", |
---|
71 | "TRAP 13", |
---|
72 | "TRAP 14", |
---|
73 | "TRAP 15", |
---|
74 | "VECTOR 48", |
---|
75 | "VECTOR 49", |
---|
76 | "VECTOR 50", |
---|
77 | "VECTOR 51", |
---|
78 | "VECTOR 52", |
---|
79 | "VECTOR 53", |
---|
80 | "VECTOR 54", |
---|
81 | "VECTOR 55", |
---|
82 | "VECTOR 56", |
---|
83 | "VECTOR 57", |
---|
84 | "VECTOR 58", |
---|
85 | "VECTOR 59", |
---|
86 | "VECTOR 60", |
---|
87 | "VECTOR 61", |
---|
88 | "VECTOR 62", |
---|
89 | "VECTOR 63", |
---|
90 | }; |
---|
91 | |
---|
92 | typedef struct { |
---|
93 | unsigned long pc; |
---|
94 | unsigned short sr; |
---|
95 | unsigned short format_id; |
---|
96 | unsigned long d0, d1, d2, d3, d4, d5, d6, d7; |
---|
97 | unsigned long a0, a1, a2, a3, a4, a5, a6, a7; |
---|
98 | unsigned long sfc, dfc, vbr; |
---|
99 | } boot_panic_registers_t; |
---|
100 | |
---|
101 | boot_panic_registers_t _boot_panic_registers; |
---|
102 | |
---|
103 | extern void RAW_FMT( int minor, const char* fmt, ... ); |
---|
104 | extern char RAW_GETC(int minor); |
---|
105 | |
---|
106 | /****************************************************** |
---|
107 | Name: _dbug_dump |
---|
108 | Input parameters: sr, pc, stack pointer, |
---|
109 | size to display |
---|
110 | Output parameters: - |
---|
111 | Description: display the supervisor stack |
---|
112 | *****************************************************/ |
---|
113 | void _dbug_dump(unsigned short sr, void* pc, unsigned short *stack, int size) |
---|
114 | { |
---|
115 | int i; |
---|
116 | |
---|
117 | RAW_FMT(0,"%x : %x \t%x",0,sr,(unsigned short)(((unsigned)pc)>>16)); |
---|
118 | for (i=2; i<size; i++) { |
---|
119 | if ((i%8)==0) RAW_FMT(0,"\n%x :",i/8); |
---|
120 | RAW_FMT(0," %x\t",stack[i-2]); |
---|
121 | } |
---|
122 | RAW_FMT(0,"\n"); |
---|
123 | } |
---|
124 | |
---|
125 | /****************************************************** |
---|
126 | Name: _dbug_dump |
---|
127 | Input parameters: - |
---|
128 | Output parameters: - |
---|
129 | Description: display microcontroler state. Registers |
---|
130 | values are stored in _boot_panic_registers |
---|
131 | which is filled in _uhoh ASM routine |
---|
132 | *****************************************************/ |
---|
133 | void _dbug_dumpanic(void) |
---|
134 | { |
---|
135 | int c; |
---|
136 | void *faultedAddr, *pc; |
---|
137 | unsigned short vector, status; |
---|
138 | unsigned char frametype, *stack; |
---|
139 | #define ESCAPE 27 |
---|
140 | |
---|
141 | stack = (unsigned char*)(_boot_panic_registers.a7); |
---|
142 | do { |
---|
143 | status = _boot_panic_registers.sr; |
---|
144 | pc = (void*)_boot_panic_registers.pc; |
---|
145 | faultedAddr = *(void**)(stack+4); |
---|
146 | vector = (_boot_panic_registers.format_id&0x0FFF)>>2; |
---|
147 | frametype = (_boot_panic_registers.format_id&0xF000)>>12; |
---|
148 | |
---|
149 | RAW_FMT(0,"\n---------------------------------------------\n"); |
---|
150 | if (vector<64) |
---|
151 | RAW_FMT(0,"%s",exceptionName[vector]); |
---|
152 | else { |
---|
153 | RAW_FMT(0,"RESERVED USER"); |
---|
154 | } |
---|
155 | RAW_FMT(0," exception (vector %x, type %x)\n",vector,frametype); |
---|
156 | RAW_FMT(0,"---------------------------------------------\n"); |
---|
157 | RAW_FMT(0,"PC : 0x%x ",pc); |
---|
158 | RAW_FMT(0,"A7 : 0x%x ",_boot_panic_registers.a7); |
---|
159 | RAW_FMT(0,"SR : 0x%x\n",status); |
---|
160 | if (frametype==0x0c) { |
---|
161 | RAW_FMT(0,"\nfaulted address = 0x%x\n",faultedAddr); |
---|
162 | } |
---|
163 | RAW_FMT(0,"---------------------------------------------\n"); |
---|
164 | RAW_FMT(0," panic regs\n"); |
---|
165 | RAW_FMT(0,"---------------------------------------------\n"); |
---|
166 | RAW_FMT(0,"D[0..3] : %x \t%x \t%x \t%x\n", |
---|
167 | _boot_panic_registers.d0,_boot_panic_registers.d1, |
---|
168 | _boot_panic_registers.d2,_boot_panic_registers.d3); |
---|
169 | RAW_FMT(0,"D[4..7] : %x \t%x \t%x \t%x\n", |
---|
170 | _boot_panic_registers.d4,_boot_panic_registers.d5, |
---|
171 | _boot_panic_registers.d6,_boot_panic_registers.d7); |
---|
172 | RAW_FMT(0,"A[0..3] : %x \t%x \t%x \t%x\n", |
---|
173 | _boot_panic_registers.a0,_boot_panic_registers.a1, |
---|
174 | _boot_panic_registers.a2,_boot_panic_registers.a3); |
---|
175 | RAW_FMT(0,"A[4..7] : %x \t%x \t%x \t%x\n", |
---|
176 | _boot_panic_registers.a4,_boot_panic_registers.a5, |
---|
177 | _boot_panic_registers.a6,_boot_panic_registers.a7); |
---|
178 | |
---|
179 | RAW_FMT(0," SFC : %x",_boot_panic_registers.sfc); |
---|
180 | RAW_FMT(0," DFC : %x\n",_boot_panic_registers.dfc); |
---|
181 | RAW_FMT(0," VBR : %x\n",_boot_panic_registers.vbr); |
---|
182 | RAW_FMT(0,"---------------------------------------------\n"); |
---|
183 | RAW_FMT(0," panic stack\n"); |
---|
184 | RAW_FMT(0,"---------------------------------------------\n"); |
---|
185 | _dbug_dump(status, pc, (unsigned short*)stack,64*2); |
---|
186 | |
---|
187 | RAW_FMT(0,"---------------------------------------------\n"); |
---|
188 | RAW_FMT(0,"press escape to reboot\n"); |
---|
189 | } while ((c=RAW_GETC(0))!=ESCAPE); /* cgets ne marche pas si les IT sont bloquées */ |
---|
190 | } |
---|
191 | |
---|
192 | |
---|
193 | |
---|