source: rtems/c/src/lib/libbsp/i960/rxgen960/startup/flttbl.c @ 8ac4213

4.104.114.84.95
Last change on this file since 8ac4213 was 702c5f5, checked in by Joel Sherrill <joel.sherrill@…>, on 10/27/99 at 15:29:18

The rxgen960 BSP and i960 RPM support was submitted by Mark Bronson
<mark@…> of RAMIX.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*-------------------------------------*/
2/* flttbl.c                            */
3/* Last change :  3.11.94              */
4/*-------------------------------------*/ 
5#include "i960.h"
6#include "string.h"
7#include "sctns.h"
8#include "fault.h"
9#include "asmfault.h"
10#include "flttbl.h"
11/*-------------------------------------*/
12  /* Fault Table. It (as well as all the rest of the
13   * code of this file will always stay in ROM, so
14   * that it wouldn't be destroyed by silly user code.
15   * Thus, at least faults will be always caugth,
16   */
17FaultTblEntry faultTbl[] = {
18  {faultHndlEntry + LOCAL_FH, LOCAL_FW},            /* Parallel */
19  {faultHndlEntry + LOCAL_FH, LOCAL_FW},            /* Trace */
20  {faultHndlEntry + LOCAL_FH, LOCAL_FW},            /* Operation */
21  {faultHndlEntry + LOCAL_FH, LOCAL_FW},            /* Arithmetic */
22  {0, 0},                                                 /* Reserved */
23  {faultHndlEntry + LOCAL_FH, LOCAL_FW},            /* Constraint */
24  {0, 0},                                           /* Reserved */
25  {faultHndlEntry + LOCAL_FH, LOCAL_FW},            /* Protection */
26  {0, 0},                                           /* Reserved */
27  {faultHndlEntry + LOCAL_FH, LOCAL_FW}            /* Type */
28};
29
30void fltTblInit(void)
31{
32  static unsigned int fltTblCheckSum(void);
33
34  faultCheckSum = fltTblCheckSum();
35}
36static unsigned int fltTblCheckSum(void)
37{
38  unsigned int * f = faultStart;
39  unsigned int * l = faultEnd;
40  unsigned int sum;
41 
42  for (sum = 0; f < l; f ++)  {
43    sum += * f;
44  }
45  return sum;
46}
47void faultTblHandler(unsigned int * fp, unsigned int * faultBuffer)
48{
49  unsigned int * ip;
50  struct typeWord {
51    unsigned int sbtp : 8;
52    unsigned int : 8;
53    unsigned int type : 8;
54    unsigned int : 8;
55  } tw;
56  unsigned int type;
57  unsigned int sbtp;
58  unsigned int ac;
59  unsigned int pc;
60  unsigned int inst;
61
62  char nib;
63  unsigned int i;
64
65    /* Address of faulting instruction.
66     */
67  ip = (unsigned int *) fp[-1];
68    /* Type/Subtype word.
69     */
70
71  /* put address of faulting instruction to console */
72  kkprintf("Fault: %x\n", ip);
73 
74  tw = * (struct typeWord *) & fp[-2]; 
75    /* Type and subtype.
76     */
77  type = tw.type;
78  sbtp = tw.sbtp;
79    /* Arithmetic controls.
80     */
81  ac = fp[-3];
82    /* Process controls.
83     */
84  pc = fp[-4];   
85    /* Global and local registers are in faultBuffer
86     * already. Save the rest. Change RIP to IP.
87     */
88  faultBuffer[IP_REGNUM] = (unsigned int) ip;
89  faultBuffer[ACW_REGNUM] = ac;
90  faultBuffer[PCW_REGNUM] = pc; 
91    /* Bad instruction itself. We do
92     * this here since it may be repaired (by copying from PROM).
93     */
94  inst = * ip;
95    /* Now, to handling.
96     */
97  if (faultCheckSum != fltTblCheckSum())  {
98      /* RAM-based fault repair stuff
99       * is broken. No chance to recover.
100       * Repair RAM memory which is
101       * destroyed by silly user.
102       */
103    copyCodeToRom();
104      /* And call RAM-based fault handler.
105       */
106    faultBad(1, inst, faultBuffer, type, sbtp);
107  }
108  else  {
109      /* There exist a chance to recover.
110       */
111    faultGood(inst, faultBuffer, type, sbtp); 
112  }
113}
114/*-------------*/
115/* End of file */
116/*-------------*/
117
Note: See TracBrowser for help on using the repository browser.