faults.cc revision 5254
12131SN/A/* 25254Sksewell@umich.edu * Copyright (c) 2007 MIPS Technologies, Inc. 35254Sksewell@umich.edu * All rights reserved. 42131SN/A * 55254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 65254Sksewell@umich.edu * modification, are permitted provided that the following conditions are 75254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 85254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 95254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 105254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 115254Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 125254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 135254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 145254Sksewell@umich.edu * this software without specific prior written permission. 152131SN/A * 165254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 285254Sksewell@umich.edu * Authors: Gabe Black 295254Sksewell@umich.edu * Korey Sewell 305222Sksewell@umich.edu * Jaidev Patwardhan 312131SN/A */ 322131SN/A 332239SN/A#include "arch/mips/faults.hh" 342680Sktlim@umich.edu#include "cpu/thread_context.hh" 352447SN/A#include "cpu/base.hh" 362447SN/A#include "base/trace.hh" 375222Sksewell@umich.edu#include "arch/mips/pra_constants.hh" 382800Ssaidi@eecs.umich.edu#if !FULL_SYSTEM 392800Ssaidi@eecs.umich.edu#include "sim/process.hh" 402800Ssaidi@eecs.umich.edu#include "mem/page_table.hh" 412800Ssaidi@eecs.umich.edu#endif 422131SN/A 432447SN/Anamespace MipsISA 442447SN/A{ 452131SN/A 462479SN/AFaultName MachineCheckFault::_name = "Machine Check"; 472447SN/AFaultVect MachineCheckFault::_vect = 0x0401; 482447SN/AFaultStat MachineCheckFault::_count; 492131SN/A 502479SN/AFaultName AlignmentFault::_name = "Alignment"; 512447SN/AFaultVect AlignmentFault::_vect = 0x0301; 522447SN/AFaultStat AlignmentFault::_count; 532447SN/A 545224Sksewell@umich.eduFaultName ResetFault::_name = "Reset Fault"; 555222Sksewell@umich.edu#if FULL_SYSTEM 565222Sksewell@umich.eduFaultVect ResetFault::_vect = 0xBFC00000; 575222Sksewell@umich.edu#else 585222Sksewell@umich.eduFaultVect ResetFault::_vect = 0x001; 595222Sksewell@umich.edu#endif 602447SN/AFaultStat ResetFault::_count; 612447SN/A 625222Sksewell@umich.eduFaultName AddressErrorFault::_name = "Address Error"; 635222Sksewell@umich.eduFaultVect AddressErrorFault::_vect = 0x0180; 645222Sksewell@umich.eduFaultStat AddressErrorFault::_count; 655222Sksewell@umich.edu 665222Sksewell@umich.eduFaultName StoreAddressErrorFault::_name = "Store Address Error"; 675222Sksewell@umich.eduFaultVect StoreAddressErrorFault::_vect = 0x0180; 685222Sksewell@umich.eduFaultStat StoreAddressErrorFault::_count; 695222Sksewell@umich.edu 705222Sksewell@umich.edu 715222Sksewell@umich.eduFaultName SystemCallFault::_name = "Syscall"; 725222Sksewell@umich.eduFaultVect SystemCallFault::_vect = 0x0180; 735222Sksewell@umich.eduFaultStat SystemCallFault::_count; 745222Sksewell@umich.edu 755224Sksewell@umich.eduFaultName CoprocessorUnusableFault::_name = "Coprocessor Unusable Fault"; 765222Sksewell@umich.eduFaultVect CoprocessorUnusableFault::_vect = 0x180; 774661Sksewell@umich.eduFaultStat CoprocessorUnusableFault::_count; 784661Sksewell@umich.edu 795224Sksewell@umich.eduFaultName ReservedInstructionFault::_name = "Reserved Instruction Fault"; 805222Sksewell@umich.eduFaultVect ReservedInstructionFault::_vect = 0x0180; 814661Sksewell@umich.eduFaultStat ReservedInstructionFault::_count; 824661Sksewell@umich.edu 835224Sksewell@umich.eduFaultName ThreadFault::_name = "Thread Fault"; 844661Sksewell@umich.eduFaultVect ThreadFault::_vect = 0x00F1; 854661Sksewell@umich.eduFaultStat ThreadFault::_count; 864661Sksewell@umich.edu 874661Sksewell@umich.edu 885222Sksewell@umich.eduFaultName ArithmeticFault::_name = "Arithmetic Overflow Exception"; 895222Sksewell@umich.eduFaultVect ArithmeticFault::_vect = 0x180; 902447SN/AFaultStat ArithmeticFault::_count; 912447SN/A 924661Sksewell@umich.eduFaultName UnimplementedOpcodeFault::_name = "opdec"; 934661Sksewell@umich.eduFaultVect UnimplementedOpcodeFault::_vect = 0x0481; 944661Sksewell@umich.eduFaultStat UnimplementedOpcodeFault::_count; 954661Sksewell@umich.edu 962447SN/AFaultName InterruptFault::_name = "interrupt"; 975222Sksewell@umich.eduFaultVect InterruptFault::_vect = 0x0180; 982447SN/AFaultStat InterruptFault::_count; 992447SN/A 1005222Sksewell@umich.eduFaultName TrapFault::_name = "Trap"; 1015222Sksewell@umich.eduFaultVect TrapFault::_vect = 0x0180; 1025222Sksewell@umich.eduFaultStat TrapFault::_count; 1035222Sksewell@umich.edu 1045222Sksewell@umich.eduFaultName BreakpointFault::_name = "Breakpoint"; 1055222Sksewell@umich.eduFaultVect BreakpointFault::_vect = 0x0180; 1065222Sksewell@umich.eduFaultStat BreakpointFault::_count; 1075222Sksewell@umich.edu 1085222Sksewell@umich.edu 1095222Sksewell@umich.eduFaultName ItbInvalidFault::_name = "Invalid TLB Entry Exception (I-Fetch/LW)"; 1105222Sksewell@umich.eduFaultVect ItbInvalidFault::_vect = 0x0180; 1115222Sksewell@umich.eduFaultStat ItbInvalidFault::_count; 1125222Sksewell@umich.edu 1135222Sksewell@umich.eduFaultName ItbPageFault::_name = "itbmiss"; 1145222Sksewell@umich.eduFaultVect ItbPageFault::_vect = 0x0181; 1155222Sksewell@umich.eduFaultStat ItbPageFault::_count; 1165222Sksewell@umich.edu 1175222Sksewell@umich.eduFaultName ItbMissFault::_name = "itbmiss"; 1185222Sksewell@umich.eduFaultVect ItbMissFault::_vect = 0x0181; 1195222Sksewell@umich.eduFaultStat ItbMissFault::_count; 1205222Sksewell@umich.edu 1215222Sksewell@umich.eduFaultName ItbAcvFault::_name = "iaccvio"; 1225222Sksewell@umich.eduFaultVect ItbAcvFault::_vect = 0x0081; 1235222Sksewell@umich.eduFaultStat ItbAcvFault::_count; 1245222Sksewell@umich.edu 1255222Sksewell@umich.eduFaultName ItbRefillFault::_name = "TLB Refill Exception (I-Fetch/LW)"; 1265222Sksewell@umich.eduFaultVect ItbRefillFault::_vect = 0x0180; 1275222Sksewell@umich.eduFaultStat ItbRefillFault::_count; 1285222Sksewell@umich.edu 1292447SN/AFaultName NDtbMissFault::_name = "dtb_miss_single"; 1302447SN/AFaultVect NDtbMissFault::_vect = 0x0201; 1312447SN/AFaultStat NDtbMissFault::_count; 1322447SN/A 1332447SN/AFaultName PDtbMissFault::_name = "dtb_miss_double"; 1342447SN/AFaultVect PDtbMissFault::_vect = 0x0281; 1352447SN/AFaultStat PDtbMissFault::_count; 1362447SN/A 1372447SN/AFaultName DtbPageFault::_name = "dfault"; 1382447SN/AFaultVect DtbPageFault::_vect = 0x0381; 1392447SN/AFaultStat DtbPageFault::_count; 1402447SN/A 1412447SN/AFaultName DtbAcvFault::_name = "dfault"; 1422447SN/AFaultVect DtbAcvFault::_vect = 0x0381; 1432447SN/AFaultStat DtbAcvFault::_count; 1442447SN/A 1455222Sksewell@umich.eduFaultName DtbInvalidFault::_name = "Invalid TLB Entry Exception (Store)"; 1465222Sksewell@umich.eduFaultVect DtbInvalidFault::_vect = 0x0180; 1475222Sksewell@umich.eduFaultStat DtbInvalidFault::_count; 1482447SN/A 1495222Sksewell@umich.eduFaultName DtbRefillFault::_name = "TLB Refill Exception (Store)"; 1505222Sksewell@umich.eduFaultVect DtbRefillFault::_vect = 0x0180; 1515222Sksewell@umich.eduFaultStat DtbRefillFault::_count; 1522447SN/A 1535222Sksewell@umich.eduFaultName TLBModifiedFault::_name = "TLB Modified Exception"; 1545222Sksewell@umich.eduFaultVect TLBModifiedFault::_vect = 0x0180; 1555222Sksewell@umich.eduFaultStat TLBModifiedFault::_count; 1562447SN/A 1575222Sksewell@umich.eduFaultName FloatEnableFault::_name = "float_enable_fault"; 1582447SN/AFaultVect FloatEnableFault::_vect = 0x0581; 1592447SN/AFaultStat FloatEnableFault::_count; 1602447SN/A 1615222Sksewell@umich.eduFaultName IntegerOverflowFault::_name = "Integer Overflow Fault"; 1622447SN/AFaultVect IntegerOverflowFault::_vect = 0x0501; 1632447SN/AFaultStat IntegerOverflowFault::_count; 1642447SN/A 1655222Sksewell@umich.eduFaultName DspStateDisabledFault::_name = "DSP Disabled Fault"; 1664661Sksewell@umich.eduFaultVect DspStateDisabledFault::_vect = 0x001a; 1674661Sksewell@umich.eduFaultStat DspStateDisabledFault::_count; 1684661Sksewell@umich.edu 1695222Sksewell@umich.edu#if FULL_SYSTEM 1705222Sksewell@umich.eduvoid MipsFault::setHandlerPC(Addr HandlerBase, ThreadContext *tc) 1715222Sksewell@umich.edu{ 1725222Sksewell@umich.edu tc->setPC(HandlerBase); 1735222Sksewell@umich.edu tc->setNextPC(HandlerBase+sizeof(MachInst)); 1745222Sksewell@umich.edu tc->setNextNPC(HandlerBase+2*sizeof(MachInst)); 1755222Sksewell@umich.edu} 1765222Sksewell@umich.edu 1775222Sksewell@umich.eduvoid MipsFault::setExceptionState(ThreadContext *tc,uint8_t ExcCode) 1785222Sksewell@umich.edu{ 1795222Sksewell@umich.edu // modify SRS Ctl - Save CSS, put ESS into CSS 1805222Sksewell@umich.edu MiscReg stat = tc->readMiscReg(MipsISA::Status); 1815222Sksewell@umich.edu if(bits(stat,Status_EXL) != 1 && bits(stat,Status_BEV) != 1) 1825222Sksewell@umich.edu { 1835222Sksewell@umich.edu // SRS Ctl is modified only if Status_EXL and Status_BEV are not set 1845222Sksewell@umich.edu MiscReg srs = tc->readMiscReg(MipsISA::SRSCtl); 1855222Sksewell@umich.edu uint8_t CSS,ESS; 1865222Sksewell@umich.edu CSS = bits(srs,SRSCtl_CSS_HI,SRSCtl_CSS_LO); 1875222Sksewell@umich.edu ESS = bits(srs,SRSCtl_ESS_HI,SRSCtl_ESS_LO); 1885222Sksewell@umich.edu // Move CSS to PSS 1895222Sksewell@umich.edu replaceBits(srs,SRSCtl_PSS_HI,SRSCtl_PSS_LO,CSS); 1905222Sksewell@umich.edu // Move ESS to CSS 1915222Sksewell@umich.edu replaceBits(srs,SRSCtl_CSS_HI,SRSCtl_CSS_LO,ESS); 1925222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::SRSCtl,srs); 1935250Sksewell@umich.edu //tc->setShadowSet(ESS); 1945222Sksewell@umich.edu } 1955222Sksewell@umich.edu 1965222Sksewell@umich.edu // set EXL bit (don't care if it is already set!) 1975222Sksewell@umich.edu replaceBits(stat,Status_EXL_HI,Status_EXL_LO,1); 1985222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::Status,stat); 1995222Sksewell@umich.edu 2005222Sksewell@umich.edu // write EPC 2015222Sksewell@umich.edu // warn("Set EPC to %x\n",tc->readPC()); 2025222Sksewell@umich.edu // CHECK ME or FIXME or FIX ME or POSSIBLE HACK 2035222Sksewell@umich.edu // Check to see if the exception occurred in the branch delay slot 2045222Sksewell@umich.edu DPRINTF(MipsPRA,"PC: %x, NextPC: %x, NNPC: %x\n",tc->readPC(),tc->readNextPC(),tc->readNextNPC()); 2055222Sksewell@umich.edu int C_BD=0; 2065222Sksewell@umich.edu if(tc->readPC() + sizeof(MachInst) != tc->readNextPC()){ 2075222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::EPC,tc->readPC()-sizeof(MachInst)); 2085222Sksewell@umich.edu // In the branch delay slot? set CAUSE_31 2095222Sksewell@umich.edu C_BD = 1; 2105222Sksewell@umich.edu } else { 2115222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::EPC,tc->readPC()); 2125222Sksewell@umich.edu // In the branch delay slot? reset CAUSE_31 2135222Sksewell@umich.edu C_BD = 0; 2145222Sksewell@umich.edu } 2155222Sksewell@umich.edu 2165222Sksewell@umich.edu // Set Cause_EXCCODE field 2175222Sksewell@umich.edu MiscReg cause = tc->readMiscReg(MipsISA::Cause); 2185222Sksewell@umich.edu replaceBits(cause,Cause_EXCCODE_HI,Cause_EXCCODE_LO,ExcCode); 2195222Sksewell@umich.edu replaceBits(cause,Cause_BD_HI,Cause_BD_LO,C_BD); 2205222Sksewell@umich.edu replaceBits(cause,Cause_CE_HI,Cause_CE_LO,0); 2215222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::Cause,cause); 2225222Sksewell@umich.edu 2235222Sksewell@umich.edu} 2245222Sksewell@umich.edu 2255222Sksewell@umich.eduvoid ArithmeticFault::invoke(ThreadContext *tc) 2265222Sksewell@umich.edu{ 2275222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 2285222Sksewell@umich.edu setExceptionState(tc,0xC); 2295222Sksewell@umich.edu 2305222Sksewell@umich.edu // Set new PC 2315222Sksewell@umich.edu Addr HandlerBase; 2325222Sksewell@umich.edu MiscReg stat = tc->readMiscReg(MipsISA::Status); 2335222Sksewell@umich.edu // Here, the handler is dependent on BEV, which is not modified by setExceptionState() 2345222Sksewell@umich.edu if(bits(stat,Status_BEV)==0){ // See MIPS ARM Vol 3, Revision 2, Page 38 2355222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); 2365222Sksewell@umich.edu }else{ 2375222Sksewell@umich.edu HandlerBase = 0xBFC00200; 2385222Sksewell@umich.edu } 2395222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 2405222Sksewell@umich.edu // warn("Exception Handler At: %x \n",HandlerBase); 2415222Sksewell@umich.edu} 2425222Sksewell@umich.edu 2435222Sksewell@umich.eduvoid StoreAddressErrorFault::invoke(ThreadContext *tc) 2445222Sksewell@umich.edu{ 2455222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 2465222Sksewell@umich.edu setExceptionState(tc,0x5); 2475222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::BadVAddr,BadVAddr); 2485222Sksewell@umich.edu 2495222Sksewell@umich.edu // Set new PC 2505222Sksewell@umich.edu Addr HandlerBase; 2515222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 2525222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 2535222Sksewell@umich.edu // warn("Exception Handler At: %x \n",HandlerBase); 2545222Sksewell@umich.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(MipsISA::EPC)); 2555222Sksewell@umich.edu 2565222Sksewell@umich.edu} 2575222Sksewell@umich.edu 2585222Sksewell@umich.eduvoid TrapFault::invoke(ThreadContext *tc) 2595222Sksewell@umich.edu{ 2605222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 2615222Sksewell@umich.edu // warn("%s encountered.\n", name()); 2625222Sksewell@umich.edu setExceptionState(tc,0xD); 2635222Sksewell@umich.edu 2645222Sksewell@umich.edu // Set new PC 2655222Sksewell@umich.edu Addr HandlerBase; 2665222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 2675222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 2685222Sksewell@umich.edu // warn("Exception Handler At: %x \n",HandlerBase); 2695222Sksewell@umich.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(MipsISA::EPC)); 2705222Sksewell@umich.edu} 2715222Sksewell@umich.edu 2725222Sksewell@umich.eduvoid BreakpointFault::invoke(ThreadContext *tc) 2735222Sksewell@umich.edu{ 2745222Sksewell@umich.edu setExceptionState(tc,0x9); 2755222Sksewell@umich.edu 2765222Sksewell@umich.edu // Set new PC 2775222Sksewell@umich.edu Addr HandlerBase; 2785222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 2795222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 2805222Sksewell@umich.edu // warn("Exception Handler At: %x \n",HandlerBase); 2815222Sksewell@umich.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(MipsISA::EPC)); 2825222Sksewell@umich.edu 2835222Sksewell@umich.edu} 2845222Sksewell@umich.edu 2855222Sksewell@umich.eduvoid DtbInvalidFault::invoke(ThreadContext *tc) 2865222Sksewell@umich.edu{ 2875222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 2885222Sksewell@umich.edu // warn("%s encountered.\n", name()); 2895222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::BadVAddr,BadVAddr); 2905222Sksewell@umich.edu MiscReg eh = tc->readMiscReg(MipsISA::EntryHi); 2915222Sksewell@umich.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 2925222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 2935222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 2945222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::EntryHi,eh); 2955222Sksewell@umich.edu MiscReg ctxt = tc->readMiscReg(MipsISA::Context); 2965222Sksewell@umich.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 2975222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::Context,ctxt); 2985222Sksewell@umich.edu setExceptionState(tc,0x3); 2995222Sksewell@umich.edu 3005222Sksewell@umich.edu 3015222Sksewell@umich.edu // Set new PC 3025222Sksewell@umich.edu Addr HandlerBase; 3035222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 3045222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 3055222Sksewell@umich.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(MipsISA::EPC)); 3065222Sksewell@umich.edu} 3075222Sksewell@umich.edu 3085222Sksewell@umich.eduvoid AddressErrorFault::invoke(ThreadContext *tc) 3095222Sksewell@umich.edu{ 3105222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 3115222Sksewell@umich.edu setExceptionState(tc,0x4); 3125222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::BadVAddr,BadVAddr); 3135222Sksewell@umich.edu 3145222Sksewell@umich.edu // Set new PC 3155222Sksewell@umich.edu Addr HandlerBase; 3165222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 3175222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 3185222Sksewell@umich.edu} 3195222Sksewell@umich.edu 3205222Sksewell@umich.eduvoid ItbInvalidFault::invoke(ThreadContext *tc) 3215222Sksewell@umich.edu{ 3225222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 3235222Sksewell@umich.edu setExceptionState(tc,0x2); 3245222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::BadVAddr,BadVAddr); 3255222Sksewell@umich.edu MiscReg eh = tc->readMiscReg(MipsISA::EntryHi); 3265222Sksewell@umich.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 3275222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 3285222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 3295222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::EntryHi,eh); 3305222Sksewell@umich.edu MiscReg ctxt = tc->readMiscReg(MipsISA::Context); 3315222Sksewell@umich.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 3325222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::Context,ctxt); 3335222Sksewell@umich.edu 3345222Sksewell@umich.edu 3355222Sksewell@umich.edu // Set new PC 3365222Sksewell@umich.edu Addr HandlerBase; 3375222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 3385222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 3395222Sksewell@umich.edu DPRINTF(MipsPRA,"Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(MipsISA::EPC)); 3405222Sksewell@umich.edu} 3415222Sksewell@umich.edu 3425222Sksewell@umich.eduvoid ItbRefillFault::invoke(ThreadContext *tc) 3435222Sksewell@umich.edu{ 3445222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered (%x).\n", name(),BadVAddr); 3455222Sksewell@umich.edu Addr HandlerBase; 3465222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::BadVAddr,BadVAddr); 3475222Sksewell@umich.edu MiscReg eh = tc->readMiscReg(MipsISA::EntryHi); 3485222Sksewell@umich.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 3495222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 3505222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 3515222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::EntryHi,eh); 3525222Sksewell@umich.edu MiscReg ctxt = tc->readMiscReg(MipsISA::Context); 3535222Sksewell@umich.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 3545222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::Context,ctxt); 3555222Sksewell@umich.edu 3565222Sksewell@umich.edu MiscReg stat = tc->readMiscReg(MipsISA::Status); 3575222Sksewell@umich.edu // Since handler depends on EXL bit, must check EXL bit before setting it!! 3585222Sksewell@umich.edu if(bits(stat,Status_EXL)==1){ // See MIPS ARM Vol 3, Revision 2, Page 38 3595222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 3605222Sksewell@umich.edu }else{ 3615222Sksewell@umich.edu HandlerBase = tc->readMiscReg(MipsISA::EBase); // Offset 0x000 3625222Sksewell@umich.edu } 3635222Sksewell@umich.edu 3645222Sksewell@umich.edu setExceptionState(tc,0x2); 3655222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 3665222Sksewell@umich.edu} 3675222Sksewell@umich.edu 3685222Sksewell@umich.eduvoid DtbRefillFault::invoke(ThreadContext *tc) 3695222Sksewell@umich.edu{ 3705222Sksewell@umich.edu // Set new PC 3715222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 3725222Sksewell@umich.edu Addr HandlerBase; 3735222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::BadVAddr,BadVAddr); 3745222Sksewell@umich.edu MiscReg eh = tc->readMiscReg(MipsISA::EntryHi); 3755222Sksewell@umich.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 3765222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 3775222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 3785222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::EntryHi,eh); 3795222Sksewell@umich.edu MiscReg ctxt = tc->readMiscReg(MipsISA::Context); 3805222Sksewell@umich.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 3815222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::Context,ctxt); 3825222Sksewell@umich.edu 3835222Sksewell@umich.edu MiscReg stat = tc->readMiscReg(MipsISA::Status); 3845222Sksewell@umich.edu // Since handler depends on EXL bit, must check EXL bit before setting it!! 3855222Sksewell@umich.edu if(bits(stat,Status_EXL)==1){ // See MIPS ARM Vol 3, Revision 2, Page 38 3865222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 3875222Sksewell@umich.edu }else{ 3885222Sksewell@umich.edu HandlerBase = tc->readMiscReg(MipsISA::EBase); // Offset 0x000 3895222Sksewell@umich.edu } 3905222Sksewell@umich.edu 3915222Sksewell@umich.edu 3925222Sksewell@umich.edu setExceptionState(tc,0x3); 3935222Sksewell@umich.edu 3945222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 3955222Sksewell@umich.edu} 3965222Sksewell@umich.edu 3975222Sksewell@umich.eduvoid TLBModifiedFault::invoke(ThreadContext *tc) 3985222Sksewell@umich.edu{ 3995222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 4005222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::BadVAddr,BadVAddr); 4015222Sksewell@umich.edu MiscReg eh = tc->readMiscReg(MipsISA::EntryHi); 4025222Sksewell@umich.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 4035222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 4045222Sksewell@umich.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 4055222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::EntryHi,eh); 4065222Sksewell@umich.edu MiscReg ctxt = tc->readMiscReg(MipsISA::Context); 4075222Sksewell@umich.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 4085222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::Context,ctxt); 4095222Sksewell@umich.edu 4105222Sksewell@umich.edu // Set new PC 4115222Sksewell@umich.edu Addr HandlerBase; 4125222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 4135222Sksewell@umich.edu setExceptionState(tc,0x1); 4145222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 4155222Sksewell@umich.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(MipsISA::EPC)); 4165222Sksewell@umich.edu 4175222Sksewell@umich.edu} 4185222Sksewell@umich.edu 4195222Sksewell@umich.eduvoid SystemCallFault::invoke(ThreadContext *tc) 4205222Sksewell@umich.edu{ 4215222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 4225222Sksewell@umich.edu setExceptionState(tc,0x8); 4235222Sksewell@umich.edu 4245222Sksewell@umich.edu // Set new PC 4255222Sksewell@umich.edu Addr HandlerBase; 4265222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 4275222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 4285222Sksewell@umich.edu // warn("Exception Handler At: %x \n",HandlerBase); 4295222Sksewell@umich.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(MipsISA::EPC)); 4305222Sksewell@umich.edu 4315222Sksewell@umich.edu} 4325222Sksewell@umich.edu 4335222Sksewell@umich.eduvoid InterruptFault::invoke(ThreadContext *tc) 4345222Sksewell@umich.edu{ 4355222Sksewell@umich.edu#if FULL_SYSTEM 4365222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 4375222Sksewell@umich.edu //RegFile *Reg = tc->getRegFilePtr(); // Get pointer to the register fil 4385222Sksewell@umich.edu setExceptionState(tc,0x0A); 4395222Sksewell@umich.edu Addr HandlerBase; 4405222Sksewell@umich.edu 4415222Sksewell@umich.edu 4425222Sksewell@umich.edu uint8_t IV = bits(tc->readMiscRegNoEffect(MipsISA::Cause),Cause_IV); 4435222Sksewell@umich.edu if (IV)// Offset 200 for release 2 4445222Sksewell@umich.edu HandlerBase= 0x20 + vect() + tc->readMiscRegNoEffect(MipsISA::EBase); 4455222Sksewell@umich.edu else//Ofset at 180 for release 1 4465222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscRegNoEffect(MipsISA::EBase); 4475222Sksewell@umich.edu 4485222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 4495222Sksewell@umich.edu#endif 4505222Sksewell@umich.edu} 4515222Sksewell@umich.edu 4525222Sksewell@umich.edu#endif // FULL_SYSTEM 4535222Sksewell@umich.edu 4544661Sksewell@umich.eduvoid ResetFault::invoke(ThreadContext *tc) 4554661Sksewell@umich.edu{ 4565224Sksewell@umich.edu#if FULL_SYSTEM 4575222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 4585222Sksewell@umich.edu /* All reset activity must be invoked from here */ 4595222Sksewell@umich.edu tc->setPC(vect()); 4605222Sksewell@umich.edu tc->setNextPC(vect()+sizeof(MachInst)); 4615222Sksewell@umich.edu tc->setNextNPC(vect()+sizeof(MachInst)+sizeof(MachInst)); 4625222Sksewell@umich.edu DPRINTF(MipsPRA,"(%x) - ResetFault::invoke : PC set to %x",(unsigned)tc,(unsigned)tc->readPC()); 4635224Sksewell@umich.edu#endif 4645224Sksewell@umich.edu 4655224Sksewell@umich.edu // Set Coprocessor 1 (Floating Point) To Usable 4665224Sksewell@umich.edu tc->setMiscReg(MipsISA::Status, MipsISA::Status | 0x20000000); 4675222Sksewell@umich.edu} 4685222Sksewell@umich.edu 4695222Sksewell@umich.eduvoid ReservedInstructionFault::invoke(ThreadContext *tc) 4705222Sksewell@umich.edu{ 4715222Sksewell@umich.edu#if FULL_SYSTEM 4725222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 4735222Sksewell@umich.edu //RegFile *Reg = tc->getRegFilePtr(); // Get pointer to the register fil 4745222Sksewell@umich.edu setExceptionState(tc,0x0A); 4755222Sksewell@umich.edu Addr HandlerBase; 4765222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscRegNoEffect(MipsISA::EBase); // Offset 0x180 - General Exception Vector 4775222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 4785222Sksewell@umich.edu#else 4795222Sksewell@umich.edu panic("%s encountered.\n", name()); 4805222Sksewell@umich.edu#endif 4815222Sksewell@umich.edu} 4825222Sksewell@umich.edu 4835222Sksewell@umich.eduvoid ThreadFault::invoke(ThreadContext *tc) 4845222Sksewell@umich.edu{ 4855222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 4865222Sksewell@umich.edu panic("%s encountered.\n", name()); 4875222Sksewell@umich.edu} 4885222Sksewell@umich.edu 4895222Sksewell@umich.eduvoid DspStateDisabledFault::invoke(ThreadContext *tc) 4905222Sksewell@umich.edu{ 4915222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 4925222Sksewell@umich.edu panic("%s encountered.\n", name()); 4934661Sksewell@umich.edu} 4944661Sksewell@umich.edu 4954661Sksewell@umich.eduvoid CoprocessorUnusableFault::invoke(ThreadContext *tc) 4964661Sksewell@umich.edu{ 4975222Sksewell@umich.edu#if FULL_SYSTEM 4985222Sksewell@umich.edu DPRINTF(MipsPRA,"%s encountered.\n", name()); 4995222Sksewell@umich.edu setExceptionState(tc,0xb); 5005222Sksewell@umich.edu /* The ID of the coprocessor causing the exception is stored in CoprocessorUnusableFault::coProcID */ 5015222Sksewell@umich.edu MiscReg cause = tc->readMiscReg(MipsISA::Cause); 5025222Sksewell@umich.edu replaceBits(cause,Cause_CE_HI,Cause_CE_LO,coProcID); 5035222Sksewell@umich.edu tc->setMiscRegNoEffect(MipsISA::Cause,cause); 5044661Sksewell@umich.edu 5055222Sksewell@umich.edu Addr HandlerBase; 5065222Sksewell@umich.edu HandlerBase= vect() + tc->readMiscReg(MipsISA::EBase); // Offset 0x180 - General Exception Vector 5075222Sksewell@umich.edu setHandlerPC(HandlerBase,tc); 5084661Sksewell@umich.edu 5095222Sksewell@umich.edu // warn("Status: %x, Cause: %x\n",tc->readMiscReg(MipsISA::Status),tc->readMiscReg(MipsISA::Cause)); 5105222Sksewell@umich.edu#else 5115224Sksewell@umich.edu warn("%s (CP%d) encountered.\n", name(), coProcID); 5125222Sksewell@umich.edu#endif 5134661Sksewell@umich.edu} 5144661Sksewell@umich.edu 5152447SN/A} // namespace MipsISA 5162447SN/A 517