source: rtems/c/src/lib/libbsp/m68k/gen68340/startup/dumpanic.c @ 4590fd96

5
Last change on this file since 4590fd96 was 4590fd96, checked in by Joel Sherrill <joel@…>, on 04/04/17 at 22:04:02

gen68340/startup/dumppanic.c: Fix warnings

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*
2 *  M68340/349 registers and stack dump if an exception is raised
3 */
4
5/*
6 *  Author:
7 *  Pascal Cadic
8 *  France Telecom - CNET/DSM/TAM/CAT
9 *  4, rue du Clos Courtel
10 *  35512 CESSON-SEVIGNE
11 *  FRANCE
12 *
13 *  COPYRIGHT (c) 1989-1999.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.org/license/LICENSE.
19 */
20
21#include <bsp.h>
22#include <rtems/bspIo.h>
23
24const char *exceptionName[] = {
25  "INITIAL STACK POINTER",
26  "INITIAL PROGRAM COUNTER",
27  "BUS ERROR",
28  "ADDRESS ERROR",
29  "ILLEGAL INSTRUCTION",
30  "DIVISION BY ZERO",
31  "CHK, CHK2",
32  "TRAPcc, TRAPv",
33  "PRIVILEGE VIOLATION",
34  "TRACE",
35  "LINE A EMULATOR",
36  "LINE F EMULATOR",
37  "HARDWARE BREAK",
38  "COPROCESSOR PROTOCOL VIOLATION",
39  "FORMAT ERROR",
40  "UNINITIALIZED INTERRUPT",
41  "RESERVED 16",
42  "RESERVED 17",
43  "RESERVED 18",
44  "RESERVED 19",
45  "RESERVED 20",
46  "RESERVED 21",
47  "RESERVED 22",
48  "RESERVED 23",
49  "SPURIOUS INTERRUPT",
50  "LEVEL 1 AUTOVECTOR",
51  "LEVEL 2 AUTOVECTOR",
52  "LEVEL 3 AUTOVECTOR",
53  "LEVEL 4 AUTOVECTOR",
54  "LEVEL 5 AUTOVECTOR",
55  "LEVEL 6 AUTOVECTOR",
56  "LEVEL 7 AUTOVECTOR",
57  "TRAP 1",
58  "TRAP 2",
59  "TRAP 3",
60  "TRAP 4",
61  "TRAP 5",
62  "TRAP 6",
63  "TRAP 7",
64  "TRAP 8",
65  "TRAP 9",
66  "TRAP 10",
67  "TRAP 11",
68  "TRAP 12",
69  "TRAP 13",
70  "TRAP 14",
71  "TRAP 15",
72  "VECTOR 48",
73  "VECTOR 49",
74  "VECTOR 50",
75  "VECTOR 51",
76  "VECTOR 52",
77  "VECTOR 53",
78  "VECTOR 54",
79  "VECTOR 55",
80  "VECTOR 56",
81  "VECTOR 57",
82  "VECTOR 58",
83  "VECTOR 59",
84  "VECTOR 60",
85  "VECTOR 61",
86  "VECTOR 62",
87  "VECTOR 63",
88  };
89
90typedef struct {
91    unsigned long  pc;
92    unsigned short  sr;
93    unsigned short  format_id;
94    unsigned long  d0, d1, d2, d3, d4, d5, d6, d7;
95    unsigned long  a0, a1, a2, a3, a4, a5, a6, a7;
96    unsigned long  sfc, dfc, vbr;
97} boot_panic_registers_t;
98
99boot_panic_registers_t _boot_panic_registers;
100
101/******************************************************
102  Name: _dbug_dump
103  Input parameters: sr, pc, stack pointer,
104        size to display
105  Output parameters: -
106  Description: display the supervisor stack
107 *****************************************************/
108static void _dbug_dump(
109  unsigned short sr,
110  void* pc,
111  unsigned short *stack,
112  int size
113)
114{
115  int i;
116
117  printk("%x : %x \t%x",0,sr,(unsigned short)(((unsigned)pc)>>16));
118  for (i=2; i<size; i++) {
119    if ((i%8)==0) printk("\n%x :",i/8);
120    printk(" %x\t",stack[i-2]);
121  }
122  printk("\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 *****************************************************/
133void _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    printk("\n---------------------------------------------\n");
150    if (vector<64)
151      printk("%s",exceptionName[vector]);
152    else {
153      printk("RESERVED USER");
154    }
155    printk(" exception (vector %x, type %x)\n",vector,frametype);
156    printk("---------------------------------------------\n");
157    printk("PC : 0x%x  ",pc);
158    printk("A7 : 0x%x  ",_boot_panic_registers.a7);
159    printk("SR : 0x%x\n",status);
160    if (frametype==0x0c) {
161      printk("\nfaulted address = 0x%x\n",faultedAddr);
162    }
163    printk("---------------------------------------------\n");
164    printk("               panic regs\n");
165    printk("---------------------------------------------\n");
166    printk("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    printk("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    printk("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    printk("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    printk("    SFC : %x",_boot_panic_registers.sfc);
180    printk("    DFC : %x\n",_boot_panic_registers.dfc);
181    printk("    VBR : %x\n",_boot_panic_registers.vbr);
182    printk("---------------------------------------------\n");
183    printk("               panic stack\n");
184    printk("---------------------------------------------\n");
185    _dbug_dump(status, pc, (unsigned short*)stack,64*2);
186
187    printk("---------------------------------------------\n");
188    printk("press escape to reboot\n");
189  } while ((c=getchark())!=ESCAPE);
190}
Note: See TracBrowser for help on using the repository browser.