Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

/projects/cubeos/src_current/kernel/e_handle.c

Go to the documentation of this file.
00001 /*  src_experimental/kernel/e_handle.c
00002    CubeOS Version 0.4.90 experimental
00003    Copyright (C) 1999,2000 Holger Kenn
00004 
00005    CubeOS is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or any later version.
00009 
00010    CubeOS is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015  */
00016 #include <stdarg.h>
00017 #include <stdio.h>
00018 #include <cubeos.h>
00019 #include "sys_var.h"
00020 #include <ttyio.h>
00021 
00038 void KERN_exphandler (unsigned long par1, unsigned long par2,...)
00039 {
00040         va_list ap;
00041         char *e_name[36] =
00042         {"UNKNOWN", "BUS ERROR", "ADDRESS ERROR",
00043          "ILLEGAL INSTRUCTION",
00044          "DIVIDE BY ZERO", "CHK, CHK2", "TRAPCCV",
00045          "PRIVILEGE VIOLATION", "TRACE", "UNUSED VECTOR",
00046          "HARDWARE BREAKPOINT", "UNINITIALISED",
00047          "SPURIOUS INTERRUPT", "AUTOVECTOR 1", "AUTOVECTOR 2",
00048          "AUTOVECTOR 3", "AUTOVECTOR 4", "AUTOVECTOR 5",
00049          "AUTOVECTOR 6", "AUTOVECTOR 7",
00050          "TRAP0", "TRAP1", "TRAP2", "TRAP3", "TRAP4", "TRAP5", "TRAP6",
00051          "TRAP7", "TRAP8", "TRAP9", "TRAP10", "TRAP11", "TRAP12",
00052          "TRAP13", "TRAP14", "TRAP15"
00053         };
00054 
00055         unsigned short stat_reg, fmt_vector;
00056         unsigned long prg_ctr;
00057         unsigned int fmt, tmp1, tmp2, ssw;
00058         unsigned int my_errno;
00059 
00060 //        if (_KERN_sys_errorcode==9) return; /* ignore unused vectors */
00061 
00062         asm (" ori.w #0x0700,%sr");     /* disable all further interupts */
00063 
00064         // this will disable clkout, so we are going to get a reset 
00065         // when the watchdog expires. This is done so that even if the
00066         // e_handle fails from here on, we will still get the reset
00067         writeshort (SIM_MCR, readshort (SIM_MCR) | 0x8000);
00068         // in case we want to continue running, the bit in SIM_MCR has to
00069         // be cleared again, i.e.
00070         // writeshort (SIM_MCR, readshort (SIM_MCR) & 0x7fff);
00071         // we have about 500 msec for this decission in the default config.
00072         // that should be plenty...
00073 
00074         TTY_Blocking_Serial_Out = 1;    /* wait until every char is output */
00075         TTY_soutchar('E');
00076         TTY_soutchar('R');
00077         TTY_soutchar('R');
00078         TTY_soutchar('O');
00079         TTY_soutchar('R');
00080         TTY_soutchar('\n');
00081         TTY_soutchar('\r');
00082 
00083         TTY_tty[_TTY_contty].mode=TTY_MODE_TXUNBUF|TTY_MODE_RXBLOCKING|TTY_MODE_TXBLOCKING;
00084         stat_reg = (par1 >> 16);
00085         prg_ctr = (par2 >> 16) | ((par1 & 0xffff) << 16);
00086         fmt_vector = (par2 & 0xffff);
00087 
00088         my_errno = _KERN_sys_errorcode;
00089         if (my_errno > 35)
00090                 my_errno = 0;
00091 
00092         printf ("\r\n*******SYSTEM ERROR********\r\n");
00093         printf ("%s [%d] (vector offset %03x) @ %08lx\n\r", e_name[my_errno], _KERN_sys_errorcode,
00094                 (fmt_vector & 0xfff), prg_ctr);
00095         printf ("Statusregister: %04x\r\n", stat_reg);
00096         printf ("Trace mode: %1d\r\n", ((stat_reg & 0xc000) >> 14));
00097         if (stat_reg & 0x2000)
00098                 printf ("Supervisor mode\r\n");
00099         else
00100                 printf ("User mode\r\n");
00101         printf ("Interrupt priority mask: %1d\r\n", ((stat_reg & 0x700) >> 8));
00102         printf ("Flags: ");
00103         if (stat_reg & 0x10)
00104                 printf ("Extend ");
00105         if (stat_reg & 0x8)
00106                 printf ("Negative ");
00107         if (stat_reg & 0x4)
00108                 printf ("Zero ");
00109         if (stat_reg & 0x2)
00110                 printf ("Overflow ");
00111         if (stat_reg & 0x1)
00112                 printf ("Carry");
00113         printf ("\r\n");
00114 
00115         fmt = (fmt_vector & 0xf000) >> 12;
00116         va_start (ap, par2);
00117 
00118         switch (fmt) {
00119         case (0):
00120                 break;
00121         case (2):
00122                 printf ("Faulted instr PC: %08lx\r\n", va_arg (ap, unsigned long));
00123 
00124                 break;
00125         case (12):
00126                 printf ("Faulted addr. PC: %08lx\r\n", va_arg (ap, unsigned long));
00127                 tmp1 = va_arg (ap, unsigned long);
00128                 tmp2 = va_arg (ap, unsigned long);
00129                 printf ("Microcode rev. no.: %02x\n\r", va_arg (ap, unsigned char));
00130                 printf ("Transfer count: %02x\n\r", va_arg (ap, unsigned char));
00131                 ssw = va_arg (ap, unsigned int);
00132 
00133                 printf ("SSW: ");
00134                 if (ssw & 0x8000)
00135                         printf ("TP ");
00136                 if (ssw & 0x4000)
00137                         printf ("MV ");
00138                 if (ssw & 0x1000)
00139                         printf ("TR ");
00140                 if (ssw & 0x800)
00141                         printf ("B1 ");
00142                 if (ssw & 0x400)
00143                         printf ("B0 ");
00144                 if (ssw & 0x200)
00145                         printf ("RR ");
00146                 if (ssw & 0x100)
00147                         printf ("RM ");
00148                 if (ssw & 0x80)
00149                         printf ("IN ");
00150                 if (ssw & 0x40)
00151                         printf ("RW ");
00152                 if (ssw & 0x20)
00153                         printf ("LG ");
00154                 printf ("SIZ=%1d ", ((ssw & 18) >> 3));
00155                 printf ("FCT=%1d ", (ssw & 7));
00156                 printf ("\r\n");
00157                 if (ssw & 0x8000) {
00158                         printf ("Pre-exception SR: %04x\n\r", (tmp1 >> 16));
00159                         printf ("Faulted exception format/vector: %04x\n\r", (tmp1 & 0xffff));
00160                         printf ("Faulted exception PC: %08x\n\r", tmp2);
00161                 } else {
00162                         printf ("Data Buffer (DBUF): %08x\n\r", tmp1);
00163                         printf ("Current instr. PC: %08x\n\r", tmp2);
00164                 }
00165                 break;
00166         default:
00167                 printf ("Something strange happened: fmt=%2d\n\r", fmt);
00168         }
00169 
00170         printf ("*******SYSTEM HALTED*******\r\n");
00171 
00172         while (1);
00173 }

Generated on Thu Feb 20 15:38:44 2003 for cubeOS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002