2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "arch/alpha/faults.hh"
30 #include "cpu/exec_context.hh"
31 #include "cpu/base.hh"
32 #include "base/trace.hh"
33 #include "kern/kernel_stats.hh"
38 FaultVect
AlphaMachineCheckFault::_vect
= 0x0401;
39 FaultStat
AlphaMachineCheckFault::_stat
;
41 FaultVect
AlphaAlignmentFault::_vect
= 0x0301;
42 FaultStat
AlphaAlignmentFault::_stat
;
44 FaultName
ResetFault::_name
= "reset";
45 FaultVect
ResetFault::_vect
= 0x0001;
46 FaultStat
ResetFault::_stat
;
48 FaultName
ArithmeticFault::_name
= "arith";
49 FaultVect
ArithmeticFault::_vect
= 0x0501;
50 FaultStat
ArithmeticFault::_stat
;
52 FaultName
InterruptFault::_name
= "interrupt";
53 FaultVect
InterruptFault::_vect
= 0x0101;
54 FaultStat
InterruptFault::_stat
;
56 FaultName
NDtbMissFault::_name
= "dtb_miss_single";
57 FaultVect
NDtbMissFault::_vect
= 0x0201;
58 FaultStat
NDtbMissFault::_stat
;
60 FaultName
PDtbMissFault::_name
= "dtb_miss_double";
61 FaultVect
PDtbMissFault::_vect
= 0x0281;
62 FaultStat
PDtbMissFault::_stat
;
64 FaultName
DtbPageFault::_name
= "dfault";
65 FaultVect
DtbPageFault::_vect
= 0x0381;
66 FaultStat
DtbPageFault::_stat
;
68 FaultName
DtbAcvFault::_name
= "dfault";
69 FaultVect
DtbAcvFault::_vect
= 0x0381;
70 FaultStat
DtbAcvFault::_stat
;
72 FaultName
ItbMissFault::_name
= "itbmiss";
73 FaultVect
ItbMissFault::_vect
= 0x0181;
74 FaultStat
ItbMissFault::_stat
;
76 FaultName
ItbPageFault::_name
= "itbmiss";
77 FaultVect
ItbPageFault::_vect
= 0x0181;
78 FaultStat
ItbPageFault::_stat
;
80 FaultName
ItbAcvFault::_name
= "iaccvio";
81 FaultVect
ItbAcvFault::_vect
= 0x0081;
82 FaultStat
ItbAcvFault::_stat
;
84 FaultName
UnimplementedOpcodeFault::_name
= "opdec";
85 FaultVect
UnimplementedOpcodeFault::_vect
= 0x0481;
86 FaultStat
UnimplementedOpcodeFault::_stat
;
88 FaultName
FloatEnableFault::_name
= "fen";
89 FaultVect
FloatEnableFault::_vect
= 0x0581;
90 FaultStat
FloatEnableFault::_stat
;
92 FaultName
PalFault::_name
= "pal";
93 FaultVect
PalFault::_vect
= 0x2001;
94 FaultStat
PalFault::_stat
;
96 FaultName
IntegerOverflowFault::_name
= "intover";
97 FaultVect
IntegerOverflowFault::_vect
= 0x0501;
98 FaultStat
IntegerOverflowFault::_stat
;
102 void AlphaFault::invoke(ExecContext
* xc
)
104 DPRINTF(Fault
, "Fault %s at PC: %#x\n", name(), xc
->regs
.pc
);
105 xc
->cpu
->recordEvent(csprintf("Fault %s", name()));
107 assert(!xc
->misspeculating());
108 xc
->kernelStats
->fault(this);
110 // exception restart address
111 if (setRestartAddress() || !xc
->inPalMode())
112 xc
->setMiscReg(AlphaISA::IPR_EXC_ADDR
, xc
->regs
.pc
);
114 if (skipFaultingInstruction()) {
115 // traps... skip faulting instruction.
116 xc
->setMiscReg(AlphaISA::IPR_EXC_ADDR
,
117 xc
->readMiscReg(AlphaISA::IPR_EXC_ADDR
) + 4);
120 if (!xc
->inPalMode())
121 AlphaISA::swap_palshadow(&(xc
->regs
), true);
123 xc
->regs
.pc
= xc
->readMiscReg(AlphaISA::IPR_PAL_BASE
) + vect();
124 xc
->regs
.npc
= xc
->regs
.pc
+ sizeof(MachInst
);
127 void ArithmeticFault::invoke(ExecContext
* xc
)
129 DPRINTF(Fault
, "Fault %s at PC: %#x\n", name(), xc
->regs
.pc
);
130 xc
->cpu
->recordEvent(csprintf("Fault %s", name()));
132 assert(!xc
->misspeculating());
133 xc
->kernelStats
->fault(this);
135 panic("Arithmetic traps are unimplemented!");
139 /*void ArithmeticFault::invoke(ExecContext * xc)
141 panic("Arithmetic traps are unimplemented!");
146 } // namespace AlphaISA
148 /*Fault * ListOfFaults[] = {
150 (Fault *)&ResetFault,
151 (Fault *)&MachineCheckFault,
152 (Fault *)&ArithmeticFault,
153 (Fault *)&InterruptFault,
154 (Fault *)&NDtbMissFault,
155 (Fault *)&PDtbMissFault,
156 (Fault *)&AlignmentFault,
157 (Fault *)&DtbPageFault,
158 (Fault *)&DtbAcvFault,
159 (Fault *)&ItbMissFault,
160 (Fault *)&ItbPageFault,
161 (Fault *)&ItbAcvFault,
162 (Fault *)&UnimplementedOpcodeFault,
163 (Fault *)&FloatEnableFault,
165 (Fault *)&IntegerOverflowFault,
168 int NumFaults = sizeof(ListOfFaults) / sizeof(Fault *);*/