faults.cc revision 6049
16019Shines@cs.fsu.edu/* 26019Shines@cs.fsu.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan 36019Shines@cs.fsu.edu * Copyright (c) 2007-2008 The Florida State University 46019Shines@cs.fsu.edu * All rights reserved. 56019Shines@cs.fsu.edu * 66019Shines@cs.fsu.edu * Redistribution and use in source and binary forms, with or without 76019Shines@cs.fsu.edu * modification, are permitted provided that the following conditions are 86019Shines@cs.fsu.edu * met: redistributions of source code must retain the above copyright 96019Shines@cs.fsu.edu * notice, this list of conditions and the following disclaimer; 106019Shines@cs.fsu.edu * redistributions in binary form must reproduce the above copyright 116019Shines@cs.fsu.edu * notice, this list of conditions and the following disclaimer in the 126019Shines@cs.fsu.edu * documentation and/or other materials provided with the distribution; 136019Shines@cs.fsu.edu * neither the name of the copyright holders nor the names of its 146019Shines@cs.fsu.edu * contributors may be used to endorse or promote products derived from 156019Shines@cs.fsu.edu * this software without specific prior written permission. 166019Shines@cs.fsu.edu * 176019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286019Shines@cs.fsu.edu * 296019Shines@cs.fsu.edu * Authors: Gabe Black 306019Shines@cs.fsu.edu * Stephen Hines 316019Shines@cs.fsu.edu */ 326019Shines@cs.fsu.edu 336019Shines@cs.fsu.edu#include "arch/arm/faults.hh" 346019Shines@cs.fsu.edu#include "cpu/thread_context.hh" 356019Shines@cs.fsu.edu#include "cpu/base.hh" 366019Shines@cs.fsu.edu#include "base/trace.hh" 376019Shines@cs.fsu.edu#if !FULL_SYSTEM 386019Shines@cs.fsu.edu#include "sim/process.hh" 396019Shines@cs.fsu.edu#include "mem/page_table.hh" 406019Shines@cs.fsu.edu#endif 416019Shines@cs.fsu.edu 426019Shines@cs.fsu.edunamespace ArmISA 436019Shines@cs.fsu.edu{ 446019Shines@cs.fsu.edu 456019Shines@cs.fsu.eduFaultName MachineCheckFault::_name = "Machine Check"; 466019Shines@cs.fsu.eduFaultVect MachineCheckFault::_vect = 0x0401; 476019Shines@cs.fsu.eduFaultStat MachineCheckFault::_count; 486019Shines@cs.fsu.edu 496019Shines@cs.fsu.eduFaultName AlignmentFault::_name = "Alignment"; 506019Shines@cs.fsu.eduFaultVect AlignmentFault::_vect = 0x0301; 516019Shines@cs.fsu.eduFaultStat AlignmentFault::_count; 526019Shines@cs.fsu.edu 536019Shines@cs.fsu.eduFaultName ResetFault::_name = "Reset Fault"; 546019Shines@cs.fsu.edu#if FULL_SYSTEM 556019Shines@cs.fsu.eduFaultVect ResetFault::_vect = 0xBFC00000; 566019Shines@cs.fsu.edu#else 576019Shines@cs.fsu.eduFaultVect ResetFault::_vect = 0x001; 586019Shines@cs.fsu.edu#endif 596019Shines@cs.fsu.eduFaultStat ResetFault::_count; 606019Shines@cs.fsu.edu 616019Shines@cs.fsu.eduFaultName AddressErrorFault::_name = "Address Error"; 626019Shines@cs.fsu.eduFaultVect AddressErrorFault::_vect = 0x0180; 636019Shines@cs.fsu.eduFaultStat AddressErrorFault::_count; 646019Shines@cs.fsu.edu 656019Shines@cs.fsu.eduFaultName StoreAddressErrorFault::_name = "Store Address Error"; 666019Shines@cs.fsu.eduFaultVect StoreAddressErrorFault::_vect = 0x0180; 676019Shines@cs.fsu.eduFaultStat StoreAddressErrorFault::_count; 686019Shines@cs.fsu.edu 696019Shines@cs.fsu.edu 706019Shines@cs.fsu.eduFaultName SystemCallFault::_name = "Syscall"; 716019Shines@cs.fsu.eduFaultVect SystemCallFault::_vect = 0x0180; 726019Shines@cs.fsu.eduFaultStat SystemCallFault::_count; 736019Shines@cs.fsu.edu 746019Shines@cs.fsu.eduFaultName CoprocessorUnusableFault::_name = "Coprocessor Unusable Fault"; 756019Shines@cs.fsu.eduFaultVect CoprocessorUnusableFault::_vect = 0x180; 766019Shines@cs.fsu.eduFaultStat CoprocessorUnusableFault::_count; 776019Shines@cs.fsu.edu 786019Shines@cs.fsu.eduFaultName ReservedInstructionFault::_name = "Reserved Instruction Fault"; 796019Shines@cs.fsu.eduFaultVect ReservedInstructionFault::_vect = 0x0180; 806019Shines@cs.fsu.eduFaultStat ReservedInstructionFault::_count; 816019Shines@cs.fsu.edu 826019Shines@cs.fsu.eduFaultName ThreadFault::_name = "Thread Fault"; 836019Shines@cs.fsu.eduFaultVect ThreadFault::_vect = 0x00F1; 846019Shines@cs.fsu.eduFaultStat ThreadFault::_count; 856019Shines@cs.fsu.edu 866019Shines@cs.fsu.edu 876019Shines@cs.fsu.eduFaultName ArithmeticFault::_name = "Arithmetic Overflow Exception"; 886019Shines@cs.fsu.eduFaultVect ArithmeticFault::_vect = 0x180; 896019Shines@cs.fsu.eduFaultStat ArithmeticFault::_count; 906019Shines@cs.fsu.edu 916019Shines@cs.fsu.eduFaultName UnimplementedOpcodeFault::_name = "opdec"; 926019Shines@cs.fsu.eduFaultVect UnimplementedOpcodeFault::_vect = 0x0481; 936019Shines@cs.fsu.eduFaultStat UnimplementedOpcodeFault::_count; 946019Shines@cs.fsu.edu 956019Shines@cs.fsu.eduFaultName InterruptFault::_name = "interrupt"; 966019Shines@cs.fsu.eduFaultVect InterruptFault::_vect = 0x0180; 976019Shines@cs.fsu.eduFaultStat InterruptFault::_count; 986019Shines@cs.fsu.edu 996019Shines@cs.fsu.eduFaultName TrapFault::_name = "Trap"; 1006019Shines@cs.fsu.eduFaultVect TrapFault::_vect = 0x0180; 1016019Shines@cs.fsu.eduFaultStat TrapFault::_count; 1026019Shines@cs.fsu.edu 1036019Shines@cs.fsu.eduFaultName BreakpointFault::_name = "Breakpoint"; 1046019Shines@cs.fsu.eduFaultVect BreakpointFault::_vect = 0x0180; 1056019Shines@cs.fsu.eduFaultStat BreakpointFault::_count; 1066019Shines@cs.fsu.edu 1076019Shines@cs.fsu.edu 1086019Shines@cs.fsu.eduFaultName ItbInvalidFault::_name = "Invalid TLB Entry Exception (I-Fetch/LW)"; 1096019Shines@cs.fsu.eduFaultVect ItbInvalidFault::_vect = 0x0180; 1106019Shines@cs.fsu.eduFaultStat ItbInvalidFault::_count; 1116019Shines@cs.fsu.edu 1126019Shines@cs.fsu.eduFaultName ItbPageFault::_name = "itbmiss"; 1136019Shines@cs.fsu.eduFaultVect ItbPageFault::_vect = 0x0181; 1146019Shines@cs.fsu.eduFaultStat ItbPageFault::_count; 1156019Shines@cs.fsu.edu 1166019Shines@cs.fsu.eduFaultName ItbMissFault::_name = "itbmiss"; 1176019Shines@cs.fsu.eduFaultVect ItbMissFault::_vect = 0x0181; 1186019Shines@cs.fsu.eduFaultStat ItbMissFault::_count; 1196019Shines@cs.fsu.edu 1206019Shines@cs.fsu.eduFaultName ItbAcvFault::_name = "iaccvio"; 1216019Shines@cs.fsu.eduFaultVect ItbAcvFault::_vect = 0x0081; 1226019Shines@cs.fsu.eduFaultStat ItbAcvFault::_count; 1236019Shines@cs.fsu.edu 1246019Shines@cs.fsu.eduFaultName ItbRefillFault::_name = "TLB Refill Exception (I-Fetch/LW)"; 1256019Shines@cs.fsu.eduFaultVect ItbRefillFault::_vect = 0x0180; 1266019Shines@cs.fsu.eduFaultStat ItbRefillFault::_count; 1276019Shines@cs.fsu.edu 1286019Shines@cs.fsu.eduFaultName NDtbMissFault::_name = "dtb_miss_single"; 1296019Shines@cs.fsu.eduFaultVect NDtbMissFault::_vect = 0x0201; 1306019Shines@cs.fsu.eduFaultStat NDtbMissFault::_count; 1316019Shines@cs.fsu.edu 1326019Shines@cs.fsu.eduFaultName PDtbMissFault::_name = "dtb_miss_double"; 1336019Shines@cs.fsu.eduFaultVect PDtbMissFault::_vect = 0x0281; 1346019Shines@cs.fsu.eduFaultStat PDtbMissFault::_count; 1356019Shines@cs.fsu.edu 1366019Shines@cs.fsu.eduFaultName DtbPageFault::_name = "dfault"; 1376019Shines@cs.fsu.eduFaultVect DtbPageFault::_vect = 0x0381; 1386019Shines@cs.fsu.eduFaultStat DtbPageFault::_count; 1396019Shines@cs.fsu.edu 1406019Shines@cs.fsu.eduFaultName DtbAcvFault::_name = "dfault"; 1416019Shines@cs.fsu.eduFaultVect DtbAcvFault::_vect = 0x0381; 1426019Shines@cs.fsu.eduFaultStat DtbAcvFault::_count; 1436019Shines@cs.fsu.edu 1446019Shines@cs.fsu.eduFaultName DtbInvalidFault::_name = "Invalid TLB Entry Exception (Store)"; 1456019Shines@cs.fsu.eduFaultVect DtbInvalidFault::_vect = 0x0180; 1466019Shines@cs.fsu.eduFaultStat DtbInvalidFault::_count; 1476019Shines@cs.fsu.edu 1486019Shines@cs.fsu.eduFaultName DtbRefillFault::_name = "TLB Refill Exception (Store)"; 1496019Shines@cs.fsu.eduFaultVect DtbRefillFault::_vect = 0x0180; 1506019Shines@cs.fsu.eduFaultStat DtbRefillFault::_count; 1516019Shines@cs.fsu.edu 1526019Shines@cs.fsu.eduFaultName TLBModifiedFault::_name = "TLB Modified Exception"; 1536019Shines@cs.fsu.eduFaultVect TLBModifiedFault::_vect = 0x0180; 1546019Shines@cs.fsu.eduFaultStat TLBModifiedFault::_count; 1556019Shines@cs.fsu.edu 1566019Shines@cs.fsu.eduFaultName FloatEnableFault::_name = "float_enable_fault"; 1576019Shines@cs.fsu.eduFaultVect FloatEnableFault::_vect = 0x0581; 1586019Shines@cs.fsu.eduFaultStat FloatEnableFault::_count; 1596019Shines@cs.fsu.edu 1606019Shines@cs.fsu.eduFaultName IntegerOverflowFault::_name = "Integer Overflow Fault"; 1616019Shines@cs.fsu.eduFaultVect IntegerOverflowFault::_vect = 0x0501; 1626019Shines@cs.fsu.eduFaultStat IntegerOverflowFault::_count; 1636019Shines@cs.fsu.edu 1646019Shines@cs.fsu.eduFaultName DspStateDisabledFault::_name = "DSP Disabled Fault"; 1656019Shines@cs.fsu.eduFaultVect DspStateDisabledFault::_vect = 0x001a; 1666019Shines@cs.fsu.eduFaultStat DspStateDisabledFault::_count; 1676019Shines@cs.fsu.edu 1686019Shines@cs.fsu.edu#if FULL_SYSTEM 1696019Shines@cs.fsu.eduvoid ArmFault::setHandlerPC(Addr HandlerBase, ThreadContext *tc) 1706019Shines@cs.fsu.edu{ 1716019Shines@cs.fsu.edu tc->setPC(HandlerBase); 1726019Shines@cs.fsu.edu tc->setNextPC(HandlerBase+sizeof(MachInst)); 1736019Shines@cs.fsu.edu tc->setNextNPC(HandlerBase+2*sizeof(MachInst)); 1746019Shines@cs.fsu.edu} 1756019Shines@cs.fsu.edu 1766019Shines@cs.fsu.eduvoid ArmFault::setExceptionState(ThreadContext *tc,uint8_t ExcCode) 1776019Shines@cs.fsu.edu{ 1786019Shines@cs.fsu.edu // modify SRS Ctl - Save CSS, put ESS into CSS 1796019Shines@cs.fsu.edu MiscReg stat = tc->readMiscReg(ArmISA::Status); 1806019Shines@cs.fsu.edu if(bits(stat,Status_EXL) != 1 && bits(stat,Status_BEV) != 1) 1816019Shines@cs.fsu.edu { 1826019Shines@cs.fsu.edu // SRS Ctl is modified only if Status_EXL and Status_BEV are not set 1836019Shines@cs.fsu.edu MiscReg srs = tc->readMiscReg(ArmISA::SRSCtl); 1846019Shines@cs.fsu.edu uint8_t CSS,ESS; 1856019Shines@cs.fsu.edu CSS = bits(srs,SRSCtl_CSS_HI,SRSCtl_CSS_LO); 1866019Shines@cs.fsu.edu ESS = bits(srs,SRSCtl_ESS_HI,SRSCtl_ESS_LO); 1876019Shines@cs.fsu.edu // Move CSS to PSS 1886019Shines@cs.fsu.edu replaceBits(srs,SRSCtl_PSS_HI,SRSCtl_PSS_LO,CSS); 1896019Shines@cs.fsu.edu // Move ESS to CSS 1906019Shines@cs.fsu.edu replaceBits(srs,SRSCtl_CSS_HI,SRSCtl_CSS_LO,ESS); 1916019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::SRSCtl,srs); 1926019Shines@cs.fsu.edu //tc->setShadowSet(ESS); 1936019Shines@cs.fsu.edu } 1946019Shines@cs.fsu.edu 1956019Shines@cs.fsu.edu // set EXL bit (don't care if it is already set!) 1966019Shines@cs.fsu.edu replaceBits(stat,Status_EXL_HI,Status_EXL_LO,1); 1976019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::Status,stat); 1986019Shines@cs.fsu.edu 1996019Shines@cs.fsu.edu // write EPC 2006019Shines@cs.fsu.edu // warn("Set EPC to %x\n",tc->readPC()); 2016019Shines@cs.fsu.edu // CHECK ME or FIXME or FIX ME or POSSIBLE HACK 2026019Shines@cs.fsu.edu // Check to see if the exception occurred in the branch delay slot 2036019Shines@cs.fsu.edu DPRINTF(Arm,"PC: %x, NextPC: %x, NNPC: %x\n",tc->readPC(),tc->readNextPC(),tc->readNextNPC()); 2046019Shines@cs.fsu.edu int C_BD=0; 2056019Shines@cs.fsu.edu if(tc->readPC() + sizeof(MachInst) != tc->readNextPC()){ 2066019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::EPC,tc->readPC()-sizeof(MachInst)); 2076019Shines@cs.fsu.edu // In the branch delay slot? set CAUSE_31 2086019Shines@cs.fsu.edu C_BD = 1; 2096019Shines@cs.fsu.edu } else { 2106019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::EPC,tc->readPC()); 2116019Shines@cs.fsu.edu // In the branch delay slot? reset CAUSE_31 2126019Shines@cs.fsu.edu C_BD = 0; 2136019Shines@cs.fsu.edu } 2146019Shines@cs.fsu.edu 2156019Shines@cs.fsu.edu // Set Cause_EXCCODE field 2166019Shines@cs.fsu.edu MiscReg cause = tc->readMiscReg(ArmISA::Cause); 2176019Shines@cs.fsu.edu replaceBits(cause,Cause_EXCCODE_HI,Cause_EXCCODE_LO,ExcCode); 2186019Shines@cs.fsu.edu replaceBits(cause,Cause_BD_HI,Cause_BD_LO,C_BD); 2196019Shines@cs.fsu.edu replaceBits(cause,Cause_CE_HI,Cause_CE_LO,0); 2206019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::Cause,cause); 2216019Shines@cs.fsu.edu 2226019Shines@cs.fsu.edu} 2236019Shines@cs.fsu.edu 2246019Shines@cs.fsu.eduvoid ArithmeticFault::invoke(ThreadContext *tc) 2256019Shines@cs.fsu.edu{ 2266019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 2276019Shines@cs.fsu.edu setExceptionState(tc,0xC); 2286019Shines@cs.fsu.edu 2296019Shines@cs.fsu.edu // Set new PC 2306019Shines@cs.fsu.edu Addr HandlerBase; 2316019Shines@cs.fsu.edu MiscReg stat = tc->readMiscReg(ArmISA::Status); 2326019Shines@cs.fsu.edu // Here, the handler is dependent on BEV, which is not modified by setExceptionState() 2336019Shines@cs.fsu.edu if(bits(stat,Status_BEV)==0){ // See MIPS ARM Vol 3, Revision 2, Page 38 2346019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); 2356019Shines@cs.fsu.edu }else{ 2366019Shines@cs.fsu.edu HandlerBase = 0xBFC00200; 2376019Shines@cs.fsu.edu } 2386019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 2396019Shines@cs.fsu.edu // warn("Exception Handler At: %x \n",HandlerBase); 2406019Shines@cs.fsu.edu} 2416019Shines@cs.fsu.edu 2426019Shines@cs.fsu.eduvoid StoreAddressErrorFault::invoke(ThreadContext *tc) 2436019Shines@cs.fsu.edu{ 2446019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 2456019Shines@cs.fsu.edu setExceptionState(tc,0x5); 2466019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::BadVAddr,BadVAddr); 2476019Shines@cs.fsu.edu 2486019Shines@cs.fsu.edu // Set new PC 2496019Shines@cs.fsu.edu Addr HandlerBase; 2506019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 2516019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 2526019Shines@cs.fsu.edu // warn("Exception Handler At: %x \n",HandlerBase); 2536019Shines@cs.fsu.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(ArmISA::EPC)); 2546019Shines@cs.fsu.edu 2556019Shines@cs.fsu.edu} 2566019Shines@cs.fsu.edu 2576019Shines@cs.fsu.eduvoid TrapFault::invoke(ThreadContext *tc) 2586019Shines@cs.fsu.edu{ 2596019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 2606019Shines@cs.fsu.edu // warn("%s encountered.\n", name()); 2616019Shines@cs.fsu.edu setExceptionState(tc,0xD); 2626019Shines@cs.fsu.edu 2636019Shines@cs.fsu.edu // Set new PC 2646019Shines@cs.fsu.edu Addr HandlerBase; 2656019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 2666019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 2676019Shines@cs.fsu.edu // warn("Exception Handler At: %x \n",HandlerBase); 2686019Shines@cs.fsu.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(ArmISA::EPC)); 2696019Shines@cs.fsu.edu} 2706019Shines@cs.fsu.edu 2716019Shines@cs.fsu.eduvoid BreakpointFault::invoke(ThreadContext *tc) 2726019Shines@cs.fsu.edu{ 2736019Shines@cs.fsu.edu setExceptionState(tc,0x9); 2746019Shines@cs.fsu.edu 2756019Shines@cs.fsu.edu // Set new PC 2766019Shines@cs.fsu.edu Addr HandlerBase; 2776019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 2786019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 2796019Shines@cs.fsu.edu // warn("Exception Handler At: %x \n",HandlerBase); 2806019Shines@cs.fsu.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(ArmISA::EPC)); 2816019Shines@cs.fsu.edu 2826019Shines@cs.fsu.edu} 2836019Shines@cs.fsu.edu 2846019Shines@cs.fsu.eduvoid DtbInvalidFault::invoke(ThreadContext *tc) 2856019Shines@cs.fsu.edu{ 2866019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 2876019Shines@cs.fsu.edu // warn("%s encountered.\n", name()); 2886019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::BadVAddr,BadVAddr); 2896019Shines@cs.fsu.edu MiscReg eh = tc->readMiscReg(ArmISA::EntryHi); 2906019Shines@cs.fsu.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 2916019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 2926019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 2936019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::EntryHi,eh); 2946019Shines@cs.fsu.edu MiscReg ctxt = tc->readMiscReg(ArmISA::Context); 2956019Shines@cs.fsu.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 2966019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::Context,ctxt); 2976019Shines@cs.fsu.edu setExceptionState(tc,0x3); 2986019Shines@cs.fsu.edu 2996019Shines@cs.fsu.edu 3006019Shines@cs.fsu.edu // Set new PC 3016019Shines@cs.fsu.edu Addr HandlerBase; 3026019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 3036019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 3046019Shines@cs.fsu.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(ArmISA::EPC)); 3056019Shines@cs.fsu.edu} 3066019Shines@cs.fsu.edu 3076019Shines@cs.fsu.eduvoid AddressErrorFault::invoke(ThreadContext *tc) 3086019Shines@cs.fsu.edu{ 3096019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 3106019Shines@cs.fsu.edu setExceptionState(tc,0x4); 3116019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::BadVAddr,BadVAddr); 3126019Shines@cs.fsu.edu 3136019Shines@cs.fsu.edu // Set new PC 3146019Shines@cs.fsu.edu Addr HandlerBase; 3156019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 3166019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 3176019Shines@cs.fsu.edu} 3186019Shines@cs.fsu.edu 3196019Shines@cs.fsu.eduvoid ItbInvalidFault::invoke(ThreadContext *tc) 3206019Shines@cs.fsu.edu{ 3216019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 3226019Shines@cs.fsu.edu setExceptionState(tc,0x2); 3236019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::BadVAddr,BadVAddr); 3246019Shines@cs.fsu.edu MiscReg eh = tc->readMiscReg(ArmISA::EntryHi); 3256019Shines@cs.fsu.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 3266019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 3276019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 3286019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::EntryHi,eh); 3296019Shines@cs.fsu.edu MiscReg ctxt = tc->readMiscReg(ArmISA::Context); 3306019Shines@cs.fsu.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 3316019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::Context,ctxt); 3326019Shines@cs.fsu.edu 3336019Shines@cs.fsu.edu 3346019Shines@cs.fsu.edu // Set new PC 3356019Shines@cs.fsu.edu Addr HandlerBase; 3366019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 3376019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 3386019Shines@cs.fsu.edu DPRINTF(Arm,"Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(ArmISA::EPC)); 3396019Shines@cs.fsu.edu} 3406019Shines@cs.fsu.edu 3416019Shines@cs.fsu.eduvoid ItbRefillFault::invoke(ThreadContext *tc) 3426019Shines@cs.fsu.edu{ 3436019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered (%x).\n", name(),BadVAddr); 3446019Shines@cs.fsu.edu Addr HandlerBase; 3456019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::BadVAddr,BadVAddr); 3466019Shines@cs.fsu.edu MiscReg eh = tc->readMiscReg(ArmISA::EntryHi); 3476019Shines@cs.fsu.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 3486019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 3496019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 3506019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::EntryHi,eh); 3516019Shines@cs.fsu.edu MiscReg ctxt = tc->readMiscReg(ArmISA::Context); 3526019Shines@cs.fsu.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 3536019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::Context,ctxt); 3546019Shines@cs.fsu.edu 3556019Shines@cs.fsu.edu MiscReg stat = tc->readMiscReg(ArmISA::Status); 3566019Shines@cs.fsu.edu // Since handler depends on EXL bit, must check EXL bit before setting it!! 3576019Shines@cs.fsu.edu if(bits(stat,Status_EXL)==1){ // See MIPS ARM Vol 3, Revision 2, Page 38 3586019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 3596019Shines@cs.fsu.edu }else{ 3606019Shines@cs.fsu.edu HandlerBase = tc->readMiscReg(ArmISA::EBase); // Offset 0x000 3616019Shines@cs.fsu.edu } 3626019Shines@cs.fsu.edu 3636019Shines@cs.fsu.edu setExceptionState(tc,0x2); 3646019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 3656019Shines@cs.fsu.edu} 3666019Shines@cs.fsu.edu 3676019Shines@cs.fsu.eduvoid DtbRefillFault::invoke(ThreadContext *tc) 3686019Shines@cs.fsu.edu{ 3696019Shines@cs.fsu.edu // Set new PC 3706019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 3716019Shines@cs.fsu.edu Addr HandlerBase; 3726019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::BadVAddr,BadVAddr); 3736019Shines@cs.fsu.edu MiscReg eh = tc->readMiscReg(ArmISA::EntryHi); 3746019Shines@cs.fsu.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 3756019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 3766019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 3776019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::EntryHi,eh); 3786019Shines@cs.fsu.edu MiscReg ctxt = tc->readMiscReg(ArmISA::Context); 3796019Shines@cs.fsu.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 3806019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::Context,ctxt); 3816019Shines@cs.fsu.edu 3826019Shines@cs.fsu.edu MiscReg stat = tc->readMiscReg(ArmISA::Status); 3836019Shines@cs.fsu.edu // Since handler depends on EXL bit, must check EXL bit before setting it!! 3846019Shines@cs.fsu.edu if(bits(stat,Status_EXL)==1){ // See MIPS ARM Vol 3, Revision 2, Page 38 3856019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 3866019Shines@cs.fsu.edu }else{ 3876019Shines@cs.fsu.edu HandlerBase = tc->readMiscReg(ArmISA::EBase); // Offset 0x000 3886019Shines@cs.fsu.edu } 3896019Shines@cs.fsu.edu 3906019Shines@cs.fsu.edu 3916019Shines@cs.fsu.edu setExceptionState(tc,0x3); 3926019Shines@cs.fsu.edu 3936019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 3946019Shines@cs.fsu.edu} 3956019Shines@cs.fsu.edu 3966019Shines@cs.fsu.eduvoid TLBModifiedFault::invoke(ThreadContext *tc) 3976019Shines@cs.fsu.edu{ 3986019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 3996019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::BadVAddr,BadVAddr); 4006019Shines@cs.fsu.edu MiscReg eh = tc->readMiscReg(ArmISA::EntryHi); 4016019Shines@cs.fsu.edu replaceBits(eh,EntryHi_ASID_HI,EntryHi_ASID_LO,EntryHi_Asid); 4026019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2_HI,EntryHi_VPN2_LO,EntryHi_VPN2); 4036019Shines@cs.fsu.edu replaceBits(eh,EntryHi_VPN2X_HI,EntryHi_VPN2X_LO,EntryHi_VPN2X); 4046019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::EntryHi,eh); 4056019Shines@cs.fsu.edu MiscReg ctxt = tc->readMiscReg(ArmISA::Context); 4066019Shines@cs.fsu.edu replaceBits(ctxt,Context_BadVPN2_HI,Context_BadVPN2_LO,Context_BadVPN2); 4076019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::Context,ctxt); 4086019Shines@cs.fsu.edu 4096019Shines@cs.fsu.edu // Set new PC 4106019Shines@cs.fsu.edu Addr HandlerBase; 4116019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 4126019Shines@cs.fsu.edu setExceptionState(tc,0x1); 4136019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 4146019Shines@cs.fsu.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(ArmISA::EPC)); 4156019Shines@cs.fsu.edu 4166019Shines@cs.fsu.edu} 4176019Shines@cs.fsu.edu 4186019Shines@cs.fsu.eduvoid SystemCallFault::invoke(ThreadContext *tc) 4196019Shines@cs.fsu.edu{ 4206019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 4216019Shines@cs.fsu.edu setExceptionState(tc,0x8); 4226019Shines@cs.fsu.edu 4236019Shines@cs.fsu.edu // Set new PC 4246019Shines@cs.fsu.edu Addr HandlerBase; 4256019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 4266019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 4276019Shines@cs.fsu.edu // warn("Exception Handler At: %x \n",HandlerBase); 4286019Shines@cs.fsu.edu // warn("Exception Handler At: %x , EPC set to %x\n",HandlerBase,tc->readMiscReg(ArmISA::EPC)); 4296019Shines@cs.fsu.edu 4306019Shines@cs.fsu.edu} 4316019Shines@cs.fsu.edu 4326019Shines@cs.fsu.eduvoid InterruptFault::invoke(ThreadContext *tc) 4336019Shines@cs.fsu.edu{ 4346019Shines@cs.fsu.edu#if FULL_SYSTEM 4356019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 4366019Shines@cs.fsu.edu //RegFile *Reg = tc->getRegFilePtr(); // Get pointer to the register fil 4376019Shines@cs.fsu.edu setExceptionState(tc,0x0A); 4386019Shines@cs.fsu.edu Addr HandlerBase; 4396019Shines@cs.fsu.edu 4406019Shines@cs.fsu.edu 4416019Shines@cs.fsu.edu uint8_t IV = bits(tc->readMiscRegNoEffect(ArmISA::Cause),Cause_IV); 4426019Shines@cs.fsu.edu if (IV)// Offset 200 for release 2 4436019Shines@cs.fsu.edu HandlerBase= 0x20 + vect() + tc->readMiscRegNoEffect(ArmISA::EBase); 4446019Shines@cs.fsu.edu else//Ofset at 180 for release 1 4456019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscRegNoEffect(ArmISA::EBase); 4466019Shines@cs.fsu.edu 4476019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 4486019Shines@cs.fsu.edu#endif 4496019Shines@cs.fsu.edu} 4506019Shines@cs.fsu.edu 4516019Shines@cs.fsu.edu#endif // FULL_SYSTEM 4526019Shines@cs.fsu.edu 4536019Shines@cs.fsu.eduvoid ResetFault::invoke(ThreadContext *tc) 4546019Shines@cs.fsu.edu{ 4556019Shines@cs.fsu.edu#if FULL_SYSTEM 4566019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 4576019Shines@cs.fsu.edu /* All reset activity must be invoked from here */ 4586019Shines@cs.fsu.edu tc->setPC(vect()); 4596019Shines@cs.fsu.edu tc->setNextPC(vect()+sizeof(MachInst)); 4606019Shines@cs.fsu.edu tc->setNextNPC(vect()+sizeof(MachInst)+sizeof(MachInst)); 4616019Shines@cs.fsu.edu DPRINTF(Arm,"(%x) - ResetFault::invoke : PC set to %x",(unsigned)tc,(unsigned)tc->readPC()); 4626019Shines@cs.fsu.edu#endif 4636019Shines@cs.fsu.edu 4646019Shines@cs.fsu.edu // Set Coprocessor 1 (Floating Point) To Usable 4656019Shines@cs.fsu.edu //tc->setMiscReg(ArmISA::Status, ArmISA::Status | 0x20000000); 4666019Shines@cs.fsu.edu} 4676019Shines@cs.fsu.edu 4686019Shines@cs.fsu.eduvoid ReservedInstructionFault::invoke(ThreadContext *tc) 4696019Shines@cs.fsu.edu{ 4706019Shines@cs.fsu.edu#if FULL_SYSTEM 4716019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 4726019Shines@cs.fsu.edu //RegFile *Reg = tc->getRegFilePtr(); // Get pointer to the register fil 4736019Shines@cs.fsu.edu setExceptionState(tc,0x0A); 4746019Shines@cs.fsu.edu Addr HandlerBase; 4756019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscRegNoEffect(ArmISA::EBase); // Offset 0x180 - General Exception Vector 4766019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 4776019Shines@cs.fsu.edu#else 4786019Shines@cs.fsu.edu panic("%s encountered.\n", name()); 4796019Shines@cs.fsu.edu#endif 4806019Shines@cs.fsu.edu} 4816019Shines@cs.fsu.edu 4826019Shines@cs.fsu.eduvoid ThreadFault::invoke(ThreadContext *tc) 4836019Shines@cs.fsu.edu{ 4846019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 4856019Shines@cs.fsu.edu panic("%s encountered.\n", name()); 4866019Shines@cs.fsu.edu} 4876019Shines@cs.fsu.edu 4886019Shines@cs.fsu.eduvoid DspStateDisabledFault::invoke(ThreadContext *tc) 4896019Shines@cs.fsu.edu{ 4906019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 4916019Shines@cs.fsu.edu panic("%s encountered.\n", name()); 4926019Shines@cs.fsu.edu} 4936019Shines@cs.fsu.edu 4946019Shines@cs.fsu.eduvoid CoprocessorUnusableFault::invoke(ThreadContext *tc) 4956019Shines@cs.fsu.edu{ 4966019Shines@cs.fsu.edu#if FULL_SYSTEM 4976019Shines@cs.fsu.edu DPRINTF(Arm,"%s encountered.\n", name()); 4986019Shines@cs.fsu.edu setExceptionState(tc,0xb); 4996019Shines@cs.fsu.edu /* The ID of the coprocessor causing the exception is stored in CoprocessorUnusableFault::coProcID */ 5006019Shines@cs.fsu.edu MiscReg cause = tc->readMiscReg(ArmISA::Cause); 5016019Shines@cs.fsu.edu replaceBits(cause,Cause_CE_HI,Cause_CE_LO,coProcID); 5026019Shines@cs.fsu.edu tc->setMiscRegNoEffect(ArmISA::Cause,cause); 5036019Shines@cs.fsu.edu 5046019Shines@cs.fsu.edu Addr HandlerBase; 5056019Shines@cs.fsu.edu HandlerBase= vect() + tc->readMiscReg(ArmISA::EBase); // Offset 0x180 - General Exception Vector 5066019Shines@cs.fsu.edu setHandlerPC(HandlerBase,tc); 5076019Shines@cs.fsu.edu 5086019Shines@cs.fsu.edu // warn("Status: %x, Cause: %x\n",tc->readMiscReg(ArmISA::Status),tc->readMiscReg(ArmISA::Cause)); 5096019Shines@cs.fsu.edu#else 5106019Shines@cs.fsu.edu warn("%s (CP%d) encountered.\n", name(), coProcID); 5116019Shines@cs.fsu.edu#endif 5126019Shines@cs.fsu.edu} 5136019Shines@cs.fsu.edu 5146019Shines@cs.fsu.edu} // namespace ArmISA 5156019Shines@cs.fsu.edu 516