📄 excarchlib.c
字号:
/* excArchLib.c - mc680x0 exception handling facilities *//* Copyright 1984-1994 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------03n,10aug98,pr removed ifdef WV_INSTRUMENTATION comment for header file03m,16dec96,map skip vector 59 on MC68000 for EN302 [SPR# 7552]03l,12jul96,jmb Installed Thierry's patch for TAS on MC68060 (SPR #4552)03k,08jul96,sbs made windview instrumentation conditionally compiled03j,21jun96,ms folded in patch for SPR 2650 (excTasRetry wrong for 680[0|1]0)03i,23may96,ms fixed SPR 6240 (reseting pTaskLastFpTcb busted nested exc's).03h,23jun95,ms excExcHandle saves fpp in pTaskLastFpTcb, not taskIdCurrent03g,30may94,tpr added MC68060 cpu support.03i,10nov94,dvs changed fppLastTcb to pTaskLastFpTcb to deal with merge of SPR 3033 with SPR 106003h,26oct94,tmk added MC68LC040 support03g,14oct94,ism merged customer support patch for SPR#1060.03f,23oct93,jcf eliminated MC68882 coprocessor violations.03h,28jan94,smb added instrumentation for excIntHandle03h,24jan94,smb added instrumentation macros03g,10dec93,smb added instrumentation support for windview03f,26aug93,jcf re-added CPU32 support.03e,19oct92,jcf swapped 5.0/excInfoShow hook order.03d,01oct92,jcf added reboot if exception before kernel.03c,31aug92,rrr changed code passed to sigExcKill to be vector number.03b,23aug92,jcf changed name. added format $4 for 68EC040 handler.03a,02aug92,jcf overhauled. excJobAdd avoided, reworked hooks.02y,30jul92,rrr backed out 1g (now back to 1f)02x,30jul92,kdl backed out 01f changes pending rest of exc handling.02w,29jul92,rrr pass one of exc of split02v,09jul92,rrr changed xsignal.h to private/sigLibP.h02u,26may92,rrr the tree shuffle02t,30apr92,rrr some preparation for posix signals.02s,21apr92,rrr fixed number of args to printExc for 68000 version02r,27jan92,yao removed architecture independent routines excInit(), excTask(), excHookAdd(), excJobAdd(), printExc(), excDeliverSignal(). added excFaultTab [].02q,20jan92,jcf use vxMemProbe() to handle writebacks in case of berr. rewrote handling of ESF 7 of 68040.02p,24oct91,rfs fixed spelling error in exception message02o,17oct91,yao minor documentation cleanup.02n,04oct91,rrr passed through the ansification filter -changed functions to ansi style -changed includes to have absolute path from h/ -fixed #else and #endif -changed READ, WRITE and UPDATE to O_RDONLY O_WRONLY O_RDWR -changed VOID to void -changed copyright notice02m,25sep91,yao added support for CPU32.02l,28aup91,shl added handling of ESF3 and ESF7 of MC68040.02k,30apr91,jdi documentation tweaks.02j,05apr91,jdi documentation -- removed header parens and x-ref numbers; doc review by dnw.02i,04feb91,jaa documentation cleanup.Deleted pre 91 modification history -- See RCS*//*This module contains MC680X0 architecture dependent portions of theexception handling facilities. See excLib for the portions that arearchitecture independent.SEE ALSO: dbgLib, sigLib, intLib, "Debugging"*/#include "vxWorks.h"#include "esf.h"#include "iv.h"#include "sysLib.h"#include "intLib.h"#include "taskLib.h"#include "qLib.h"#include "errno.h"#include "string.h"#include "fppLib.h"#include "vxLib.h"#include "logLib.h"#include "rebootLib.h"#include "private/funcBindP.h"#include "private/kernelLibP.h"#include "private/taskLibP.h"#include "private/sigLibP.h"#include "private/eventP.h"#if (CPU==MC68060)#include "math/isp060Lib.h"#endif /* (CPU==MC68060 *//* local variables */LOCAL int excTasErrors; /* count of TAS bus errors - just curiosity *//* forward static functions */LOCAL BOOL excTasRetry (int vecNum, ESF0 *pEsf, REG_SET *pRegs);LOCAL void excGetInfoFromESF (int vecNum, ESF0 *pEsf, REG_SET *pRegs, EXC_INFO *pExcInfo);/********************************************************************************* excVecInit - initialize the exception/interrupt vectors** This routine sets all exception vectors to point to the appropriate* default exception handlers. These handlers will safely trap and report* exceptions caused by program errors or unexpected hardware interrupts.* All vectors from vector 2 (address 0x0008) to 255 (address 0x03fc) are* initialized. Vectors 0 and 1 contain the reset stack pointer and program* counter.** WHEN TO CALL* This routine is usually called from the system start-up routine* usrInit() in usrConfig, before interrupts are enabled.** RETURNS: OK (always).*/STATUS excVecInit (void) { FAST int vecNum; /* make exception vectors point to proper place in bsr table */#if (CPU==MC68000) for (vecNum = LOW_VEC; vecNum < 59; ++vecNum) intVecSet (INUM_TO_IVEC (vecNum), (FUNCPTR) &excBsrTbl[vecNum]); /* skip vectors 59 - 63 so we don't clobber MC68[EN]302 internal regs */ for (vecNum = 64; vecNum <= HIGH_VEC; ++vecNum) intVecSet (INUM_TO_IVEC (vecNum), (FUNCPTR) &excBsrTbl[vecNum]);#else /* (CPU==MC680[12346]0 || CPU==CPU32) */ for (vecNum = LOW_VEC; vecNum <= HIGH_VEC; ++vecNum) { if (((BUS_ERROR_VEC <= vecNum) && (vecNum <= FORMAT_ERROR)) || ((TRAP_0_VEC <= vecNum ) && (vecNum < USER_VEC_START))) intVecSet ((FUNCPTR *)INUM_TO_IVEC (vecNum), (FUNCPTR)excStub); else intVecSet ((FUNCPTR *)INUM_TO_IVEC (vecNum), (FUNCPTR)excIntStub); }#if (CPU==MC68060) /* * initialize the call out table used by the unimplemented integer * instruction library */ isp060COTblInit(); /* connect the umimplemented integer instruction exception handler */ intVecSet ((FUNCPTR *) IV_UNIMP_INTEGER_INSTRUCTION, (FUNCPTR) (ISP_060_UNIMP));#endif /* (CPU==MC68060) */#endif /* (CPU==MC680[12346]0 || CPU==CPU32) */ return (OK); }/********************************************************************************* excExcHandle - interrupt level handling of exceptions** This routine handles exception traps. It is never to be called except* from the special assembly language interrupt stub routine.** It prints out a bunch of pertinent information about the trap that* occurred via excTask.** Note that this routine runs in the context of the task that got the exception.** NOMANUAL*/void excExcHandle ( int vecNum, /* exception vector number */ ESF0 * pEsf, /* pointer to exception stack frame */ REG_SET * pRegs /* pointer to register info on stack */ ) { EXC_INFO excInfo; /* * save the floating point state here to avoid doing it in * the swap hook. The MC68882 requires an FSAVE to be executed * early in an exception handler. */ if (pTaskLastFpTcb != NULL) fppSave (pTaskLastFpTcb->pFpContext); excGetInfoFromESF (vecNum, pEsf, pRegs, &excInfo); /* fill excInfo/pRegs */ if ((_func_excBaseHook != NULL) && /* user hook around? */ ((* _func_excBaseHook) (vecNum, pEsf, pRegs, &excInfo))) return; /* user hook fixed it */ if (excTasRetry (vecNum, pEsf, pRegs)) return; /* retry the TAS */#ifdef WV_INSTRUMENTATION /* windview - level 3 event logging */ EVT_CTX_1(EVENT_EXCEPTION, vecNum);#endif /* if exception occured in an isr or before multi tasking then reboot */ if ((INT_CONTEXT ()) || (Q_FIRST (&activeQHead) == NULL)) { if (_func_excPanicHook != NULL) /* panic hook? */ (*_func_excPanicHook) (vecNum, pEsf, pRegs, &excInfo); reboot (BOOT_WARM_AUTOBOOT); return; /* reboot returns?! */ } /* task caused exception */ taskIdCurrent->pExcRegSet = pRegs; /* for taskRegs[GS]et */ taskIdDefault ((int)taskIdCurrent); /* update default tid */ bcopy ((char *) &excInfo, (char *) &(taskIdCurrent->excInfo), sizeof (EXC_INFO)); /* copy in exc info */ if (_func_sigExcKill != NULL) /* signals installed? */ (*_func_sigExcKill) (vecNum, INUM_TO_IVEC(vecNum), pRegs); if (_func_excInfoShow != NULL) /* default show rtn? */ (*_func_excInfoShow) (&excInfo, TRUE); if (excExcepHook != NULL) /* 5.0.2 hook? */ (* excExcepHook) (taskIdCurrent, vecNum, pEsf); taskSuspend (0); /* whoa partner... */ taskIdCurrent->pExcRegSet = (REG_SET *) NULL; /* invalid after rts */ }/********************************************************************************* excIntHandle - interrupt level handling of interrupts** This routine handles interrupts. It is never to be called except* from the special assembly language interrupt stub routine.** It prints out a bunch of pertinent information about the trap that* occurred via excTask().** NOMANUAL*/void excIntHandle ( int vecNum, /* exception vector number */ ESF0 * pEsf, /* pointer to exception stack frame */ REG_SET * pRegs /* pointer to register info on stack */ ) { EXC_INFO excInfo; excGetInfoFromESF (vecNum, pEsf, pRegs, &excInfo); /* fill excInfo/pRegs */ #ifdef WV_INSTRUMENTATION /* windview - level 3 event logging */ EVT_CTX_1(EVENT_EXCEPTION, vecNum);#endif if (_func_excIntHook != NULL) (*_func_excIntHook) (vecNum, pEsf, pRegs, &excInfo); if (Q_FIRST (&activeQHead) == NULL) /* pre kernel */ reboot (BOOT_WARM_AUTOBOOT); /* better reboot */ }/******************************************************************************* excGetInfoFromESF - get relevent info from exception stack frame**/LOCAL void excGetInfoFromESF ( FAST int vecNum, /* vector number */ FAST ESF0 * pEsf, /* pointer to exception stack frame */ REG_SET * pRegs, /* pointer to register info on stack */ EXC_INFO * pExcInfo /* where to fill in exception info */ ) { int size; pExcInfo->vecNum = vecNum; pExcInfo->valid = EXC_VEC_NUM;#if (CPU==MC68000) if ((vecNum == BUS_ERROR_VEC) || (vecNum == ADRS_ERROR_VEC)) { /* Its an address or bus error */ pExcInfo->valid |= EXC_PC | EXC_STATUS_REG | EXC_ACCESS_ADDR | EXC_FUNC_CODE | EXC_INSTR_REG; pExcInfo->pc = ((ESF68K_BA *)pEsf)->pc; pExcInfo->statusReg = ((ESF68K_BA *)pEsf)->sr; pExcInfo->accessAddr = ((ESF68K_BA *)pEsf)->aa; pExcInfo->funcCode = ((ESF68K_BA *)pEsf)->fn;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -