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

4.115
Last change on this file since cfaa366 was cfaa366, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 17:55:58

General - Remove extraneous blank line in license message

Many files had an extra blank line in the license text
found in the file header. This patch removes that line.

The script that did this also turned off execute permission
when it was turned on incorrectly.

  • 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 *  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-1999.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#include <stdio.h>
22
23const char *exceptionName[] =
24        {
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
101extern void RAW_FMT( int minor, const char* fmt, ... );
102extern char RAW_GETC(int minor);
103
104/******************************************************
105  Name: _dbug_dump
106  Input parameters: sr, pc, stack pointer,
107                    size to display
108  Output parameters: -
109  Description: display the supervisor stack
110 *****************************************************/
111void _dbug_dump(unsigned short sr, void* pc, unsigned short *stack, int size)
112{
113int i;
114
115        RAW_FMT(0,"%x : %x \t%x",0,sr,(unsigned short)(((unsigned)pc)>>16));
116        for (i=2; i<size; i++) {
117                if ((i%8)==0) RAW_FMT(0,"\n%x :",i/8);
118                RAW_FMT(0," %x\t",stack[i-2]);
119        }
120        RAW_FMT(0,"\n");
121}
122
123/******************************************************
124  Name: _dbug_dump
125  Input parameters: -
126  Output parameters: -
127  Description: display microcontroler state. Registers
128               values are stored in _boot_panic_registers
129               which is filled in _uhoh ASM routine
130 *****************************************************/
131void _dbug_dumpanic(void)
132{
133 int c;
134 void *faultedAddr, *pc;
135 unsigned short vector, status;
136 unsigned char frametype, *stack;
137 #define ESCAPE 27
138
139        stack = (unsigned char*)(_boot_panic_registers.a7);
140        do {
141                status = _boot_panic_registers.sr;
142                pc = (void*)_boot_panic_registers.pc;
143                faultedAddr = *(void**)(stack+4);
144                vector = (_boot_panic_registers.format_id&0x0FFF)>>2;
145                frametype = (_boot_panic_registers.format_id&0xF000)>>12;
146
147                RAW_FMT(0,"\n---------------------------------------------\n");
148                if (vector<64)
149                        RAW_FMT(0,"%s",exceptionName[vector]);
150                else {
151                        RAW_FMT(0,"RESERVED USER");
152                }
153                RAW_FMT(0," exception (vector %x, type %x)\n",vector,frametype);
154                RAW_FMT(0,"---------------------------------------------\n");
155                RAW_FMT(0,"PC : 0x%x  ",pc);
156                RAW_FMT(0,"A7 : 0x%x  ",_boot_panic_registers.a7);
157                RAW_FMT(0,"SR : 0x%x\n",status);
158                if (frametype==0x0c) {
159                        RAW_FMT(0,"\nfaulted address = 0x%x\n",faultedAddr);
160                }
161                RAW_FMT(0,"---------------------------------------------\n");
162                RAW_FMT(0,"               panic regs\n");
163                RAW_FMT(0,"---------------------------------------------\n");
164                RAW_FMT(0,"D[0..3] : %x \t%x \t%x \t%x\n",
165                                _boot_panic_registers.d0,_boot_panic_registers.d1,
166                                _boot_panic_registers.d2,_boot_panic_registers.d3);
167                RAW_FMT(0,"D[4..7] : %x \t%x \t%x \t%x\n",
168                                _boot_panic_registers.d4,_boot_panic_registers.d5,
169                                _boot_panic_registers.d6,_boot_panic_registers.d7);
170                RAW_FMT(0,"A[0..3] : %x \t%x \t%x \t%x\n",
171                                _boot_panic_registers.a0,_boot_panic_registers.a1,
172                                _boot_panic_registers.a2,_boot_panic_registers.a3);
173                RAW_FMT(0,"A[4..7] : %x \t%x \t%x \t%x\n",
174                                _boot_panic_registers.a4,_boot_panic_registers.a5,
175                                _boot_panic_registers.a6,_boot_panic_registers.a7);
176
177                RAW_FMT(0,"    SFC : %x",_boot_panic_registers.sfc);
178                RAW_FMT(0,"    DFC : %x\n",_boot_panic_registers.dfc);
179                RAW_FMT(0,"    VBR : %x\n",_boot_panic_registers.vbr);
180                RAW_FMT(0,"---------------------------------------------\n");
181                RAW_FMT(0,"               panic stack\n");
182                RAW_FMT(0,"---------------------------------------------\n");
183                _dbug_dump(status, pc, (unsigned short*)stack,64*2);
184
185                RAW_FMT(0,"---------------------------------------------\n");
186                RAW_FMT(0,"press escape to reboot\n");
187        } while ((c=RAW_GETC(0))!=ESCAPE);      /* cgets ne marche pas si les IT sont bloquées */
188}
Note: See TracBrowser for help on using the repository browser.