faults.cc revision 3573
12221SN/A/*
22221SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
32221SN/A * All rights reserved.
42221SN/A *
52221SN/A * Redistribution and use in source and binary forms, with or without
62221SN/A * modification, are permitted provided that the following conditions are
72221SN/A * met: redistributions of source code must retain the above copyright
82221SN/A * notice, this list of conditions and the following disclaimer;
92221SN/A * redistributions in binary form must reproduce the above copyright
102221SN/A * notice, this list of conditions and the following disclaimer in the
112221SN/A * documentation and/or other materials provided with the distribution;
122221SN/A * neither the name of the copyright holders nor the names of its
132221SN/A * contributors may be used to endorse or promote products derived from
142221SN/A * this software without specific prior written permission.
152221SN/A *
162221SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172221SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182221SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192221SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202221SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212221SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222221SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232221SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242221SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252221SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262221SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Gabe Black
292665Ssaidi@eecs.umich.edu *          Kevin Lim
302221SN/A */
312221SN/A
323415Sgblack@eecs.umich.edu#include <algorithm>
333415Sgblack@eecs.umich.edu
342223SN/A#include "arch/sparc/faults.hh"
353415Sgblack@eecs.umich.edu#include "arch/sparc/isa_traits.hh"
363415Sgblack@eecs.umich.edu#include "arch/sparc/process.hh"
373415Sgblack@eecs.umich.edu#include "base/bitfield.hh"
383415Sgblack@eecs.umich.edu#include "base/trace.hh"
393415Sgblack@eecs.umich.edu#include "cpu/base.hh"
402680Sktlim@umich.edu#include "cpu/thread_context.hh"
412800Ssaidi@eecs.umich.edu#if !FULL_SYSTEM
423415Sgblack@eecs.umich.edu#include "mem/page_table.hh"
432800Ssaidi@eecs.umich.edu#include "sim/process.hh"
442800Ssaidi@eecs.umich.edu#endif
452221SN/A
463415Sgblack@eecs.umich.eduusing namespace std;
473415Sgblack@eecs.umich.edu
482223SN/Anamespace SparcISA
492221SN/A{
502221SN/A
513573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
523573Sgblack@eecs.umich.edu    SparcFault<InternalProcessorError>::vals = {"intprocerr", 0x029, 4};
532221SN/A
543573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
553573Sgblack@eecs.umich.edu    SparcFault<MemAddressNotAligned>::vals = {"unalign", 0x034, 10};
562221SN/A
573573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
583573Sgblack@eecs.umich.edu    SparcFault<PowerOnReset>::vals = {"pow_reset", 0x001, 0};
592221SN/A
603573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
613573Sgblack@eecs.umich.edu    SparcFault<WatchDogReset>::vals = {"watch_dog_reset", 0x002, 1};
622221SN/A
633573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
643573Sgblack@eecs.umich.edu    SparcFault<ExternallyInitiatedReset>::vals = {"extern_reset", 0x003, 1};
652221SN/A
663573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
673573Sgblack@eecs.umich.edu    SparcFault<SoftwareInitiatedReset>::vals = {"software_reset", 0x004, 1};
682221SN/A
693573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
703573Sgblack@eecs.umich.edu    SparcFault<REDStateException>::vals = {"red_counte", 0x005, 1};
712221SN/A
723573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
733573Sgblack@eecs.umich.edu    SparcFault<InstructionAccessException>::vals = {"inst_access", 0x008, 5};
742221SN/A
753573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
763573Sgblack@eecs.umich.edu    SparcFault<InstructionAccessMMUMiss>::vals = {"inst_mmu", 0x009, 2};
772221SN/A
783573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
793573Sgblack@eecs.umich.edu    SparcFault<InstructionAccessError>::vals = {"inst_error", 0x00A, 3};
802221SN/A
813573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
823573Sgblack@eecs.umich.edu    SparcFault<IllegalInstruction>::vals = {"illegal_inst", 0x010, 7};
832221SN/A
843573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
853573Sgblack@eecs.umich.edu    SparcFault<PrivilegedOpcode>::vals = {"priv_opcode", 0x011, 6};
862221SN/A
873573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
883573Sgblack@eecs.umich.edu    SparcFault<UnimplementedLDD>::vals = {"unimp_ldd", 0x012, 6};
892221SN/A
903573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
913573Sgblack@eecs.umich.edu    SparcFault<UnimplementedSTD>::vals = {"unimp_std", 0x013, 6};
922221SN/A
933573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
943573Sgblack@eecs.umich.edu    SparcFault<FpDisabled>::vals = {"fp_disabled", 0x020, 8};
952221SN/A
963573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
973573Sgblack@eecs.umich.edu    SparcFault<FpExceptionIEEE754>::vals = {"fp_754", 0x021, 11};
982223SN/A
993573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1003573Sgblack@eecs.umich.edu    SparcFault<FpExceptionOther>::vals = {"fp_other", 0x022, 11};
1012223SN/A
1023573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1033573Sgblack@eecs.umich.edu    SparcFault<TagOverflow>::vals = {"tag_overflow", 0x023, 14};
1042223SN/A
1053573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1063573Sgblack@eecs.umich.edu    SparcFault<DivisionByZero>::vals = {"div_by_zero", 0x028, 15};
1072223SN/A
1083573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1093573Sgblack@eecs.umich.edu    SparcFault<DataAccessException>::vals = {"data_access", 0x030, 12};
1102223SN/A
1113573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1123573Sgblack@eecs.umich.edu    SparcFault<DataAccessMMUMiss>::vals = {"data_mmu", 0x031, 12};
1132223SN/A
1143573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1153573Sgblack@eecs.umich.edu    SparcFault<DataAccessError>::vals = {"data_error", 0x032, 12};
1162223SN/A
1173573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1183573Sgblack@eecs.umich.edu    SparcFault<DataAccessProtection>::vals = {"data_protection", 0x033, 12};
1192223SN/A
1203573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1213573Sgblack@eecs.umich.edu    SparcFault<LDDFMemAddressNotAligned>::vals = {"unalign_lddf", 0x035, 10};
1222223SN/A
1233573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1243573Sgblack@eecs.umich.edu    SparcFault<STDFMemAddressNotAligned>::vals = {"unalign_stdf", 0x036, 10};
1252223SN/A
1263573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1273573Sgblack@eecs.umich.edu    SparcFault<PrivilegedAction>::vals = {"priv_action", 0x037, 11};
1282223SN/A
1293573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1303573Sgblack@eecs.umich.edu    SparcFault<LDQFMemAddressNotAligned>::vals = {"unalign_ldqf", 0x038, 10};
1312223SN/A
1323573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1333573Sgblack@eecs.umich.edu    SparcFault<STQFMemAddressNotAligned>::vals = {"unalign_stqf", 0x039, 10};
1342223SN/A
1353573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1363573Sgblack@eecs.umich.edu    SparcFault<AsyncDataError>::vals = {"async_data", 0x040, 2};
1372223SN/A
1383573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1393573Sgblack@eecs.umich.edu    SparcFault<CleanWindow>::vals = {"clean_win", 0x024, 10};
1402223SN/A
1412527SN/A//The enumerated faults
1422527SN/A
1433573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1443573Sgblack@eecs.umich.edu    SparcFault<InterruptLevelN>::vals = {"interrupt_n", 0x041, 0};
1452223SN/A
1463573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1473573Sgblack@eecs.umich.edu    SparcFault<SpillNNormal>::vals = {"spill_n_normal", 0x080, 9};
1482223SN/A
1493573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1503573Sgblack@eecs.umich.edu    SparcFault<SpillNOther>::vals = {"spill_n_other", 0x0A0, 9};
1512223SN/A
1523573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1533573Sgblack@eecs.umich.edu    SparcFault<FillNNormal>::vals = {"fill_n_normal", 0x0C0, 9};
1542223SN/A
1553573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1563573Sgblack@eecs.umich.edu    SparcFault<FillNOther>::vals = {"fill_n_other", 0x0E0, 9};
1572223SN/A
1583573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1593573Sgblack@eecs.umich.edu    SparcFault<TrapInstruction>::vals = {"trap_inst_n", 0x100, 16};
1602223SN/A
1612800Ssaidi@eecs.umich.edu#if !FULL_SYSTEM
1623573Sgblack@eecs.umich.edutemplate<> SparcFaultBase::FaultVals
1633573Sgblack@eecs.umich.edu    SparcFault<PageTableFault>::vals = {"page_table_fault", 0x0000, 0};
1642800Ssaidi@eecs.umich.edu#endif
1652800Ssaidi@eecs.umich.edu
1663415Sgblack@eecs.umich.edu/**
1673415Sgblack@eecs.umich.edu * This sets everything up for a normal trap except for actually jumping to
1683415Sgblack@eecs.umich.edu * the handler. It will need to be expanded to include the state machine in
1693415Sgblack@eecs.umich.edu * the manual. Right now it assumes that traps will always be to the
1703415Sgblack@eecs.umich.edu * privileged level.
1713415Sgblack@eecs.umich.edu */
1723415Sgblack@eecs.umich.edu
1733415Sgblack@eecs.umich.eduvoid doNormalFault(ThreadContext *tc, TrapType tt)
1743415Sgblack@eecs.umich.edu{
1753415Sgblack@eecs.umich.edu    uint64_t TL = tc->readMiscReg(MISCREG_TL);
1763415Sgblack@eecs.umich.edu    uint64_t TSTATE = tc->readMiscReg(MISCREG_TSTATE);
1773415Sgblack@eecs.umich.edu    uint64_t PSTATE = tc->readMiscReg(MISCREG_PSTATE);
1783415Sgblack@eecs.umich.edu    uint64_t HPSTATE = tc->readMiscReg(MISCREG_HPSTATE);
1793415Sgblack@eecs.umich.edu    uint64_t CCR = tc->readMiscReg(MISCREG_CCR);
1803415Sgblack@eecs.umich.edu    uint64_t ASI = tc->readMiscReg(MISCREG_ASI);
1813415Sgblack@eecs.umich.edu    uint64_t CWP = tc->readMiscReg(MISCREG_CWP);
1823415Sgblack@eecs.umich.edu    uint64_t CANSAVE = tc->readMiscReg(MISCREG_CANSAVE);
1833415Sgblack@eecs.umich.edu    uint64_t GL = tc->readMiscReg(MISCREG_GL);
1843415Sgblack@eecs.umich.edu    uint64_t PC = tc->readPC();
1853415Sgblack@eecs.umich.edu    uint64_t NPC = tc->readNextPC();
1863415Sgblack@eecs.umich.edu
1873415Sgblack@eecs.umich.edu    //Increment the trap level
1883415Sgblack@eecs.umich.edu    TL++;
1893415Sgblack@eecs.umich.edu    tc->setMiscReg(MISCREG_TL, TL);
1903415Sgblack@eecs.umich.edu
1913415Sgblack@eecs.umich.edu    //Save off state
1923415Sgblack@eecs.umich.edu
1933415Sgblack@eecs.umich.edu    //set TSTATE.gl to gl
1943415Sgblack@eecs.umich.edu    replaceBits(TSTATE, 42, 40, GL);
1953415Sgblack@eecs.umich.edu    //set TSTATE.ccr to ccr
1963415Sgblack@eecs.umich.edu    replaceBits(TSTATE, 39, 32, CCR);
1973415Sgblack@eecs.umich.edu    //set TSTATE.asi to asi
1983415Sgblack@eecs.umich.edu    replaceBits(TSTATE, 31, 24, ASI);
1993415Sgblack@eecs.umich.edu    //set TSTATE.pstate to pstate
2003415Sgblack@eecs.umich.edu    replaceBits(TSTATE, 20, 8, PSTATE);
2013415Sgblack@eecs.umich.edu    //set TSTATE.cwp to cwp
2023415Sgblack@eecs.umich.edu    replaceBits(TSTATE, 4, 0, CWP);
2033415Sgblack@eecs.umich.edu
2043415Sgblack@eecs.umich.edu    //Write back TSTATE
2053415Sgblack@eecs.umich.edu    tc->setMiscReg(MISCREG_TSTATE, TSTATE);
2063415Sgblack@eecs.umich.edu
2073415Sgblack@eecs.umich.edu    //set TPC to PC
2083415Sgblack@eecs.umich.edu    tc->setMiscReg(MISCREG_TPC, PC);
2093415Sgblack@eecs.umich.edu    //set TNPC to NPC
2103415Sgblack@eecs.umich.edu    tc->setMiscReg(MISCREG_TNPC, NPC);
2113415Sgblack@eecs.umich.edu
2123415Sgblack@eecs.umich.edu    //set HTSTATE.hpstate to hpstate
2133415Sgblack@eecs.umich.edu    tc->setMiscReg(MISCREG_HTSTATE, HPSTATE);
2143415Sgblack@eecs.umich.edu
2153415Sgblack@eecs.umich.edu    //TT = trap type;
2163415Sgblack@eecs.umich.edu    tc->setMiscReg(MISCREG_TT, tt);
2173415Sgblack@eecs.umich.edu
2183415Sgblack@eecs.umich.edu    //Update the global register level
2193415Sgblack@eecs.umich.edu    if(1/*We're delivering the trap in priveleged mode*/)
2203415Sgblack@eecs.umich.edu        tc->setMiscReg(MISCREG_GL, max<int>(GL+1, MaxGL));
2213415Sgblack@eecs.umich.edu    else
2223415Sgblack@eecs.umich.edu        tc->setMiscReg(MISCREG_GL, max<int>(GL+1, MaxPGL));
2233415Sgblack@eecs.umich.edu
2243415Sgblack@eecs.umich.edu    //PSTATE.mm is unchanged
2253415Sgblack@eecs.umich.edu    //PSTATE.pef = whether or not an fpu is present
2263415Sgblack@eecs.umich.edu    //XXX We'll say there's one present, even though there aren't
2273415Sgblack@eecs.umich.edu    //implementations for a decent number of the instructions
2283415Sgblack@eecs.umich.edu    PSTATE |= (1 << 4);
2293415Sgblack@eecs.umich.edu    //PSTATE.am = 0
2303415Sgblack@eecs.umich.edu    PSTATE &= ~(1 << 3);
2313415Sgblack@eecs.umich.edu    if(1/*We're delivering the trap in priveleged mode*/)
2323415Sgblack@eecs.umich.edu    {
2333415Sgblack@eecs.umich.edu        //PSTATE.priv = 1
2343415Sgblack@eecs.umich.edu        PSTATE |= (1 << 2);
2353415Sgblack@eecs.umich.edu        //PSTATE.cle = PSTATE.tle
2363415Sgblack@eecs.umich.edu        replaceBits(PSTATE, 9, 9, PSTATE >> 8);
2373415Sgblack@eecs.umich.edu    }
2383415Sgblack@eecs.umich.edu    else
2393415Sgblack@eecs.umich.edu    {
2403415Sgblack@eecs.umich.edu        //PSTATE.priv = 0
2413415Sgblack@eecs.umich.edu        PSTATE &= ~(1 << 2);
2423415Sgblack@eecs.umich.edu        //PSTATE.cle = 0
2433415Sgblack@eecs.umich.edu        PSTATE &= ~(1 << 9);
2443415Sgblack@eecs.umich.edu    }
2453415Sgblack@eecs.umich.edu    //PSTATE.ie = 0
2463415Sgblack@eecs.umich.edu    PSTATE &= ~(1 << 1);
2473415Sgblack@eecs.umich.edu    //PSTATE.tle is unchanged
2483415Sgblack@eecs.umich.edu    //PSTATE.tct = 0
2493415Sgblack@eecs.umich.edu    //XXX Where exactly is this field?
2503415Sgblack@eecs.umich.edu    tc->setMiscReg(MISCREG_PSTATE, PSTATE);
2513415Sgblack@eecs.umich.edu
2523415Sgblack@eecs.umich.edu    if(0/*We're delivering the trap in hyperprivileged mode*/)
2533415Sgblack@eecs.umich.edu    {
2543415Sgblack@eecs.umich.edu        //HPSTATE.red = 0
2553415Sgblack@eecs.umich.edu        HPSTATE &= ~(1 << 5);
2563415Sgblack@eecs.umich.edu        //HPSTATE.hpriv = 1
2573415Sgblack@eecs.umich.edu        HPSTATE |= (1 << 2);
2583415Sgblack@eecs.umich.edu        //HPSTATE.ibe = 0
2593415Sgblack@eecs.umich.edu        HPSTATE &= ~(1 << 10);
2603415Sgblack@eecs.umich.edu        //HPSTATE.tlz is unchanged
2613415Sgblack@eecs.umich.edu        tc->setMiscReg(MISCREG_HPSTATE, HPSTATE);
2623415Sgblack@eecs.umich.edu    }
2633415Sgblack@eecs.umich.edu
2643415Sgblack@eecs.umich.edu    bool changedCWP = true;
2653415Sgblack@eecs.umich.edu    if(tt == 0x24)
2663415Sgblack@eecs.umich.edu        CWP++;
2673415Sgblack@eecs.umich.edu    else if(0x80 <= tt && tt <= 0xbf)
2683415Sgblack@eecs.umich.edu        CWP += (CANSAVE + 2);
2693415Sgblack@eecs.umich.edu    else if(0xc0 <= tt && tt <= 0xff)
2703415Sgblack@eecs.umich.edu        CWP--;
2713415Sgblack@eecs.umich.edu    else
2723415Sgblack@eecs.umich.edu        changedCWP = false;
2733420Sgblack@eecs.umich.edu
2743415Sgblack@eecs.umich.edu    if(changedCWP)
2753415Sgblack@eecs.umich.edu    {
2763415Sgblack@eecs.umich.edu        CWP = (CWP + NWindows) % NWindows;
2773415Sgblack@eecs.umich.edu        tc->setMiscRegWithEffect(MISCREG_CWP, CWP);
2783415Sgblack@eecs.umich.edu    }
2793415Sgblack@eecs.umich.edu}
2803415Sgblack@eecs.umich.edu
2812221SN/A#if FULL_SYSTEM
2822221SN/A
2833573Sgblack@eecs.umich.eduvoid SparcFaultBase::invoke(ThreadContext * tc)
2842221SN/A{
2852680Sktlim@umich.edu    FaultBase::invoke(tc);
2862223SN/A    countStat()++;
2872221SN/A
2882223SN/A    //Use the SPARC trap state machine
2892223SN/A    /*// exception restart address
2902680Sktlim@umich.edu    if (setRestartAddress() || !tc->inPalMode())
2912680Sktlim@umich.edu        tc->setMiscReg(AlphaISA::IPR_EXC_ADDR, tc->regs.pc);
2922221SN/A
2932221SN/A    if (skipFaultingInstruction()) {
2942221SN/A        // traps...  skip faulting instruction.
2952680Sktlim@umich.edu        tc->setMiscReg(AlphaISA::IPR_EXC_ADDR,
2962680Sktlim@umich.edu                   tc->readMiscReg(AlphaISA::IPR_EXC_ADDR) + 4);
2972221SN/A    }
2982221SN/A
2992680Sktlim@umich.edu    if (!tc->inPalMode())
3002680Sktlim@umich.edu        AlphaISA::swap_palshadow(&(tc->regs), true);
3012221SN/A
3022680Sktlim@umich.edu    tc->regs.pc = tc->readMiscReg(AlphaISA::IPR_PAL_BASE) + vect();
3032680Sktlim@umich.edu    tc->regs.npc = tc->regs.pc + sizeof(MachInst);*/
3042221SN/A}
3052221SN/A
3062612SN/A#endif
3072612SN/A
3082612SN/A#if !FULL_SYSTEM
3092612SN/A
3102680Sktlim@umich.eduvoid TrapInstruction::invoke(ThreadContext * tc)
3112523SN/A{
3122719Sktlim@umich.edu    // Should be handled in ISA.
3132523SN/A}
3142523SN/A
3153415Sgblack@eecs.umich.eduvoid SpillNNormal::invoke(ThreadContext *tc)
3163415Sgblack@eecs.umich.edu{
3173415Sgblack@eecs.umich.edu    doNormalFault(tc, trapType());
3183415Sgblack@eecs.umich.edu
3193415Sgblack@eecs.umich.edu    Process *p = tc->getProcessPtr();
3203415Sgblack@eecs.umich.edu
3213415Sgblack@eecs.umich.edu    //This will only work in faults from a SparcLiveProcess
3223415Sgblack@eecs.umich.edu    SparcLiveProcess *lp = dynamic_cast<SparcLiveProcess *>(p);
3233415Sgblack@eecs.umich.edu    assert(lp);
3243415Sgblack@eecs.umich.edu
3253415Sgblack@eecs.umich.edu    //Then adjust the PC and NPC
3263415Sgblack@eecs.umich.edu    Addr spillStart = lp->readSpillStart();
3273415Sgblack@eecs.umich.edu    tc->setPC(spillStart);
3283415Sgblack@eecs.umich.edu    tc->setNextPC(spillStart + sizeof(MachInst));
3293415Sgblack@eecs.umich.edu    tc->setNextNPC(spillStart + 2*sizeof(MachInst));
3303415Sgblack@eecs.umich.edu}
3313415Sgblack@eecs.umich.edu
3323415Sgblack@eecs.umich.eduvoid FillNNormal::invoke(ThreadContext *tc)
3333415Sgblack@eecs.umich.edu{
3343415Sgblack@eecs.umich.edu    doNormalFault(tc, trapType());
3353415Sgblack@eecs.umich.edu
3363415Sgblack@eecs.umich.edu    Process * p = tc->getProcessPtr();
3373415Sgblack@eecs.umich.edu
3383415Sgblack@eecs.umich.edu    //This will only work in faults from a SparcLiveProcess
3393415Sgblack@eecs.umich.edu    SparcLiveProcess *lp = dynamic_cast<SparcLiveProcess *>(p);
3403415Sgblack@eecs.umich.edu    assert(lp);
3413415Sgblack@eecs.umich.edu
3423415Sgblack@eecs.umich.edu    //The adjust the PC and NPC
3433415Sgblack@eecs.umich.edu    Addr fillStart = lp->readFillStart();
3443415Sgblack@eecs.umich.edu    tc->setPC(fillStart);
3453415Sgblack@eecs.umich.edu    tc->setNextPC(fillStart + sizeof(MachInst));
3463415Sgblack@eecs.umich.edu    tc->setNextNPC(fillStart + 2*sizeof(MachInst));
3473415Sgblack@eecs.umich.edu}
3483415Sgblack@eecs.umich.edu
3492800Ssaidi@eecs.umich.eduvoid PageTableFault::invoke(ThreadContext *tc)
3502800Ssaidi@eecs.umich.edu{
3512800Ssaidi@eecs.umich.edu    Process *p = tc->getProcessPtr();
3522800Ssaidi@eecs.umich.edu
3532800Ssaidi@eecs.umich.edu    // address is higher than the stack region or in the current stack region
3542800Ssaidi@eecs.umich.edu    if (vaddr > p->stack_base || vaddr > p->stack_min)
3552800Ssaidi@eecs.umich.edu        FaultBase::invoke(tc);
3562800Ssaidi@eecs.umich.edu
3572800Ssaidi@eecs.umich.edu    // We've accessed the next page
3582800Ssaidi@eecs.umich.edu    if (vaddr > p->stack_min - PageBytes) {
3592800Ssaidi@eecs.umich.edu        p->stack_min -= PageBytes;
3602800Ssaidi@eecs.umich.edu        if (p->stack_base - p->stack_min > 8*1024*1024)
3612800Ssaidi@eecs.umich.edu            fatal("Over max stack size for one thread\n");
3622800Ssaidi@eecs.umich.edu        p->pTable->allocate(p->stack_min, PageBytes);
3632800Ssaidi@eecs.umich.edu        warn("Increasing stack size by one page.");
3642800Ssaidi@eecs.umich.edu    } else {
3652800Ssaidi@eecs.umich.edu        FaultBase::invoke(tc);
3662800Ssaidi@eecs.umich.edu    }
3672800Ssaidi@eecs.umich.edu}
3683415Sgblack@eecs.umich.edu
3692221SN/A#endif
3702221SN/A
3712223SN/A} // namespace SparcISA
3722221SN/A
373