faults.cc revision 2201
113521Sgabeblack@google.com/*
213521Sgabeblack@google.com * Copyright (c) 2003-2005 The Regents of The University of Michigan
313521Sgabeblack@google.com * All rights reserved.
413521Sgabeblack@google.com *
513521Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
613521Sgabeblack@google.com * modification, are permitted provided that the following conditions are
713521Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
813521Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
913521Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1013521Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1113521Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1213521Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1313521Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1413521Sgabeblack@google.com * this software without specific prior written permission.
1513521Sgabeblack@google.com *
1613521Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1713521Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1813521Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1913521Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2013521Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2113521Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2213521Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2313586Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2413586Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2513521Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2613521Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2713521Sgabeblack@google.com */
2813521Sgabeblack@google.com
2913521Sgabeblack@google.com#include "arch/alpha/faults.hh"
3013521Sgabeblack@google.com#include "cpu/exec_context.hh"
3113521Sgabeblack@google.com#include "cpu/base.hh"
3213521Sgabeblack@google.com#include "base/trace.hh"
3313521Sgabeblack@google.com#include "kern/kernel_stats.hh"
3413521Sgabeblack@google.com
3513521Sgabeblack@google.comnamespace AlphaISA
3613521Sgabeblack@google.com{
3713521Sgabeblack@google.com
3813521Sgabeblack@google.comFaultVect AlphaMachineCheckFault::_vect = 0x0401;
3913521Sgabeblack@google.comFaultStat AlphaMachineCheckFault::_stat;
4013521Sgabeblack@google.com
4113521Sgabeblack@google.comFaultVect AlphaAlignmentFault::_vect = 0x0301;
4213521Sgabeblack@google.comFaultStat AlphaAlignmentFault::_stat;
4313521Sgabeblack@google.com
4413521Sgabeblack@google.comFaultName ResetFault::_name = "reset";
4513521Sgabeblack@google.comFaultVect ResetFault::_vect = 0x0001;
4613521Sgabeblack@google.comFaultStat ResetFault::_stat;
4713521Sgabeblack@google.com
4813521Sgabeblack@google.comFaultName ArithmeticFault::_name = "arith";
4913521Sgabeblack@google.comFaultVect ArithmeticFault::_vect = 0x0501;
5013521Sgabeblack@google.comFaultStat ArithmeticFault::_stat;
5113521Sgabeblack@google.com
5213521Sgabeblack@google.comFaultName InterruptFault::_name = "interrupt";
5313521Sgabeblack@google.comFaultVect InterruptFault::_vect = 0x0101;
5413521Sgabeblack@google.comFaultStat InterruptFault::_stat;
5513521Sgabeblack@google.com
5613521Sgabeblack@google.comFaultName NDtbMissFault::_name = "dtb_miss_single";
5713521Sgabeblack@google.comFaultVect NDtbMissFault::_vect = 0x0201;
5813521Sgabeblack@google.comFaultStat NDtbMissFault::_stat;
5913521Sgabeblack@google.com
6013521Sgabeblack@google.comFaultName PDtbMissFault::_name = "dtb_miss_double";
6113521Sgabeblack@google.comFaultVect PDtbMissFault::_vect = 0x0281;
6213521Sgabeblack@google.comFaultStat PDtbMissFault::_stat;
6313521Sgabeblack@google.com
6413521Sgabeblack@google.comFaultName DtbPageFault::_name = "dfault";
6513521Sgabeblack@google.comFaultVect DtbPageFault::_vect = 0x0381;
6613521Sgabeblack@google.comFaultStat DtbPageFault::_stat;
6713521Sgabeblack@google.com
6813521Sgabeblack@google.comFaultName DtbAcvFault::_name = "dfault";
6913521Sgabeblack@google.comFaultVect DtbAcvFault::_vect = 0x0381;
7013521Sgabeblack@google.comFaultStat DtbAcvFault::_stat;
7113521Sgabeblack@google.com
7213521Sgabeblack@google.comFaultName ItbMissFault::_name = "itbmiss";
7313521Sgabeblack@google.comFaultVect ItbMissFault::_vect = 0x0181;
7413521Sgabeblack@google.comFaultStat ItbMissFault::_stat;
7513521Sgabeblack@google.com
7613521Sgabeblack@google.comFaultName ItbPageFault::_name = "itbmiss";
7713521Sgabeblack@google.comFaultVect ItbPageFault::_vect = 0x0181;
7813521Sgabeblack@google.comFaultStat ItbPageFault::_stat;
7913521Sgabeblack@google.com
8013521Sgabeblack@google.comFaultName ItbAcvFault::_name = "iaccvio";
8113521Sgabeblack@google.comFaultVect ItbAcvFault::_vect = 0x0081;
8213521Sgabeblack@google.comFaultStat ItbAcvFault::_stat;
8313521Sgabeblack@google.com
8413521Sgabeblack@google.comFaultName UnimplementedOpcodeFault::_name = "opdec";
8513521Sgabeblack@google.comFaultVect UnimplementedOpcodeFault::_vect = 0x0481;
8613521Sgabeblack@google.comFaultStat UnimplementedOpcodeFault::_stat;
8713521Sgabeblack@google.com
8813521Sgabeblack@google.comFaultName FloatEnableFault::_name = "fen";
89FaultVect FloatEnableFault::_vect = 0x0581;
90FaultStat FloatEnableFault::_stat;
91
92FaultName PalFault::_name = "pal";
93FaultVect PalFault::_vect = 0x2001;
94FaultStat PalFault::_stat;
95
96FaultName IntegerOverflowFault::_name = "intover";
97FaultVect IntegerOverflowFault::_vect = 0x0501;
98FaultStat IntegerOverflowFault::_stat;
99
100#if FULL_SYSTEM
101
102void AlphaFault::invoke(ExecContext * xc)
103{
104    DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), xc->regs.pc);
105    xc->cpu->recordEvent(csprintf("Fault %s", name()));
106
107    assert(!xc->misspeculating());
108    xc->kernelStats->fault(this);
109
110    // exception restart address
111    if (setRestartAddress() || !xc->inPalMode())
112        xc->setMiscReg(AlphaISA::IPR_EXC_ADDR, xc->regs.pc);
113
114    if (skipFaultingInstruction()) {
115        // traps...  skip faulting instruction.
116        xc->setMiscReg(AlphaISA::IPR_EXC_ADDR,
117                   xc->readMiscReg(AlphaISA::IPR_EXC_ADDR) + 4);
118    }
119
120    if (!xc->inPalMode())
121        AlphaISA::swap_palshadow(&(xc->regs), true);
122
123    xc->regs.pc = xc->readMiscReg(AlphaISA::IPR_PAL_BASE) + vect();
124    xc->regs.npc = xc->regs.pc + sizeof(MachInst);
125}
126
127void ArithmeticFault::invoke(ExecContext * xc)
128{
129    DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), xc->regs.pc);
130    xc->cpu->recordEvent(csprintf("Fault %s", name()));
131
132    assert(!xc->misspeculating());
133    xc->kernelStats->fault(this);
134
135    panic("Arithmetic traps are unimplemented!");
136}
137
138
139/*void ArithmeticFault::invoke(ExecContext * xc)
140{
141    panic("Arithmetic traps are unimplemented!");
142}*/
143
144#endif
145
146} // namespace AlphaISA
147
148/*Fault * ListOfFaults[] = {
149        (Fault *)&NoFault,
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,
164        (Fault *)&PalFault,
165        (Fault *)&IntegerOverflowFault,
166        };
167
168int NumFaults = sizeof(ListOfFaults) / sizeof(Fault *);*/
169