OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [i960/] [rxgen960/] [startup/] [flttbl.c] - Blame information for rev 30

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.