Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:45

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  M68340/349 registers and stack dump if an exception is raised
0005  */
0006 
0007 /*
0008  *  Author:
0009  *  Pascal Cadic
0010  *  France Telecom - CNET/DSM/TAM/CAT
0011  *  4, rue du Clos Courtel
0012  *  35512 CESSON-SEVIGNE
0013  *  FRANCE
0014  *
0015  *  COPYRIGHT (c) 1989-1999.
0016  *  On-Line Applications Research Corporation (OAR).
0017  *
0018  * Redistribution and use in source and binary forms, with or without
0019  * modification, are permitted provided that the following conditions
0020  * are met:
0021  * 1. Redistributions of source code must retain the above copyright
0022  *    notice, this list of conditions and the following disclaimer.
0023  * 2. Redistributions in binary form must reproduce the above copyright
0024  *    notice, this list of conditions and the following disclaimer in the
0025  *    documentation and/or other materials provided with the distribution.
0026  *
0027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0037  * POSSIBILITY OF SUCH DAMAGE.
0038  */
0039 
0040 #include <bsp.h>
0041 #include <rtems/bspIo.h>
0042 
0043 const char *exceptionName[] = {
0044   "INITIAL STACK POINTER",
0045   "INITIAL PROGRAM COUNTER",
0046   "BUS ERROR",
0047   "ADDRESS ERROR",
0048   "ILLEGAL INSTRUCTION",
0049   "DIVISION BY ZERO",
0050   "CHK, CHK2",
0051   "TRAPcc, TRAPv",
0052   "PRIVILEGE VIOLATION",
0053   "TRACE",
0054   "LINE A EMULATOR",
0055   "LINE F EMULATOR",
0056   "HARDWARE BREAK",
0057   "COPROCESSOR PROTOCOL VIOLATION",
0058   "FORMAT ERROR",
0059   "UNINITIALIZED INTERRUPT",
0060   "RESERVED 16",
0061   "RESERVED 17",
0062   "RESERVED 18",
0063   "RESERVED 19",
0064   "RESERVED 20",
0065   "RESERVED 21",
0066   "RESERVED 22",
0067   "RESERVED 23",
0068   "SPURIOUS INTERRUPT",
0069   "LEVEL 1 AUTOVECTOR",
0070   "LEVEL 2 AUTOVECTOR",
0071   "LEVEL 3 AUTOVECTOR",
0072   "LEVEL 4 AUTOVECTOR",
0073   "LEVEL 5 AUTOVECTOR",
0074   "LEVEL 6 AUTOVECTOR",
0075   "LEVEL 7 AUTOVECTOR",
0076   "TRAP 1",
0077   "TRAP 2",
0078   "TRAP 3",
0079   "TRAP 4",
0080   "TRAP 5",
0081   "TRAP 6",
0082   "TRAP 7",
0083   "TRAP 8",
0084   "TRAP 9",
0085   "TRAP 10",
0086   "TRAP 11",
0087   "TRAP 12",
0088   "TRAP 13",
0089   "TRAP 14",
0090   "TRAP 15",
0091   "VECTOR 48",
0092   "VECTOR 49",
0093   "VECTOR 50",
0094   "VECTOR 51",
0095   "VECTOR 52",
0096   "VECTOR 53",
0097   "VECTOR 54",
0098   "VECTOR 55",
0099   "VECTOR 56",
0100   "VECTOR 57",
0101   "VECTOR 58",
0102   "VECTOR 59",
0103   "VECTOR 60",
0104   "VECTOR 61",
0105   "VECTOR 62",
0106   "VECTOR 63",
0107   };
0108 
0109 typedef struct {
0110     unsigned long  pc;
0111     unsigned short  sr;
0112     unsigned short  format_id;
0113     unsigned long  d0, d1, d2, d3, d4, d5, d6, d7;
0114     unsigned long  a0, a1, a2, a3, a4, a5, a6, a7;
0115     unsigned long  sfc, dfc, vbr;
0116 } boot_panic_registers_t;
0117 
0118 boot_panic_registers_t _boot_panic_registers;
0119 
0120 /******************************************************
0121   Name: _dbug_dump
0122   Input parameters: sr, pc, stack pointer,
0123         size to display
0124   Output parameters: -
0125   Description: display the supervisor stack
0126  *****************************************************/
0127 static void _dbug_dump(
0128   unsigned short sr,
0129   void* pc,
0130   unsigned short *stack,
0131   int size
0132 )
0133 {
0134   int i;
0135 
0136   printk("%x : %x \t%x",0,sr,(unsigned short)(((unsigned)pc)>>16));
0137   for (i=2; i<size; i++) {
0138     if ((i%8)==0) printk("\n%x :",i/8);
0139     printk(" %x\t",stack[i-2]);
0140   }
0141   printk("\n");
0142 }
0143 
0144 /******************************************************
0145   Name: _dbug_dump
0146   Input parameters: -
0147   Output parameters: -
0148   Description: display microcontroler state. Registers
0149          values are stored in _boot_panic_registers
0150          which is filled in _uhoh ASM routine
0151  *****************************************************/
0152 void _dbug_dumpanic(void)
0153 {
0154  int c;
0155  void *faultedAddr, *pc;
0156  unsigned short vector, status;
0157  unsigned char frametype, *stack;
0158  #define ESCAPE 27
0159 
0160   stack = (unsigned char*)(_boot_panic_registers.a7);
0161   do {
0162     status = _boot_panic_registers.sr;
0163     pc = (void*)_boot_panic_registers.pc;
0164     faultedAddr = *(void**)(stack+4);
0165     vector = (_boot_panic_registers.format_id&0x0FFF)>>2;
0166     frametype = (_boot_panic_registers.format_id&0xF000)>>12;
0167 
0168     printk("\n---------------------------------------------\n");
0169     if (vector<64)
0170       printk("%s",exceptionName[vector]);
0171     else {
0172       printk("RESERVED USER");
0173     }
0174     printk(" exception (vector %x, type %x)\n",vector,frametype);
0175     printk("---------------------------------------------\n");
0176     printk("PC : %p  ",pc);
0177     printk("A7 : 0x%lx  ",_boot_panic_registers.a7);
0178     printk("SR : 0x%x\n",status);
0179     if (frametype==0x0c) {
0180       printk("\nfaulted address = %p\n",faultedAddr);
0181     }
0182     printk("---------------------------------------------\n");
0183     printk("               panic regs\n");
0184     printk("---------------------------------------------\n");
0185     printk("D[0..3] : %lx \t%lx \t%lx \t%lx\n",
0186         _boot_panic_registers.d0,_boot_panic_registers.d1,
0187         _boot_panic_registers.d2,_boot_panic_registers.d3);
0188     printk("D[4..7] : %lx \t%lx \t%lx \t%lx\n",
0189         _boot_panic_registers.d4,_boot_panic_registers.d5,
0190         _boot_panic_registers.d6,_boot_panic_registers.d7);
0191     printk("A[0..3] : %lx \t%lx \t%lx \t%lx\n",
0192         _boot_panic_registers.a0,_boot_panic_registers.a1,
0193         _boot_panic_registers.a2,_boot_panic_registers.a3);
0194     printk("A[4..7] : %lx \t%lx \t%lx \t%lx\n",
0195         _boot_panic_registers.a4,_boot_panic_registers.a5,
0196         _boot_panic_registers.a6,_boot_panic_registers.a7);
0197 
0198     printk("    SFC : %lx",_boot_panic_registers.sfc);
0199     printk("    DFC : %lx\n",_boot_panic_registers.dfc);
0200     printk("    VBR : %lx\n",_boot_panic_registers.vbr);
0201     printk("---------------------------------------------\n");
0202     printk("               panic stack\n");
0203     printk("---------------------------------------------\n");
0204     _dbug_dump(status, pc, (unsigned short*)stack,64*2);
0205 
0206     printk("---------------------------------------------\n");
0207     printk("press escape to reboot\n");
0208   } while ((c=getchark())!=ESCAPE);
0209 }