faults.cc revision 2469
16657Snate@binkert.org/*
26657Snate@binkert.org * Copyright (c) 2003-2005 The Regents of The University of Michigan
36657Snate@binkert.org * All rights reserved.
46657Snate@binkert.org *
56657Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66657Snate@binkert.org * modification, are permitted provided that the following conditions are
76657Snate@binkert.org * met: redistributions of source code must retain the above copyright
86657Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96657Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106657Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116657Snate@binkert.org * documentation and/or other materials provided with the distribution;
126657Snate@binkert.org * neither the name of the copyright holders nor the names of its
136657Snate@binkert.org * contributors may be used to endorse or promote products derived from
146657Snate@binkert.org * this software without specific prior written permission.
156657Snate@binkert.org *
166657Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176657Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186657Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196657Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206657Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216657Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226657Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236657Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246657Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256657Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266657Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276657Snate@binkert.org */
286999Snate@binkert.org
296657Snate@binkert.org#include "arch/sparc/faults.hh"
306657Snate@binkert.org#include "cpu/exec_context.hh"
316657Snate@binkert.org#include "cpu/base.hh"
329302Snilay@cs.wisc.edu#include "base/trace.hh"
336657Snate@binkert.org
346657Snate@binkert.orgnamespace SparcISA
356657Snate@binkert.org{
366657Snate@binkert.org
376657Snate@binkert.orgFaultName     InternalProcessorError::_name = "intprocerr";
386657Snate@binkert.orgTrapType      InternalProcessorError::_trapType = 0x029;
396657Snate@binkert.orgFaultPriority InternalProcessorError::_priority = 4;
406657Snate@binkert.orgFaultStat     InternalProcessorError::_count;
416657Snate@binkert.org
426657Snate@binkert.orgFaultName     MemAddressNotAligned::_name = "unalign";
436657Snate@binkert.orgTrapType      MemAddressNotAligned::_trapType = 0x034;
446657Snate@binkert.orgFaultPriority MemAddressNotAligned::_priority = 10;
456657Snate@binkert.orgFaultStat     MemAddressNotAligned::_count;
466657Snate@binkert.org
476657Snate@binkert.orgFaultName     PowerOnReset::_name = "pow_reset";
486657Snate@binkert.orgTrapType      PowerOnReset::_trapType = 0x001;
496657Snate@binkert.orgFaultPriority PowerOnReset::_priority = 0;
506882SBrad.Beckmann@amd.comFaultStat     PowerOnReset::_count;
516657Snate@binkert.org
526657Snate@binkert.orgFaultName     WatchDogReset::_name = "watch_dog_reset";
536657Snate@binkert.orgTrapType      WatchDogReset::_trapType = 0x002;
546657Snate@binkert.orgFaultPriority WatchDogReset::_priority = 1;
556657Snate@binkert.orgFaultStat     WatchDogReset::_count;
566657Snate@binkert.org
576657Snate@binkert.orgFaultName     ExternallyInitiatedReset::_name = "extern_reset";
586657Snate@binkert.orgTrapType      ExternallyInitiatedReset::_trapType = 0x003;
596657Snate@binkert.orgFaultPriority ExternallyInitiatedReset::_priority = 1;
606657Snate@binkert.orgFaultStat     ExternallyInitiatedReset::_count;
616657Snate@binkert.org
626657Snate@binkert.orgFaultName     SoftwareInitiatedReset::_name = "software_reset";
636657Snate@binkert.orgTrapType      SoftwareInitiatedReset::_trapType = 0x004;
6410895Snilay@cs.wisc.eduFaultPriority SoftwareInitiatedReset::_priority = 1;
656657Snate@binkert.orgFaultStat     SoftwareInitiatedReset::_count;
666657Snate@binkert.org
676657Snate@binkert.orgFaultName     REDStateException::_name = "red_counte";
6810228Snilay@cs.wisc.eduTrapType      REDStateException::_trapType = 0x005;
696657Snate@binkert.orgFaultPriority REDStateException::_priority = 1;
706657Snate@binkert.orgFaultStat     REDStateException::_count;
7110228Snilay@cs.wisc.edu
726657Snate@binkert.orgFaultName     InstructionAccessException::_name = "inst_access";
736657Snate@binkert.orgTrapType      InstructionAccessException::_trapType = 0x008;
746657Snate@binkert.orgFaultPriority InstructionAccessException::_priority = 5;
756657Snate@binkert.orgFaultStat     InstructionAccessException::_count;
766657Snate@binkert.org
776657Snate@binkert.orgFaultName     InstructionAccessMMUMiss::_name = "inst_mmu";
786657Snate@binkert.orgTrapType      InstructionAccessMMUMiss::_trapType = 0x009;
796657Snate@binkert.orgFaultPriority InstructionAccessMMUMiss::_priority = 2;
806657Snate@binkert.orgFaultStat     InstructionAccessMMUMiss::_count;
816657Snate@binkert.org
826657Snate@binkert.orgFaultName     InstructionAccessError::_name = "inst_error";
836657Snate@binkert.orgTrapType      InstructionAccessError::_trapType = 0x00A;
846657Snate@binkert.orgFaultPriority InstructionAccessError::_priority = 3;
856657Snate@binkert.orgFaultStat     InstructionAccessError::_count;
866657Snate@binkert.org
876657Snate@binkert.orgFaultName     IllegalInstruction::_name = "illegal_inst";
888086SBrad.Beckmann@amd.comTrapType      IllegalInstruction::_trapType = 0x010;
898086SBrad.Beckmann@amd.comFaultPriority IllegalInstruction::_priority = 7;
908086SBrad.Beckmann@amd.comFaultStat     IllegalInstruction::_count;
916657Snate@binkert.org
926657Snate@binkert.orgFaultName     PrivilegedOpcode::_name = "priv_opcode";
936657Snate@binkert.orgTrapType      PrivilegedOpcode::_trapType = 0x011;
946657Snate@binkert.orgFaultPriority PrivilegedOpcode::_priority = 6;
956657Snate@binkert.orgFaultStat     PrivilegedOpcode::_count;
966657Snate@binkert.org
976657Snate@binkert.orgFaultName     UnimplementedLDD::_name = "unimp_ldd";
9810895Snilay@cs.wisc.eduTrapType      UnimplementedLDD::_trapType = 0x012;
996657Snate@binkert.orgFaultPriority UnimplementedLDD::_priority = 6;
1006657Snate@binkert.orgFaultStat     UnimplementedLDD::_count;
1016657Snate@binkert.org
1026657Snate@binkert.orgFaultName     UnimplementedSTD::_name = "unimp_std";
1036657Snate@binkert.orgTrapType      UnimplementedSTD::_trapType = 0x013;
1046657Snate@binkert.orgFaultPriority UnimplementedSTD::_priority = 6;
1056657Snate@binkert.orgFaultStat     UnimplementedSTD::_count;
1066657Snate@binkert.org
1076657Snate@binkert.orgFaultName     FpDisabled::_name = "fp_disabled";
1086657Snate@binkert.orgTrapType      FpDisabled::_trapType = 0x020;
1096657Snate@binkert.orgFaultPriority FpDisabled::_priority = 8;
1106657Snate@binkert.orgFaultStat     FpDisabled::_count;
1116657Snate@binkert.org
1126657Snate@binkert.orgFaultName     FpExceptionIEEE754::_name = "fp_754";
1136657Snate@binkert.orgTrapType      FpExceptionIEEE754::_trapType = 0x021;
1146657Snate@binkert.orgFaultPriority FpExceptionIEEE754::_priority = 11;
1156657Snate@binkert.orgFaultStat     FpExceptionIEEE754::_count;
1166657Snate@binkert.org
1176657Snate@binkert.orgFaultName     FpExceptionOther::_name = "fp_other";
1186657Snate@binkert.orgTrapType      FpExceptionOther::_trapType = 0x022;
1196657Snate@binkert.orgFaultPriority FpExceptionOther::_priority = 11;
1206657Snate@binkert.orgFaultStat     FpExceptionOther::_count;
1216657Snate@binkert.org
1226657Snate@binkert.orgFaultName     TagOverflow::_name = "tag_overflow";
1236657Snate@binkert.orgTrapType      TagOverflow::_trapType = 0x023;
1246657Snate@binkert.orgFaultPriority TagOverflow::_priority = 14;
1259298Snilay@cs.wisc.eduFaultStat     TagOverflow::_count;
1266657Snate@binkert.org
1276657Snate@binkert.orgFaultName     DivisionByZero::_name = "div_by_zero";
1286657Snate@binkert.orgTrapType      DivisionByZero::_trapType = 0x028;
1296657Snate@binkert.orgFaultPriority DivisionByZero::_priority = 15;
1306657Snate@binkert.orgFaultStat     DivisionByZero::_count;
1316657Snate@binkert.org
1329302Snilay@cs.wisc.eduFaultName     DataAccessException::_name = "data_access";
1339302Snilay@cs.wisc.eduTrapType      DataAccessException::_trapType = 0x030;
1349302Snilay@cs.wisc.eduFaultPriority DataAccessException::_priority = 12;
1356657Snate@binkert.orgFaultStat     DataAccessException::_count;
1366657Snate@binkert.org
1376657Snate@binkert.orgFaultName     DataAccessMMUMiss::_name = "data_mmu";
1386657Snate@binkert.orgTrapType      DataAccessMMUMiss::_trapType = 0x031;
1396657Snate@binkert.orgFaultPriority DataAccessMMUMiss::_priority = 12;
1406657Snate@binkert.orgFaultStat     DataAccessMMUMiss::_count;
1416657Snate@binkert.org
1426657Snate@binkert.orgFaultName     DataAccessError::_name = "data_error";
1436882SBrad.Beckmann@amd.comTrapType      DataAccessError::_trapType = 0x032;
1446882SBrad.Beckmann@amd.comFaultPriority DataAccessError::_priority = 12;
1456882SBrad.Beckmann@amd.comFaultStat     DataAccessError::_count;
1468086SBrad.Beckmann@amd.com
1478086SBrad.Beckmann@amd.comFaultName     DataAccessProtection::_name = "data_protection";
1488086SBrad.Beckmann@amd.comTrapType      DataAccessProtection::_trapType = 0x033;
14910307Snilay@cs.wisc.eduFaultPriority DataAccessProtection::_priority = 12;
15010307Snilay@cs.wisc.eduFaultStat     DataAccessProtection::_count;
1516657Snate@binkert.org
1526657Snate@binkert.orgFaultName     LDDFMemAddressNotAligned::_name = "unalign_lddf";
1536657Snate@binkert.orgTrapType      LDDFMemAddressNotAligned::_trapType = 0x035;
15410307Snilay@cs.wisc.eduFaultPriority LDDFMemAddressNotAligned::_priority = 10;
1559298Snilay@cs.wisc.eduFaultStat     LDDFMemAddressNotAligned::_count;
1569298Snilay@cs.wisc.edu
1579298Snilay@cs.wisc.eduFaultName     STDFMemAddressNotAligned::_name = "unalign_stdf";
1586657Snate@binkert.orgTrapType      STDFMemAddressNotAligned::_trapType = 0x036;
1596657Snate@binkert.orgFaultPriority STDFMemAddressNotAligned::_priority = 10;
1606657Snate@binkert.orgFaultStat     STDFMemAddressNotAligned::_count;
1616657Snate@binkert.org
1626657Snate@binkert.orgFaultName     PrivilegedAction::_name = "priv_action";
1636657Snate@binkert.orgTrapType      PrivilegedAction::_trapType = 0x037;
1646657Snate@binkert.orgFaultPriority PrivilegedAction::_priority = 11;
1656657Snate@binkert.orgFaultStat     PrivilegedAction::_count;
1666657Snate@binkert.org
1676657Snate@binkert.orgFaultName     LDQFMemAddressNotAligned::_name = "unalign_ldqf";
1686657Snate@binkert.orgTrapType      LDQFMemAddressNotAligned::_trapType = 0x038;
1699219Spower.jg@gmail.comFaultPriority LDQFMemAddressNotAligned::_priority = 10;
1706657Snate@binkert.orgFaultStat     LDQFMemAddressNotAligned::_count;
1716657Snate@binkert.org
1726657Snate@binkert.orgFaultName     STQFMemAddressNotAligned::_name = "unalign_stqf";
1736657Snate@binkert.orgTrapType      STQFMemAddressNotAligned::_trapType = 0x039;
1746657Snate@binkert.orgFaultPriority STQFMemAddressNotAligned::_priority = 10;
1756657Snate@binkert.orgFaultStat     STQFMemAddressNotAligned::_count;
1766657Snate@binkert.org
1776657Snate@binkert.orgFaultName     AsyncDataError::_name = "async_data";
1786657Snate@binkert.orgTrapType      AsyncDataError::_trapType = 0x040;
1796657Snate@binkert.orgFaultPriority AsyncDataError::_priority = 2;
1806657Snate@binkert.orgFaultStat     AsyncDataError::_count;
1816657Snate@binkert.org
1826999Snate@binkert.org//The enumerated faults
1836657Snate@binkert.org
1846657Snate@binkert.orgFaultName     CleanWindow::_name = "clean_win";
1856657Snate@binkert.orgTrapType      CleanWindow::_baseTrapType = 0x024;
1866657Snate@binkert.orgFaultPriority CleanWindow::_priority = 10;
1876657Snate@binkert.orgFaultStat     CleanWindow::_count;
1886657Snate@binkert.org
1896657Snate@binkert.orgFaultName     InterruptLevelN::_name = "interrupt_n";
1907007Snate@binkert.orgTrapType      InterruptLevelN::_baseTrapType = 0x041;
1917007Snate@binkert.orgFaultStat     InterruptLevelN::_count;
1926657Snate@binkert.org
1937002Snate@binkert.orgFaultName     SpillNNormal::_name = "spill_n_normal";
1947002Snate@binkert.orgTrapType      SpillNNormal::_baseTrapType = 0x080;
1959466Snilay@cs.wisc.eduFaultPriority SpillNNormal::_priority = 9;
1966657Snate@binkert.orgFaultStat     SpillNNormal::_count;
1976657Snate@binkert.org
1986657Snate@binkert.orgFaultName     SpillNOther::_name = "spill_n_other";
1996657Snate@binkert.orgTrapType      SpillNOther::_baseTrapType = 0x0A0;
2006657Snate@binkert.orgFaultPriority SpillNOther::_priority = 9;
2016657Snate@binkert.orgFaultStat     SpillNOther::_count;
2026657Snate@binkert.org
2036657Snate@binkert.orgFaultName     FillNNormal::_name = "fill_n_normal";
2046657Snate@binkert.orgTrapType      FillNNormal::_baseTrapType = 0x0C0;
2056657Snate@binkert.orgFaultPriority FillNNormal::_priority = 9;
2066657Snate@binkert.orgFaultStat     FillNNormal::_count;
2076657Snate@binkert.org
2087007Snate@binkert.orgFaultName     FillNOther::_name = "fill_n_other";
2097007Snate@binkert.orgTrapType      FillNOther::_baseTrapType = 0x0E0;
2106657Snate@binkert.orgFaultPriority FillNOther::_priority = 9;
2119466Snilay@cs.wisc.eduFaultStat     FillNOther::_count;
2126657Snate@binkert.org
2136657Snate@binkert.orgFaultName     TrapInstruction::_name = "trap_inst_n";
2149466Snilay@cs.wisc.eduTrapType      TrapInstruction::_baseTrapType = 0x100;
2159508Snilay@cs.wisc.eduFaultPriority TrapInstruction::_priority = 16;
2169466Snilay@cs.wisc.eduFaultStat     TrapInstruction::_count;
2179466Snilay@cs.wisc.edu
2189466Snilay@cs.wisc.edu
2196657Snate@binkert.org
2206657Snate@binkert.org#if FULL_SYSTEM
2216657Snate@binkert.org
2226657Snate@binkert.orgvoid SparcFault::invoke(ExecContext * xc)
2236657Snate@binkert.org{
2246657Snate@binkert.org    FaultBase::invoke(xc);
2256657Snate@binkert.org    countStat()++;
2266657Snate@binkert.org
2276657Snate@binkert.org    //Use the SPARC trap state machine
2286657Snate@binkert.org    /*// exception restart address
2296657Snate@binkert.org    if (setRestartAddress() || !xc->inPalMode())
2306657Snate@binkert.org        xc->setMiscReg(AlphaISA::IPR_EXC_ADDR, xc->regs.pc);
2316657Snate@binkert.org
2326657Snate@binkert.org    if (skipFaultingInstruction()) {
2336657Snate@binkert.org        // traps...  skip faulting instruction.
2346657Snate@binkert.org        xc->setMiscReg(AlphaISA::IPR_EXC_ADDR,
2356657Snate@binkert.org                   xc->readMiscReg(AlphaISA::IPR_EXC_ADDR) + 4);
2367453Snate@binkert.org    }
2377453Snate@binkert.org
2387453Snate@binkert.org    if (!xc->inPalMode())
2397453Snate@binkert.org        AlphaISA::swap_palshadow(&(xc->regs), true);
2407453Snate@binkert.org
2417453Snate@binkert.org    xc->regs.pc = xc->readMiscReg(AlphaISA::IPR_PAL_BASE) + vect();
2427453Snate@binkert.org    xc->regs.npc = xc->regs.pc + sizeof(MachInst);*/
2437453Snate@binkert.org}
2447453Snate@binkert.org
2457453Snate@binkert.org#endif
2467453Snate@binkert.org
2477453Snate@binkert.org} // namespace SparcISA
2487453Snate@binkert.org
2497453Snate@binkert.org