faults.cc revision 7678
12131SN/A/* 25268Sksewell@umich.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan 35254Sksewell@umich.edu * Copyright (c) 2007 MIPS Technologies, Inc. 45254Sksewell@umich.edu * All rights reserved. 52131SN/A * 65254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 75254Sksewell@umich.edu * modification, are permitted provided that the following conditions are 85254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 95254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 105254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 115254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 125254Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 135254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 145254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 155254Sksewell@umich.edu * this software without specific prior written permission. 162131SN/A * 175254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 185254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 195254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 205254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 225254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 275254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu * 295254Sksewell@umich.edu * Authors: Gabe Black 305254Sksewell@umich.edu * Korey Sewell 315222Sksewell@umich.edu * Jaidev Patwardhan 322131SN/A */ 332131SN/A 342239SN/A#include "arch/mips/faults.hh" 357676Snate@binkert.org#include "arch/mips/pra_constants.hh" 367676Snate@binkert.org#include "base/trace.hh" 377676Snate@binkert.org#include "cpu/base.hh" 382680Sktlim@umich.edu#include "cpu/thread_context.hh" 397676Snate@binkert.org 402800Ssaidi@eecs.umich.edu#if !FULL_SYSTEM 417676Snate@binkert.org#include "mem/page_table.hh" 422800Ssaidi@eecs.umich.edu#include "sim/process.hh" 432800Ssaidi@eecs.umich.edu#endif 442131SN/A 452447SN/Anamespace MipsISA 462447SN/A{ 472131SN/A 482479SN/AFaultName MachineCheckFault::_name = "Machine Check"; 492447SN/AFaultVect MachineCheckFault::_vect = 0x0401; 502447SN/AFaultStat MachineCheckFault::_count; 512131SN/A 522479SN/AFaultName AlignmentFault::_name = "Alignment"; 532447SN/AFaultVect AlignmentFault::_vect = 0x0301; 542447SN/AFaultStat AlignmentFault::_count; 552447SN/A 565224Sksewell@umich.eduFaultName ResetFault::_name = "Reset Fault"; 575222Sksewell@umich.edu#if FULL_SYSTEM 585222Sksewell@umich.eduFaultVect ResetFault::_vect = 0xBFC00000; 595222Sksewell@umich.edu#else 605222Sksewell@umich.eduFaultVect ResetFault::_vect = 0x001; 615222Sksewell@umich.edu#endif 622447SN/AFaultStat ResetFault::_count; 632447SN/A 645222Sksewell@umich.eduFaultName AddressErrorFault::_name = "Address Error"; 655222Sksewell@umich.eduFaultVect AddressErrorFault::_vect = 0x0180; 665222Sksewell@umich.eduFaultStat AddressErrorFault::_count; 675222Sksewell@umich.edu 685222Sksewell@umich.eduFaultName StoreAddressErrorFault::_name = "Store Address Error"; 695222Sksewell@umich.eduFaultVect StoreAddressErrorFault::_vect = 0x0180; 705222Sksewell@umich.eduFaultStat StoreAddressErrorFault::_count; 715222Sksewell@umich.edu 725222Sksewell@umich.edu 735222Sksewell@umich.eduFaultName SystemCallFault::_name = "Syscall"; 745222Sksewell@umich.eduFaultVect SystemCallFault::_vect = 0x0180; 755222Sksewell@umich.eduFaultStat SystemCallFault::_count; 765222Sksewell@umich.edu 775224Sksewell@umich.eduFaultName CoprocessorUnusableFault::_name = "Coprocessor Unusable Fault"; 785222Sksewell@umich.eduFaultVect CoprocessorUnusableFault::_vect = 0x180; 794661Sksewell@umich.eduFaultStat CoprocessorUnusableFault::_count; 804661Sksewell@umich.edu 815224Sksewell@umich.eduFaultName ReservedInstructionFault::_name = "Reserved Instruction Fault"; 825222Sksewell@umich.eduFaultVect ReservedInstructionFault::_vect = 0x0180; 834661Sksewell@umich.eduFaultStat ReservedInstructionFault::_count; 844661Sksewell@umich.edu 855224Sksewell@umich.eduFaultName ThreadFault::_name = "Thread Fault"; 864661Sksewell@umich.eduFaultVect ThreadFault::_vect = 0x00F1; 874661Sksewell@umich.eduFaultStat ThreadFault::_count; 884661Sksewell@umich.edu 895222Sksewell@umich.eduFaultName ArithmeticFault::_name = "Arithmetic Overflow Exception"; 905222Sksewell@umich.eduFaultVect ArithmeticFault::_vect = 0x180; 912447SN/AFaultStat ArithmeticFault::_count; 922447SN/A 934661Sksewell@umich.eduFaultName UnimplementedOpcodeFault::_name = "opdec"; 944661Sksewell@umich.eduFaultVect UnimplementedOpcodeFault::_vect = 0x0481; 954661Sksewell@umich.eduFaultStat UnimplementedOpcodeFault::_count; 964661Sksewell@umich.edu 972447SN/AFaultName InterruptFault::_name = "interrupt"; 985222Sksewell@umich.eduFaultVect InterruptFault::_vect = 0x0180; 992447SN/AFaultStat InterruptFault::_count; 1002447SN/A 1015222Sksewell@umich.eduFaultName TrapFault::_name = "Trap"; 1025222Sksewell@umich.eduFaultVect TrapFault::_vect = 0x0180; 1035222Sksewell@umich.eduFaultStat TrapFault::_count; 1045222Sksewell@umich.edu 1055222Sksewell@umich.eduFaultName BreakpointFault::_name = "Breakpoint"; 1065222Sksewell@umich.eduFaultVect BreakpointFault::_vect = 0x0180; 1075222Sksewell@umich.eduFaultStat BreakpointFault::_count; 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 1706378Sgblack@eecs.umich.eduvoid 1716378Sgblack@eecs.umich.eduMipsFault::setHandlerPC(Addr HandlerBase, ThreadContext *tc) 1725222Sksewell@umich.edu{ 1736378Sgblack@eecs.umich.edu tc->setPC(HandlerBase); 1746378Sgblack@eecs.umich.edu tc->setNextPC(HandlerBase + sizeof(MachInst)); 1756378Sgblack@eecs.umich.edu tc->setNextNPC(HandlerBase + 2 * sizeof(MachInst)); 1765222Sksewell@umich.edu} 1775222Sksewell@umich.edu 1786378Sgblack@eecs.umich.eduvoid 1796379Sgblack@eecs.umich.eduMipsFault::setExceptionState(ThreadContext *tc, uint8_t excCode) 1805222Sksewell@umich.edu{ 1816378Sgblack@eecs.umich.edu // modify SRS Ctl - Save CSS, put ESS into CSS 1826383Sgblack@eecs.umich.edu StatusReg status = tc->readMiscReg(MISCREG_STATUS); 1836379Sgblack@eecs.umich.edu if (status.exl != 1 && status.bev != 1) { 1846378Sgblack@eecs.umich.edu // SRS Ctl is modified only if Status_EXL and Status_BEV are not set 1856383Sgblack@eecs.umich.edu SRSCtlReg srsCtl = tc->readMiscReg(MISCREG_SRSCTL); 1866379Sgblack@eecs.umich.edu srsCtl.pss = srsCtl.css; 1876379Sgblack@eecs.umich.edu srsCtl.css = srsCtl.ess; 1886383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_SRSCTL, srsCtl); 1895222Sksewell@umich.edu } 1905222Sksewell@umich.edu 1916378Sgblack@eecs.umich.edu // set EXL bit (don't care if it is already set!) 1926379Sgblack@eecs.umich.edu status.exl = 1; 1936383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_STATUS, status); 1945222Sksewell@umich.edu 1956378Sgblack@eecs.umich.edu // write EPC 1966378Sgblack@eecs.umich.edu // CHECK ME or FIXME or FIX ME or POSSIBLE HACK 1976378Sgblack@eecs.umich.edu // Check to see if the exception occurred in the branch delay slot 1986378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "PC: %x, NextPC: %x, NNPC: %x\n", 1996378Sgblack@eecs.umich.edu tc->readPC(), tc->readNextPC(), tc->readNextNPC()); 2006379Sgblack@eecs.umich.edu int bd = 0; 2016378Sgblack@eecs.umich.edu if (tc->readPC() + sizeof(MachInst) != tc->readNextPC()) { 2026383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_EPC, tc->readPC() - sizeof(MachInst)); 2036378Sgblack@eecs.umich.edu // In the branch delay slot? set CAUSE_31 2046379Sgblack@eecs.umich.edu bd = 1; 2056378Sgblack@eecs.umich.edu } else { 2066383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_EPC, tc->readPC()); 2076378Sgblack@eecs.umich.edu // In the branch delay slot? reset CAUSE_31 2086379Sgblack@eecs.umich.edu bd = 0; 2096378Sgblack@eecs.umich.edu } 2105222Sksewell@umich.edu 2116378Sgblack@eecs.umich.edu // Set Cause_EXCCODE field 2126383Sgblack@eecs.umich.edu CauseReg cause = tc->readMiscReg(MISCREG_CAUSE); 2136379Sgblack@eecs.umich.edu cause.excCode = excCode; 2146379Sgblack@eecs.umich.edu cause.bd = bd; 2156379Sgblack@eecs.umich.edu cause.ce = 0; 2166383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_CAUSE, cause); 2176378Sgblack@eecs.umich.edu} 2186378Sgblack@eecs.umich.edu 2196378Sgblack@eecs.umich.eduvoid 2207678Sgblack@eecs.umich.eduArithmeticFault::invoke(ThreadContext *tc, StaticInstPtr inst) 2216378Sgblack@eecs.umich.edu{ 2226378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 2236378Sgblack@eecs.umich.edu setExceptionState(tc, 0xC); 2246378Sgblack@eecs.umich.edu 2256378Sgblack@eecs.umich.edu // Set new PC 2266378Sgblack@eecs.umich.edu Addr HandlerBase; 2276383Sgblack@eecs.umich.edu StatusReg status = tc->readMiscReg(MISCREG_STATUS); 2286378Sgblack@eecs.umich.edu // Here, the handler is dependent on BEV, which is not modified by 2296378Sgblack@eecs.umich.edu // setExceptionState() 2306379Sgblack@eecs.umich.edu if (!status.bev) { 2316378Sgblack@eecs.umich.edu // See MIPS ARM Vol 3, Revision 2, Page 38 2326383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 2336378Sgblack@eecs.umich.edu } else { 2346378Sgblack@eecs.umich.edu HandlerBase = 0xBFC00200; 2356378Sgblack@eecs.umich.edu } 2366378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 2376378Sgblack@eecs.umich.edu} 2386378Sgblack@eecs.umich.edu 2396378Sgblack@eecs.umich.eduvoid 2407678Sgblack@eecs.umich.eduStoreAddressErrorFault::invoke(ThreadContext *tc, StaticInstPtr inst) 2416378Sgblack@eecs.umich.edu{ 2426378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 2436378Sgblack@eecs.umich.edu setExceptionState(tc, 0x5); 2446383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 2456378Sgblack@eecs.umich.edu 2466378Sgblack@eecs.umich.edu // Set new PC 2476378Sgblack@eecs.umich.edu Addr HandlerBase; 2486378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 2496383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 2506378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 2516378Sgblack@eecs.umich.edu} 2526378Sgblack@eecs.umich.edu 2536378Sgblack@eecs.umich.eduvoid 2547678Sgblack@eecs.umich.eduTrapFault::invoke(ThreadContext *tc, StaticInstPtr inst) 2556378Sgblack@eecs.umich.edu{ 2566378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 2576378Sgblack@eecs.umich.edu setExceptionState(tc, 0xD); 2586378Sgblack@eecs.umich.edu 2596378Sgblack@eecs.umich.edu // Set new PC 2606378Sgblack@eecs.umich.edu Addr HandlerBase; 2616378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 2626383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 2636378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 2646378Sgblack@eecs.umich.edu} 2656378Sgblack@eecs.umich.edu 2666378Sgblack@eecs.umich.eduvoid 2677678Sgblack@eecs.umich.eduBreakpointFault::invoke(ThreadContext *tc, StaticInstPtr inst) 2686378Sgblack@eecs.umich.edu{ 2696378Sgblack@eecs.umich.edu setExceptionState(tc, 0x9); 2706378Sgblack@eecs.umich.edu 2716378Sgblack@eecs.umich.edu // Set new PC 2726378Sgblack@eecs.umich.edu Addr HandlerBase; 2736378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 2746383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 2756378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 2766378Sgblack@eecs.umich.edu} 2776378Sgblack@eecs.umich.edu 2786378Sgblack@eecs.umich.eduvoid 2797678Sgblack@eecs.umich.eduDtbInvalidFault::invoke(ThreadContext *tc, StaticInstPtr inst) 2806378Sgblack@eecs.umich.edu{ 2816378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 2826378Sgblack@eecs.umich.edu 2836383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 2846383Sgblack@eecs.umich.edu EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 2856379Sgblack@eecs.umich.edu entryHi.asid = entryHiAsid; 2866379Sgblack@eecs.umich.edu entryHi.vpn2 = entryHiVPN2; 2876379Sgblack@eecs.umich.edu entryHi.vpn2x = entryHiVPN2X; 2886383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 2896379Sgblack@eecs.umich.edu 2906383Sgblack@eecs.umich.edu ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 2916379Sgblack@eecs.umich.edu context.badVPN2 = contextBadVPN2; 2926383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 2936378Sgblack@eecs.umich.edu setExceptionState(tc, 0x3); 2946378Sgblack@eecs.umich.edu 2956378Sgblack@eecs.umich.edu 2966378Sgblack@eecs.umich.edu // Set new PC 2976378Sgblack@eecs.umich.edu Addr HandlerBase; 2986378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 2996383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 3006379Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 3016378Sgblack@eecs.umich.edu} 3026378Sgblack@eecs.umich.edu 3036378Sgblack@eecs.umich.eduvoid 3047678Sgblack@eecs.umich.eduAddressErrorFault::invoke(ThreadContext *tc, StaticInstPtr inst) 3056378Sgblack@eecs.umich.edu{ 3066378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 3076378Sgblack@eecs.umich.edu setExceptionState(tc, 0x4); 3086383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 3096378Sgblack@eecs.umich.edu 3106378Sgblack@eecs.umich.edu // Set new PC 3116378Sgblack@eecs.umich.edu Addr HandlerBase; 3126378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 3136383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 3146378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 3156378Sgblack@eecs.umich.edu} 3166378Sgblack@eecs.umich.edu 3176378Sgblack@eecs.umich.eduvoid 3187678Sgblack@eecs.umich.eduItbInvalidFault::invoke(ThreadContext *tc, StaticInstPtr inst) 3196378Sgblack@eecs.umich.edu{ 3206378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 3216378Sgblack@eecs.umich.edu setExceptionState(tc, 0x2); 3226383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 3236383Sgblack@eecs.umich.edu EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 3246379Sgblack@eecs.umich.edu entryHi.asid = entryHiAsid; 3256379Sgblack@eecs.umich.edu entryHi.vpn2 = entryHiVPN2; 3266379Sgblack@eecs.umich.edu entryHi.vpn2x = entryHiVPN2X; 3276383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 3286379Sgblack@eecs.umich.edu 3296383Sgblack@eecs.umich.edu ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 3306379Sgblack@eecs.umich.edu context.badVPN2 = contextBadVPN2; 3316383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 3326378Sgblack@eecs.umich.edu 3336378Sgblack@eecs.umich.edu 3346378Sgblack@eecs.umich.edu // Set new PC 3356378Sgblack@eecs.umich.edu Addr HandlerBase; 3366378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 3376383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 3386378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase,tc); 3396379Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "Exception Handler At: %x , EPC set to %x\n", 3406383Sgblack@eecs.umich.edu HandlerBase, tc->readMiscReg(MISCREG_EPC)); 3416378Sgblack@eecs.umich.edu} 3426378Sgblack@eecs.umich.edu 3436378Sgblack@eecs.umich.eduvoid 3447678Sgblack@eecs.umich.eduItbRefillFault::invoke(ThreadContext *tc, StaticInstPtr inst) 3456378Sgblack@eecs.umich.edu{ 3466383Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered (%x).\n", name(), MISCREG_BADVADDR); 3476378Sgblack@eecs.umich.edu Addr HandlerBase; 3486383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 3496383Sgblack@eecs.umich.edu EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 3506379Sgblack@eecs.umich.edu entryHi.asid = entryHiAsid; 3516379Sgblack@eecs.umich.edu entryHi.vpn2 = entryHiVPN2; 3526379Sgblack@eecs.umich.edu entryHi.vpn2x = entryHiVPN2X; 3536383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 3546383Sgblack@eecs.umich.edu ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 3556379Sgblack@eecs.umich.edu context.badVPN2 = contextBadVPN2; 3566383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 3576378Sgblack@eecs.umich.edu 3586383Sgblack@eecs.umich.edu StatusReg status = tc->readMiscReg(MISCREG_STATUS); 3596378Sgblack@eecs.umich.edu // Since handler depends on EXL bit, must check EXL bit before setting it!! 3606378Sgblack@eecs.umich.edu // See MIPS ARM Vol 3, Revision 2, Page 38 3616379Sgblack@eecs.umich.edu if (status.exl == 1) { 3626378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 3636383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 3646378Sgblack@eecs.umich.edu } else { 3656378Sgblack@eecs.umich.edu // Offset 0x000 3666383Sgblack@eecs.umich.edu HandlerBase = tc->readMiscReg(MISCREG_EBASE); 3676378Sgblack@eecs.umich.edu } 3686378Sgblack@eecs.umich.edu 3696378Sgblack@eecs.umich.edu setExceptionState(tc, 0x2); 3706378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 3716378Sgblack@eecs.umich.edu} 3726378Sgblack@eecs.umich.edu 3736378Sgblack@eecs.umich.eduvoid 3747678Sgblack@eecs.umich.eduDtbRefillFault::invoke(ThreadContext *tc, StaticInstPtr inst) 3756378Sgblack@eecs.umich.edu{ 3766378Sgblack@eecs.umich.edu // Set new PC 3776378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 3786378Sgblack@eecs.umich.edu Addr HandlerBase; 3796383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 3806383Sgblack@eecs.umich.edu EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 3816379Sgblack@eecs.umich.edu entryHi.asid = entryHiAsid; 3826379Sgblack@eecs.umich.edu entryHi.vpn2 = entryHiVPN2; 3836379Sgblack@eecs.umich.edu entryHi.vpn2x = entryHiVPN2X; 3846383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 3856378Sgblack@eecs.umich.edu 3866383Sgblack@eecs.umich.edu ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 3876379Sgblack@eecs.umich.edu context.badVPN2 = contextBadVPN2; 3886383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 3896379Sgblack@eecs.umich.edu 3906383Sgblack@eecs.umich.edu StatusReg status = tc->readMiscReg(MISCREG_STATUS); 3916378Sgblack@eecs.umich.edu // Since handler depends on EXL bit, must check EXL bit before setting it!! 3926378Sgblack@eecs.umich.edu // See MIPS ARM Vol 3, Revision 2, Page 38 3936379Sgblack@eecs.umich.edu if (status.exl) { 3946378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 3956383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 3966378Sgblack@eecs.umich.edu } else { 3976378Sgblack@eecs.umich.edu // Offset 0x000 3986383Sgblack@eecs.umich.edu HandlerBase = tc->readMiscReg(MISCREG_EBASE); 3996378Sgblack@eecs.umich.edu } 4006378Sgblack@eecs.umich.edu 4016378Sgblack@eecs.umich.edu setExceptionState(tc, 0x3); 4026378Sgblack@eecs.umich.edu 4036378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 4046378Sgblack@eecs.umich.edu} 4056378Sgblack@eecs.umich.edu 4066378Sgblack@eecs.umich.eduvoid 4077678Sgblack@eecs.umich.eduTLBModifiedFault::invoke(ThreadContext *tc, StaticInstPtr inst) 4086378Sgblack@eecs.umich.edu{ 4096378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 4106383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_BADVADDR, badVAddr); 4116383Sgblack@eecs.umich.edu EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI); 4126379Sgblack@eecs.umich.edu entryHi.asid = entryHiAsid; 4136379Sgblack@eecs.umich.edu entryHi.vpn2 = entryHiVPN2; 4146379Sgblack@eecs.umich.edu entryHi.vpn2x = entryHiVPN2X; 4156383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi); 4166379Sgblack@eecs.umich.edu 4176383Sgblack@eecs.umich.edu ContextReg context = tc->readMiscReg(MISCREG_CONTEXT); 4186379Sgblack@eecs.umich.edu context.badVPN2 = contextBadVPN2; 4196383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_CONTEXT, context); 4206378Sgblack@eecs.umich.edu 4216378Sgblack@eecs.umich.edu // Set new PC 4226378Sgblack@eecs.umich.edu Addr HandlerBase; 4236378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 4246383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 4256378Sgblack@eecs.umich.edu setExceptionState(tc, 0x1); 4266378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 4275222Sksewell@umich.edu 4285222Sksewell@umich.edu} 4295222Sksewell@umich.edu 4306378Sgblack@eecs.umich.eduvoid 4317678Sgblack@eecs.umich.eduSystemCallFault::invoke(ThreadContext *tc, StaticInstPtr inst) 4325222Sksewell@umich.edu{ 4336378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 4346378Sgblack@eecs.umich.edu setExceptionState(tc, 0x8); 4355222Sksewell@umich.edu 4366378Sgblack@eecs.umich.edu // Set new PC 4376378Sgblack@eecs.umich.edu Addr HandlerBase; 4386378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 4396383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 4406378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 4415222Sksewell@umich.edu} 4425222Sksewell@umich.edu 4436378Sgblack@eecs.umich.eduvoid 4447678Sgblack@eecs.umich.eduInterruptFault::invoke(ThreadContext *tc, StaticInstPtr inst) 4455222Sksewell@umich.edu{ 4465222Sksewell@umich.edu#if FULL_SYSTEM 4476378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 4486378Sgblack@eecs.umich.edu setExceptionState(tc, 0x0A); 4496378Sgblack@eecs.umich.edu Addr HandlerBase; 4505222Sksewell@umich.edu 4516383Sgblack@eecs.umich.edu CauseReg cause = tc->readMiscRegNoEffect(MISCREG_CAUSE); 4526379Sgblack@eecs.umich.edu if (cause.iv) { 4536378Sgblack@eecs.umich.edu // Offset 200 for release 2 4546383Sgblack@eecs.umich.edu HandlerBase = 0x20 + vect() + tc->readMiscRegNoEffect(MISCREG_EBASE); 4556378Sgblack@eecs.umich.edu } else { 4566378Sgblack@eecs.umich.edu //Ofset at 180 for release 1 4576383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscRegNoEffect(MISCREG_EBASE); 4586378Sgblack@eecs.umich.edu } 4595222Sksewell@umich.edu 4606378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 4615222Sksewell@umich.edu#endif 4625222Sksewell@umich.edu} 4635222Sksewell@umich.edu 4645222Sksewell@umich.edu#endif // FULL_SYSTEM 4655222Sksewell@umich.edu 4666378Sgblack@eecs.umich.eduvoid 4677678Sgblack@eecs.umich.eduResetFault::invoke(ThreadContext *tc, StaticInstPtr inst) 4684661Sksewell@umich.edu{ 4695224Sksewell@umich.edu#if FULL_SYSTEM 4706378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 4716378Sgblack@eecs.umich.edu /* All reset activity must be invoked from here */ 4726378Sgblack@eecs.umich.edu tc->setPC(vect()); 4736378Sgblack@eecs.umich.edu tc->setNextPC(vect() + sizeof(MachInst)); 4746378Sgblack@eecs.umich.edu tc->setNextNPC(vect() + sizeof(MachInst) + sizeof(MachInst)); 4756379Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "ResetFault::invoke : PC set to %x", tc->readPC()); 4765224Sksewell@umich.edu#endif 4775224Sksewell@umich.edu 4786378Sgblack@eecs.umich.edu // Set Coprocessor 1 (Floating Point) To Usable 4796383Sgblack@eecs.umich.edu StatusReg status = tc->readMiscRegNoEffect(MISCREG_STATUS); 4806379Sgblack@eecs.umich.edu status.cu.cu1 = 1; 4816383Sgblack@eecs.umich.edu tc->setMiscReg(MISCREG_STATUS, status); 4825222Sksewell@umich.edu} 4835222Sksewell@umich.edu 4846378Sgblack@eecs.umich.eduvoid 4857678Sgblack@eecs.umich.eduReservedInstructionFault::invoke(ThreadContext *tc, StaticInstPtr inst) 4865222Sksewell@umich.edu{ 4875222Sksewell@umich.edu#if FULL_SYSTEM 4886378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 4896378Sgblack@eecs.umich.edu setExceptionState(tc, 0x0A); 4906378Sgblack@eecs.umich.edu Addr HandlerBase; 4916378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 4926383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscRegNoEffect(MISCREG_EBASE); 4936378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 4945222Sksewell@umich.edu#else 4955222Sksewell@umich.edu panic("%s encountered.\n", name()); 4965222Sksewell@umich.edu#endif 4975222Sksewell@umich.edu} 4985222Sksewell@umich.edu 4996378Sgblack@eecs.umich.eduvoid 5007678Sgblack@eecs.umich.eduThreadFault::invoke(ThreadContext *tc, StaticInstPtr inst) 5015222Sksewell@umich.edu{ 5026378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 5036378Sgblack@eecs.umich.edu panic("%s encountered.\n", name()); 5045222Sksewell@umich.edu} 5055222Sksewell@umich.edu 5066378Sgblack@eecs.umich.eduvoid 5077678Sgblack@eecs.umich.eduDspStateDisabledFault::invoke(ThreadContext *tc, StaticInstPtr inst) 5085222Sksewell@umich.edu{ 5096378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 5106378Sgblack@eecs.umich.edu panic("%s encountered.\n", name()); 5114661Sksewell@umich.edu} 5124661Sksewell@umich.edu 5136378Sgblack@eecs.umich.eduvoid 5147678Sgblack@eecs.umich.eduCoprocessorUnusableFault::invoke(ThreadContext *tc, StaticInstPtr inst) 5154661Sksewell@umich.edu{ 5165222Sksewell@umich.edu#if FULL_SYSTEM 5176378Sgblack@eecs.umich.edu DPRINTF(MipsPRA, "%s encountered.\n", name()); 5186378Sgblack@eecs.umich.edu setExceptionState(tc, 0xb); 5196378Sgblack@eecs.umich.edu // The ID of the coprocessor causing the exception is stored in 5206378Sgblack@eecs.umich.edu // CoprocessorUnusableFault::coProcID 5216383Sgblack@eecs.umich.edu CauseReg cause = tc->readMiscReg(MISCREG_CAUSE); 5226379Sgblack@eecs.umich.edu cause.ce = coProcID; 5236383Sgblack@eecs.umich.edu tc->setMiscRegNoEffect(MISCREG_CAUSE, cause); 5244661Sksewell@umich.edu 5256378Sgblack@eecs.umich.edu Addr HandlerBase; 5266378Sgblack@eecs.umich.edu // Offset 0x180 - General Exception Vector 5276383Sgblack@eecs.umich.edu HandlerBase = vect() + tc->readMiscReg(MISCREG_EBASE); 5286378Sgblack@eecs.umich.edu setHandlerPC(HandlerBase, tc); 5294661Sksewell@umich.edu 5305222Sksewell@umich.edu#else 5315224Sksewell@umich.edu warn("%s (CP%d) encountered.\n", name(), coProcID); 5325222Sksewell@umich.edu#endif 5334661Sksewell@umich.edu} 5344661Sksewell@umich.edu 5352447SN/A} // namespace MipsISA 5362447SN/A 537