faults.cc revision 2221
12810SN/A/*
212501Snikos.nikoleris@arm.com * Copyright (c) 2003-2005 The Regents of The University of Michigan
39663Suri.wiener@arm.com * All rights reserved.
49663Suri.wiener@arm.com *
59663Suri.wiener@arm.com * Redistribution and use in source and binary forms, with or without
69663Suri.wiener@arm.com * modification, are permitted provided that the following conditions are
79663Suri.wiener@arm.com * met: redistributions of source code must retain the above copyright
89663Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer;
99663Suri.wiener@arm.com * redistributions in binary form must reproduce the above copyright
109663Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer in the
119663Suri.wiener@arm.com * documentation and/or other materials provided with the distribution;
129663Suri.wiener@arm.com * neither the name of the copyright holders nor the names of its
139663Suri.wiener@arm.com * contributors may be used to endorse or promote products derived from
142810SN/A * this software without specific prior written permission.
157636Ssteve.reinhardt@amd.com *
162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272810SN/A */
282810SN/A
292810SN/A#include "arch/alpha/faults.hh"
302810SN/A#include "cpu/exec_context.hh"
312810SN/A#include "cpu/base.hh"
322810SN/A#include "base/trace.hh"
332810SN/A#include "kern/kernel_stats.hh"
342810SN/A
352810SN/Anamespace AlphaISA
362810SN/A{
372810SN/A
382810SN/AFaultName MachineCheckFault::_name = "mchk";
392810SN/AFaultVect MachineCheckFault::_vect = 0x0401;
402810SN/AFaultStat MachineCheckFault::_stat;
412810SN/A
422810SN/AFaultName AlignmentFault::_name = "unalign";
432810SN/AFaultVect AlignmentFault::_vect = 0x0301;
442810SN/AFaultStat AlignmentFault::_stat;
452810SN/A
462810SN/AFaultName ResetFault::_name = "reset";
472810SN/AFaultVect ResetFault::_vect = 0x0001;
482810SN/AFaultStat ResetFault::_stat;
492810SN/A
5011486Snikos.nikoleris@arm.comFaultName ArithmeticFault::_name = "arith";
5111486Snikos.nikoleris@arm.comFaultVect ArithmeticFault::_vect = 0x0501;
526216Snate@binkert.orgFaultStat ArithmeticFault::_stat;
532810SN/A
542810SN/AFaultName InterruptFault::_name = "interrupt";
5512334Sgabeblack@google.comFaultVect InterruptFault::_vect = 0x0101;
5612727Snikos.nikoleris@arm.comFaultStat InterruptFault::_stat;
576216Snate@binkert.org
588232Snate@binkert.orgFaultName NDtbMissFault::_name = "dtb_miss_single";
5912727Snikos.nikoleris@arm.comFaultVect NDtbMissFault::_vect = 0x0201;
6012727Snikos.nikoleris@arm.comFaultStat NDtbMissFault::_stat;
616216Snate@binkert.org
622810SN/AFaultName PDtbMissFault::_name = "dtb_miss_double";
6311375Sandreas.hansson@arm.comFaultVect PDtbMissFault::_vect = 0x0281;
6411284Sandreas.hansson@arm.comFaultStat PDtbMissFault::_stat;
6510503SCurtis.Dunham@arm.com
6611741Snikos.nikoleris@arm.comFaultName DtbPageFault::_name = "dfault";
672810SN/AFaultVect DtbPageFault::_vect = 0x0381;
682810SN/AFaultStat DtbPageFault::_stat;
692810SN/A
704903SN/AFaultName DtbAcvFault::_name = "dfault";
7112715Snikos.nikoleris@arm.comFaultVect DtbAcvFault::_vect = 0x0381;
7212715Snikos.nikoleris@arm.comFaultStat DtbAcvFault::_stat;
734903SN/A
744903SN/AFaultName ItbMissFault::_name = "itbmiss";
754903SN/AFaultVect ItbMissFault::_vect = 0x0181;
7611740Snikos.nikoleris@arm.comFaultStat ItbMissFault::_stat;
7711741Snikos.nikoleris@arm.com
7811741Snikos.nikoleris@arm.comFaultName ItbPageFault::_name = "itbmiss";
794903SN/AFaultVect ItbPageFault::_vect = 0x0181;
805875Ssteve.reinhardt@amd.comFaultStat ItbPageFault::_stat;
8111284Sandreas.hansson@arm.com
8211284Sandreas.hansson@arm.comFaultName ItbAcvFault::_name = "iaccvio";
834903SN/AFaultVect ItbAcvFault::_vect = 0x0081;
844903SN/AFaultStat ItbAcvFault::_stat;
857669Ssteve.reinhardt@amd.com
867669Ssteve.reinhardt@amd.comFaultName UnimplementedOpcodeFault::_name = "opdec";
877669Ssteve.reinhardt@amd.comFaultVect UnimplementedOpcodeFault::_vect = 0x0481;
887669Ssteve.reinhardt@amd.comFaultStat UnimplementedOpcodeFault::_stat;
894903SN/A
904903SN/AFaultName FloatEnableFault::_name = "fen";
9111741Snikos.nikoleris@arm.comFaultVect FloatEnableFault::_vect = 0x0581;
9211741Snikos.nikoleris@arm.comFaultStat FloatEnableFault::_stat;
9311741Snikos.nikoleris@arm.com
9411741Snikos.nikoleris@arm.comFaultName PalFault::_name = "pal";
9512715Snikos.nikoleris@arm.comFaultVect PalFault::_vect = 0x2001;
9612715Snikos.nikoleris@arm.comFaultStat PalFault::_stat;
9712715Snikos.nikoleris@arm.com
9812715Snikos.nikoleris@arm.comFaultName IntegerOverflowFault::_name = "intover";
995318SN/AFaultVect IntegerOverflowFault::_vect = 0x0501;
10011740Snikos.nikoleris@arm.comFaultStat IntegerOverflowFault::_stat;
1014908SN/A
10211740Snikos.nikoleris@arm.com#if FULL_SYSTEM
10311740Snikos.nikoleris@arm.com
10411740Snikos.nikoleris@arm.comvoid AlphaFault::invoke(ExecContext * xc)
10511740Snikos.nikoleris@arm.com{
10611740Snikos.nikoleris@arm.com    DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), xc->regs.pc);
10711741Snikos.nikoleris@arm.com    xc->cpu->recordEvent(csprintf("Fault %s", name()));
10811740Snikos.nikoleris@arm.com
10911740Snikos.nikoleris@arm.com    assert(!xc->misspeculating());
11011740Snikos.nikoleris@arm.com    xc->kernelStats->fault(this);
11111740Snikos.nikoleris@arm.com
11211740Snikos.nikoleris@arm.com    // exception restart address
11311741Snikos.nikoleris@arm.com    if (setRestartAddress() || !xc->inPalMode())
11411741Snikos.nikoleris@arm.com        xc->setMiscReg(AlphaISA::IPR_EXC_ADDR, xc->regs.pc);
11511740Snikos.nikoleris@arm.com
11611741Snikos.nikoleris@arm.com    if (skipFaultingInstruction()) {
1175318SN/A        // traps...  skip faulting instruction.
1189543Ssascha.bischoff@arm.com        xc->setMiscReg(AlphaISA::IPR_EXC_ADDR,
1199543Ssascha.bischoff@arm.com                   xc->readMiscReg(AlphaISA::IPR_EXC_ADDR) + 4);
1209543Ssascha.bischoff@arm.com    }
1219543Ssascha.bischoff@arm.com
12211484Snikos.nikoleris@arm.com    if (!xc->inPalMode())
1234908SN/A        AlphaISA::swap_palshadow(&(xc->regs), true);
1244908SN/A
12511083Sandreas.hansson@arm.com    xc->regs.pc = xc->readMiscReg(AlphaISA::IPR_PAL_BASE) + vect();
12611083Sandreas.hansson@arm.com    xc->regs.npc = xc->regs.pc + sizeof(MachInst);
12711083Sandreas.hansson@arm.com}
1284908SN/A
1294903SN/Avoid ArithmeticFault::invoke(ExecContext * xc)
1304903SN/A{
13111741Snikos.nikoleris@arm.com    DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), xc->regs.pc);
1324903SN/A    xc->cpu->recordEvent(csprintf("Fault %s", name()));
1334903SN/A
1344903SN/A    assert(!xc->misspeculating());
1357667Ssteve.reinhardt@amd.com    xc->kernelStats->fault(this);
1367667Ssteve.reinhardt@amd.com
1377667Ssteve.reinhardt@amd.com    panic("Arithmetic traps are unimplemented!");
13811286Sandreas.hansson@arm.com}
13911286Sandreas.hansson@arm.com
14011286Sandreas.hansson@arm.com
1417667Ssteve.reinhardt@amd.com/*void ArithmeticFault::invoke(ExecContext * xc)
1427667Ssteve.reinhardt@amd.com{
1437667Ssteve.reinhardt@amd.com    panic("Arithmetic traps are unimplemented!");
1447667Ssteve.reinhardt@amd.com}*/
1457667Ssteve.reinhardt@amd.com
1467667Ssteve.reinhardt@amd.com#endif
1477669Ssteve.reinhardt@amd.com
1487669Ssteve.reinhardt@amd.com} // namespace AlphaISA
1497669Ssteve.reinhardt@amd.com
1507667Ssteve.reinhardt@amd.com/*Fault * ListOfFaults[] = {
15111286Sandreas.hansson@arm.com        (Fault *)&NoFault,
15211286Sandreas.hansson@arm.com        (Fault *)&ResetFault,
15311286Sandreas.hansson@arm.com        (Fault *)&MachineCheckFault,
15411286Sandreas.hansson@arm.com        (Fault *)&ArithmeticFault,
15511286Sandreas.hansson@arm.com        (Fault *)&InterruptFault,
15611286Sandreas.hansson@arm.com        (Fault *)&NDtbMissFault,
15711286Sandreas.hansson@arm.com        (Fault *)&PDtbMissFault,
15811286Sandreas.hansson@arm.com        (Fault *)&AlignmentFault,
15911286Sandreas.hansson@arm.com        (Fault *)&DtbPageFault,
16011286Sandreas.hansson@arm.com        (Fault *)&DtbAcvFault,
16111286Sandreas.hansson@arm.com        (Fault *)&ItbMissFault,
16211286Sandreas.hansson@arm.com        (Fault *)&ItbPageFault,
16311286Sandreas.hansson@arm.com        (Fault *)&ItbAcvFault,
1647667Ssteve.reinhardt@amd.com        (Fault *)&UnimplementedOpcodeFault,
1657667Ssteve.reinhardt@amd.com        (Fault *)&FloatEnableFault,
1667667Ssteve.reinhardt@amd.com        (Fault *)&PalFault,
1674903SN/A        (Fault *)&IntegerOverflowFault,
1684903SN/A        };
1694903SN/A
1704903SN/Aint NumFaults = sizeof(ListOfFaults) / sizeof(Fault *);*/
1714903SN/A