thread_context_impl.hh revision 5258
12817Sksewell@umich.edu/*
22817Sksewell@umich.edu * Copyright (c) 2004-2006 The Regents of The University of Michigan
32817Sksewell@umich.edu * All rights reserved.
42817Sksewell@umich.edu *
52817Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without
62817Sksewell@umich.edu * modification, are permitted provided that the following conditions are
72817Sksewell@umich.edu * met: redistributions of source code must retain the above copyright
82817Sksewell@umich.edu * notice, this list of conditions and the following disclaimer;
92817Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright
102817Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the
112817Sksewell@umich.edu * documentation and/or other materials provided with the distribution;
122817Sksewell@umich.edu * neither the name of the copyright holders nor the names of its
132817Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
142817Sksewell@umich.edu * this software without specific prior written permission.
152817Sksewell@umich.edu *
162817Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172817Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182817Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192817Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202817Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212817Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222817Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232817Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242817Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252817Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262817Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272817Sksewell@umich.edu *
282817Sksewell@umich.edu * Authors: Kevin Lim
292817Sksewell@umich.edu *          Korey Sewell
302817Sksewell@umich.edu */
312817Sksewell@umich.edu
323776Sgblack@eecs.umich.edu#include "arch/regfile.hh"
332817Sksewell@umich.edu#include "cpu/o3/thread_context.hh"
342834Sksewell@umich.edu#include "cpu/quiesce_event.hh"
352817Sksewell@umich.edu
362817Sksewell@umich.edu#if FULL_SYSTEM
372817Sksewell@umich.edutemplate <class Impl>
382817Sksewell@umich.eduVirtualPort *
392817Sksewell@umich.eduO3ThreadContext<Impl>::getVirtPort(ThreadContext *src_tc)
402817Sksewell@umich.edu{
412817Sksewell@umich.edu    if (!src_tc)
422817Sksewell@umich.edu        return thread->getVirtPort();
432817Sksewell@umich.edu
442817Sksewell@umich.edu    VirtualPort *vp;
452817Sksewell@umich.edu
462817Sksewell@umich.edu    vp = new VirtualPort("tc-vport", src_tc);
473675Sktlim@umich.edu    thread->connectToMemFunc(vp);
482817Sksewell@umich.edu    return vp;
492817Sksewell@umich.edu}
502817Sksewell@umich.edu
512817Sksewell@umich.edutemplate <class Impl>
522817Sksewell@umich.eduvoid
532817Sksewell@umich.eduO3ThreadContext<Impl>::dumpFuncProfile()
542817Sksewell@umich.edu{
553126Sktlim@umich.edu    thread->dumpFuncProfile();
562817Sksewell@umich.edu}
572817Sksewell@umich.edu#endif
582817Sksewell@umich.edu
592817Sksewell@umich.edutemplate <class Impl>
602817Sksewell@umich.eduvoid
612817Sksewell@umich.eduO3ThreadContext<Impl>::takeOverFrom(ThreadContext *old_context)
622817Sksewell@umich.edu{
632817Sksewell@umich.edu    // some things should already be set up
642817Sksewell@umich.edu#if FULL_SYSTEM
652817Sksewell@umich.edu    assert(getSystemPtr() == old_context->getSystemPtr());
662817Sksewell@umich.edu#else
672817Sksewell@umich.edu    assert(getProcessPtr() == old_context->getProcessPtr());
682817Sksewell@umich.edu#endif
692817Sksewell@umich.edu
702817Sksewell@umich.edu    // copy over functional state
712817Sksewell@umich.edu    setStatus(old_context->status());
722817Sksewell@umich.edu    copyArchRegs(old_context);
732817Sksewell@umich.edu    setCpuId(old_context->readCpuId());
742817Sksewell@umich.edu
752817Sksewell@umich.edu#if !FULL_SYSTEM
762817Sksewell@umich.edu    thread->funcExeInst = old_context->readFuncExeInst();
772817Sksewell@umich.edu#else
782817Sksewell@umich.edu    EndQuiesceEvent *other_quiesce = old_context->getQuiesceEvent();
792817Sksewell@umich.edu    if (other_quiesce) {
802817Sksewell@umich.edu        // Point the quiesce event's TC at this TC so that it wakes up
812817Sksewell@umich.edu        // the proper CPU.
822817Sksewell@umich.edu        other_quiesce->tc = this;
832817Sksewell@umich.edu    }
842817Sksewell@umich.edu    if (thread->quiesceEvent) {
852817Sksewell@umich.edu        thread->quiesceEvent->tc = this;
862817Sksewell@umich.edu    }
872817Sksewell@umich.edu
882817Sksewell@umich.edu    // Transfer kernel stats from one CPU to the other.
892817Sksewell@umich.edu    thread->kernelStats = old_context->getKernelStats();
902817Sksewell@umich.edu//    storeCondFailures = 0;
912817Sksewell@umich.edu    cpu->lockFlag = false;
922817Sksewell@umich.edu#endif
932817Sksewell@umich.edu
942817Sksewell@umich.edu    old_context->setStatus(ThreadContext::Unallocated);
952817Sksewell@umich.edu
962817Sksewell@umich.edu    thread->inSyscall = false;
972817Sksewell@umich.edu    thread->trapPending = false;
982817Sksewell@umich.edu}
992817Sksewell@umich.edu
1002817Sksewell@umich.edu#if FULL_SYSTEM
1012817Sksewell@umich.edutemplate <class Impl>
1022817Sksewell@umich.eduvoid
1032817Sksewell@umich.eduO3ThreadContext<Impl>::delVirtPort(VirtualPort *vp)
1042817Sksewell@umich.edu{
1053686Sktlim@umich.edu    if (vp != thread->getVirtPort()) {
1064217Ssaidi@eecs.umich.edu        vp->removeConn();
1073686Sktlim@umich.edu        delete vp;
1083686Sktlim@umich.edu    }
1092817Sksewell@umich.edu}
1102817Sksewell@umich.edu#endif
1112817Sksewell@umich.edu
1122817Sksewell@umich.edutemplate <class Impl>
1132817Sksewell@umich.eduvoid
1142817Sksewell@umich.eduO3ThreadContext<Impl>::activate(int delay)
1152817Sksewell@umich.edu{
1162875Sksewell@umich.edu    DPRINTF(O3CPU, "Calling activate on Thread Context %d\n",
1172875Sksewell@umich.edu            getThreadNum());
1182817Sksewell@umich.edu
1192817Sksewell@umich.edu    if (thread->status() == ThreadContext::Active)
1202817Sksewell@umich.edu        return;
1212817Sksewell@umich.edu
1222817Sksewell@umich.edu#if FULL_SYSTEM
1232817Sksewell@umich.edu    thread->lastActivate = curTick;
1242817Sksewell@umich.edu#endif
1252817Sksewell@umich.edu
1262817Sksewell@umich.edu    if (thread->status() == ThreadContext::Unallocated) {
1272817Sksewell@umich.edu        cpu->activateWhenReady(thread->readTid());
1282817Sksewell@umich.edu        return;
1292817Sksewell@umich.edu    }
1302817Sksewell@umich.edu
1312817Sksewell@umich.edu    thread->setStatus(ThreadContext::Active);
1322817Sksewell@umich.edu
1332817Sksewell@umich.edu    // status() == Suspended
1342817Sksewell@umich.edu    cpu->activateContext(thread->readTid(), delay);
1352817Sksewell@umich.edu}
1362817Sksewell@umich.edu
1372817Sksewell@umich.edutemplate <class Impl>
1382817Sksewell@umich.eduvoid
1395250Sksewell@umich.eduO3ThreadContext<Impl>::suspend(int delay)
1402817Sksewell@umich.edu{
1412875Sksewell@umich.edu    DPRINTF(O3CPU, "Calling suspend on Thread Context %d\n",
1422875Sksewell@umich.edu            getThreadNum());
1432817Sksewell@umich.edu
1442817Sksewell@umich.edu    if (thread->status() == ThreadContext::Suspended)
1452817Sksewell@umich.edu        return;
1462817Sksewell@umich.edu
1472817Sksewell@umich.edu#if FULL_SYSTEM
1482817Sksewell@umich.edu    thread->lastActivate = curTick;
1492817Sksewell@umich.edu    thread->lastSuspend = curTick;
1502817Sksewell@umich.edu#endif
1512817Sksewell@umich.edu/*
1522817Sksewell@umich.edu#if FULL_SYSTEM
1532817Sksewell@umich.edu    // Don't change the status from active if there are pending interrupts
1542817Sksewell@umich.edu    if (cpu->check_interrupts()) {
1552817Sksewell@umich.edu        assert(status() == ThreadContext::Active);
1562817Sksewell@umich.edu        return;
1572817Sksewell@umich.edu    }
1582817Sksewell@umich.edu#endif
1592817Sksewell@umich.edu*/
1602817Sksewell@umich.edu    thread->setStatus(ThreadContext::Suspended);
1612817Sksewell@umich.edu    cpu->suspendContext(thread->readTid());
1622817Sksewell@umich.edu}
1632817Sksewell@umich.edu
1642817Sksewell@umich.edutemplate <class Impl>
1652817Sksewell@umich.eduvoid
1662875Sksewell@umich.eduO3ThreadContext<Impl>::deallocate(int delay)
1672817Sksewell@umich.edu{
1683221Sktlim@umich.edu    DPRINTF(O3CPU, "Calling deallocate on Thread Context %d delay %d\n",
1693221Sktlim@umich.edu            getThreadNum(), delay);
1702817Sksewell@umich.edu
1712817Sksewell@umich.edu    if (thread->status() == ThreadContext::Unallocated)
1722817Sksewell@umich.edu        return;
1732817Sksewell@umich.edu
1742817Sksewell@umich.edu    thread->setStatus(ThreadContext::Unallocated);
1753221Sktlim@umich.edu    cpu->deallocateContext(thread->readTid(), true, delay);
1762817Sksewell@umich.edu}
1772817Sksewell@umich.edu
1782817Sksewell@umich.edutemplate <class Impl>
1792817Sksewell@umich.eduvoid
1805250Sksewell@umich.eduO3ThreadContext<Impl>::halt(int delay)
1812817Sksewell@umich.edu{
1822875Sksewell@umich.edu    DPRINTF(O3CPU, "Calling halt on Thread Context %d\n",
1832875Sksewell@umich.edu            getThreadNum());
1842817Sksewell@umich.edu
1852817Sksewell@umich.edu    if (thread->status() == ThreadContext::Halted)
1862817Sksewell@umich.edu        return;
1872817Sksewell@umich.edu
1882817Sksewell@umich.edu    thread->setStatus(ThreadContext::Halted);
1892817Sksewell@umich.edu    cpu->haltContext(thread->readTid());
1902817Sksewell@umich.edu}
1912817Sksewell@umich.edu
1922817Sksewell@umich.edutemplate <class Impl>
1932817Sksewell@umich.eduvoid
1942817Sksewell@umich.eduO3ThreadContext<Impl>::regStats(const std::string &name)
1952817Sksewell@umich.edu{
1962817Sksewell@umich.edu#if FULL_SYSTEM
1973548Sgblack@eecs.umich.edu    thread->kernelStats = new TheISA::Kernel::Statistics(cpu->system);
1982817Sksewell@umich.edu    thread->kernelStats->regStats(name + ".kern");
1992817Sksewell@umich.edu#endif
2002817Sksewell@umich.edu}
2012817Sksewell@umich.edu
2022817Sksewell@umich.edutemplate <class Impl>
2032817Sksewell@umich.eduvoid
2042817Sksewell@umich.eduO3ThreadContext<Impl>::serialize(std::ostream &os)
2052817Sksewell@umich.edu{
2062817Sksewell@umich.edu#if FULL_SYSTEM
2072817Sksewell@umich.edu    if (thread->kernelStats)
2082817Sksewell@umich.edu        thread->kernelStats->serialize(os);
2092817Sksewell@umich.edu#endif
2102817Sksewell@umich.edu
2112817Sksewell@umich.edu}
2122817Sksewell@umich.edu
2132817Sksewell@umich.edutemplate <class Impl>
2142817Sksewell@umich.eduvoid
2152817Sksewell@umich.eduO3ThreadContext<Impl>::unserialize(Checkpoint *cp, const std::string &section)
2162817Sksewell@umich.edu{
2172817Sksewell@umich.edu#if FULL_SYSTEM
2182817Sksewell@umich.edu    if (thread->kernelStats)
2192817Sksewell@umich.edu        thread->kernelStats->unserialize(cp, section);
2202817Sksewell@umich.edu#endif
2212817Sksewell@umich.edu
2222817Sksewell@umich.edu}
2232817Sksewell@umich.edu
2242817Sksewell@umich.edu#if FULL_SYSTEM
2252817Sksewell@umich.edutemplate <class Impl>
2262817Sksewell@umich.eduTick
2272817Sksewell@umich.eduO3ThreadContext<Impl>::readLastActivate()
2282817Sksewell@umich.edu{
2292817Sksewell@umich.edu    return thread->lastActivate;
2302817Sksewell@umich.edu}
2312817Sksewell@umich.edu
2322817Sksewell@umich.edutemplate <class Impl>
2332817Sksewell@umich.eduTick
2342817Sksewell@umich.eduO3ThreadContext<Impl>::readLastSuspend()
2352817Sksewell@umich.edu{
2362817Sksewell@umich.edu    return thread->lastSuspend;
2372817Sksewell@umich.edu}
2382817Sksewell@umich.edu
2392817Sksewell@umich.edutemplate <class Impl>
2402817Sksewell@umich.eduvoid
2412817Sksewell@umich.eduO3ThreadContext<Impl>::profileClear()
2423126Sktlim@umich.edu{
2433126Sktlim@umich.edu    thread->profileClear();
2443126Sktlim@umich.edu}
2452817Sksewell@umich.edu
2462817Sksewell@umich.edutemplate <class Impl>
2472817Sksewell@umich.eduvoid
2482817Sksewell@umich.eduO3ThreadContext<Impl>::profileSample()
2493126Sktlim@umich.edu{
2503126Sktlim@umich.edu    thread->profileSample();
2513126Sktlim@umich.edu}
2522817Sksewell@umich.edu#endif
2532817Sksewell@umich.edu
2542817Sksewell@umich.edutemplate <class Impl>
2552817Sksewell@umich.eduTheISA::MachInst
2562817Sksewell@umich.eduO3ThreadContext<Impl>:: getInst()
2572817Sksewell@umich.edu{
2582817Sksewell@umich.edu    return thread->getInst();
2592817Sksewell@umich.edu}
2602817Sksewell@umich.edu
2612817Sksewell@umich.edutemplate <class Impl>
2622817Sksewell@umich.eduvoid
2632817Sksewell@umich.eduO3ThreadContext<Impl>::copyArchRegs(ThreadContext *tc)
2642817Sksewell@umich.edu{
2652817Sksewell@umich.edu    // This function will mess things up unless the ROB is empty and
2662817Sksewell@umich.edu    // there are no instructions in the pipeline.
2672817Sksewell@umich.edu    unsigned tid = thread->readTid();
2682817Sksewell@umich.edu    PhysRegIndex renamed_reg;
2692817Sksewell@umich.edu
2702817Sksewell@umich.edu    // First loop through the integer registers.
2712817Sksewell@umich.edu    for (int i = 0; i < TheISA::NumIntRegs; ++i) {
2722817Sksewell@umich.edu        renamed_reg = cpu->renameMap[tid].lookup(i);
2732817Sksewell@umich.edu
2742817Sksewell@umich.edu        DPRINTF(O3CPU, "Copying over register %i, had data %lli, "
2752817Sksewell@umich.edu                "now has data %lli.\n",
2762817Sksewell@umich.edu                renamed_reg, cpu->readIntReg(renamed_reg),
2772817Sksewell@umich.edu                tc->readIntReg(i));
2782817Sksewell@umich.edu
2792817Sksewell@umich.edu        cpu->setIntReg(renamed_reg, tc->readIntReg(i));
2802817Sksewell@umich.edu    }
2812817Sksewell@umich.edu
2822817Sksewell@umich.edu    // Then loop through the floating point registers.
2832817Sksewell@umich.edu    for (int i = 0; i < TheISA::NumFloatRegs; ++i) {
2842817Sksewell@umich.edu        renamed_reg = cpu->renameMap[tid].lookup(i + TheISA::FP_Base_DepTag);
2852817Sksewell@umich.edu        cpu->setFloatRegBits(renamed_reg,
2862817Sksewell@umich.edu                             tc->readFloatRegBits(i));
2872817Sksewell@umich.edu    }
2882817Sksewell@umich.edu
2892817Sksewell@umich.edu    // Copy the misc regs.
2902986Sgblack@eecs.umich.edu    TheISA::copyMiscRegs(tc, this);
2912817Sksewell@umich.edu
2925258Sksewell@umich.edu    // Then finally set the PC, the next PC, the nextNPC, the micropc, and the
2935258Sksewell@umich.edu    // next micropc.
2942817Sksewell@umich.edu    cpu->setPC(tc->readPC(), tid);
2952817Sksewell@umich.edu    cpu->setNextPC(tc->readNextPC(), tid);
2965258Sksewell@umich.edu    cpu->setNextNPC(tc->readNextNPC(), tid);
2975258Sksewell@umich.edu    cpu->setMicroPC(tc->readMicroPC(), tid);
2985258Sksewell@umich.edu    cpu->setNextMicroPC(tc->readNextMicroPC(), tid);
2992817Sksewell@umich.edu#if !FULL_SYSTEM
3002817Sksewell@umich.edu    this->thread->funcExeInst = tc->readFuncExeInst();
3012817Sksewell@umich.edu#endif
3022817Sksewell@umich.edu}
3032817Sksewell@umich.edu
3042817Sksewell@umich.edutemplate <class Impl>
3052817Sksewell@umich.eduvoid
3062817Sksewell@umich.eduO3ThreadContext<Impl>::clearArchRegs()
3072817Sksewell@umich.edu{}
3082817Sksewell@umich.edu
3092817Sksewell@umich.edutemplate <class Impl>
3102817Sksewell@umich.eduuint64_t
3112817Sksewell@umich.eduO3ThreadContext<Impl>::readIntReg(int reg_idx)
3122817Sksewell@umich.edu{
3133776Sgblack@eecs.umich.edu    reg_idx = TheISA::flattenIntIndex(this, reg_idx);
3142817Sksewell@umich.edu    return cpu->readArchIntReg(reg_idx, thread->readTid());
3152817Sksewell@umich.edu}
3162817Sksewell@umich.edu
3172817Sksewell@umich.edutemplate <class Impl>
3182986Sgblack@eecs.umich.eduTheISA::FloatReg
3192817Sksewell@umich.eduO3ThreadContext<Impl>::readFloatReg(int reg_idx, int width)
3202817Sksewell@umich.edu{
3215258Sksewell@umich.edu    reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
3222817Sksewell@umich.edu    switch(width) {
3232817Sksewell@umich.edu      case 32:
3242817Sksewell@umich.edu        return cpu->readArchFloatRegSingle(reg_idx, thread->readTid());
3252817Sksewell@umich.edu      case 64:
3262817Sksewell@umich.edu        return cpu->readArchFloatRegDouble(reg_idx, thread->readTid());
3272817Sksewell@umich.edu      default:
3282817Sksewell@umich.edu        panic("Unsupported width!");
3292817Sksewell@umich.edu        return 0;
3302817Sksewell@umich.edu    }
3312817Sksewell@umich.edu}
3322817Sksewell@umich.edu
3332817Sksewell@umich.edutemplate <class Impl>
3342986Sgblack@eecs.umich.eduTheISA::FloatReg
3352817Sksewell@umich.eduO3ThreadContext<Impl>::readFloatReg(int reg_idx)
3362817Sksewell@umich.edu{
3375258Sksewell@umich.edu    reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
3382817Sksewell@umich.edu    return cpu->readArchFloatRegSingle(reg_idx, thread->readTid());
3392817Sksewell@umich.edu}
3402817Sksewell@umich.edu
3412817Sksewell@umich.edutemplate <class Impl>
3422986Sgblack@eecs.umich.eduTheISA::FloatRegBits
3432817Sksewell@umich.eduO3ThreadContext<Impl>::readFloatRegBits(int reg_idx, int width)
3442817Sksewell@umich.edu{
3452817Sksewell@umich.edu    DPRINTF(Fault, "Reading floatint register through the TC!\n");
3465258Sksewell@umich.edu    reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
3472817Sksewell@umich.edu    return cpu->readArchFloatRegInt(reg_idx, thread->readTid());
3482817Sksewell@umich.edu}
3492817Sksewell@umich.edu
3502817Sksewell@umich.edutemplate <class Impl>
3512986Sgblack@eecs.umich.eduTheISA::FloatRegBits
3522817Sksewell@umich.eduO3ThreadContext<Impl>::readFloatRegBits(int reg_idx)
3532817Sksewell@umich.edu{
3545258Sksewell@umich.edu    reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
3552817Sksewell@umich.edu    return cpu->readArchFloatRegInt(reg_idx, thread->readTid());
3562817Sksewell@umich.edu}
3572817Sksewell@umich.edu
3582817Sksewell@umich.edutemplate <class Impl>
3592817Sksewell@umich.eduvoid
3602817Sksewell@umich.eduO3ThreadContext<Impl>::setIntReg(int reg_idx, uint64_t val)
3612817Sksewell@umich.edu{
3623776Sgblack@eecs.umich.edu    reg_idx = TheISA::flattenIntIndex(this, reg_idx);
3632817Sksewell@umich.edu    cpu->setArchIntReg(reg_idx, val, thread->readTid());
3642817Sksewell@umich.edu
3652817Sksewell@umich.edu    // Squash if we're not already in a state update mode.
3662817Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
3672817Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
3682817Sksewell@umich.edu    }
3692817Sksewell@umich.edu}
3702817Sksewell@umich.edu
3712817Sksewell@umich.edutemplate <class Impl>
3722817Sksewell@umich.eduvoid
3732817Sksewell@umich.eduO3ThreadContext<Impl>::setFloatReg(int reg_idx, FloatReg val, int width)
3742817Sksewell@umich.edu{
3755258Sksewell@umich.edu    reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
3762817Sksewell@umich.edu    switch(width) {
3772817Sksewell@umich.edu      case 32:
3782817Sksewell@umich.edu        cpu->setArchFloatRegSingle(reg_idx, val, thread->readTid());
3792817Sksewell@umich.edu        break;
3802817Sksewell@umich.edu      case 64:
3812817Sksewell@umich.edu        cpu->setArchFloatRegDouble(reg_idx, val, thread->readTid());
3822817Sksewell@umich.edu        break;
3832817Sksewell@umich.edu    }
3842817Sksewell@umich.edu
3852817Sksewell@umich.edu    // Squash if we're not already in a state update mode.
3862817Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
3872817Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
3882817Sksewell@umich.edu    }
3892817Sksewell@umich.edu}
3902817Sksewell@umich.edu
3912817Sksewell@umich.edutemplate <class Impl>
3922817Sksewell@umich.eduvoid
3932817Sksewell@umich.eduO3ThreadContext<Impl>::setFloatReg(int reg_idx, FloatReg val)
3942817Sksewell@umich.edu{
3955258Sksewell@umich.edu    reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
3962817Sksewell@umich.edu    cpu->setArchFloatRegSingle(reg_idx, val, thread->readTid());
3972817Sksewell@umich.edu
3982817Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
3992817Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
4002817Sksewell@umich.edu    }
4012817Sksewell@umich.edu}
4022817Sksewell@umich.edu
4032817Sksewell@umich.edutemplate <class Impl>
4042817Sksewell@umich.eduvoid
4052817Sksewell@umich.eduO3ThreadContext<Impl>::setFloatRegBits(int reg_idx, FloatRegBits val,
4062817Sksewell@umich.edu                                             int width)
4072817Sksewell@umich.edu{
4082817Sksewell@umich.edu    DPRINTF(Fault, "Setting floatint register through the TC!\n");
4095258Sksewell@umich.edu    reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
4102817Sksewell@umich.edu    cpu->setArchFloatRegInt(reg_idx, val, thread->readTid());
4112817Sksewell@umich.edu
4122817Sksewell@umich.edu    // Squash if we're not already in a state update mode.
4132817Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
4142817Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
4152817Sksewell@umich.edu    }
4162817Sksewell@umich.edu}
4172817Sksewell@umich.edu
4182817Sksewell@umich.edutemplate <class Impl>
4192817Sksewell@umich.eduvoid
4202817Sksewell@umich.eduO3ThreadContext<Impl>::setFloatRegBits(int reg_idx, FloatRegBits val)
4212817Sksewell@umich.edu{
4225258Sksewell@umich.edu    reg_idx = TheISA::flattenFloatIndex(this, reg_idx);
4232817Sksewell@umich.edu    cpu->setArchFloatRegInt(reg_idx, val, thread->readTid());
4242817Sksewell@umich.edu
4252817Sksewell@umich.edu    // Squash if we're not already in a state update mode.
4262817Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
4272817Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
4282817Sksewell@umich.edu    }
4292817Sksewell@umich.edu}
4302817Sksewell@umich.edu
4312817Sksewell@umich.edutemplate <class Impl>
4322817Sksewell@umich.eduvoid
4332817Sksewell@umich.eduO3ThreadContext<Impl>::setPC(uint64_t val)
4342817Sksewell@umich.edu{
4352817Sksewell@umich.edu    cpu->setPC(val, thread->readTid());
4362817Sksewell@umich.edu
4372817Sksewell@umich.edu    // Squash if we're not already in a state update mode.
4382817Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
4392817Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
4402817Sksewell@umich.edu    }
4412817Sksewell@umich.edu}
4422817Sksewell@umich.edu
4432817Sksewell@umich.edutemplate <class Impl>
4442817Sksewell@umich.eduvoid
4452817Sksewell@umich.eduO3ThreadContext<Impl>::setNextPC(uint64_t val)
4462817Sksewell@umich.edu{
4472817Sksewell@umich.edu    cpu->setNextPC(val, thread->readTid());
4482817Sksewell@umich.edu
4492817Sksewell@umich.edu    // Squash if we're not already in a state update mode.
4502817Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
4512817Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
4522817Sksewell@umich.edu    }
4532817Sksewell@umich.edu}
4542817Sksewell@umich.edu
4552817Sksewell@umich.edutemplate <class Impl>
4563468Sgblack@eecs.umich.eduvoid
4575258Sksewell@umich.eduO3ThreadContext<Impl>::setMicroPC(uint64_t val)
4585258Sksewell@umich.edu{
4595258Sksewell@umich.edu    cpu->setMicroPC(val, thread->readTid());
4605258Sksewell@umich.edu
4615258Sksewell@umich.edu    // Squash if we're not already in a state update mode.
4625258Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
4635258Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
4645258Sksewell@umich.edu    }
4655258Sksewell@umich.edu}
4665258Sksewell@umich.edu
4675258Sksewell@umich.edutemplate <class Impl>
4685258Sksewell@umich.eduvoid
4695258Sksewell@umich.eduO3ThreadContext<Impl>::setNextMicroPC(uint64_t val)
4705258Sksewell@umich.edu{
4715258Sksewell@umich.edu    cpu->setNextMicroPC(val, thread->readTid());
4725258Sksewell@umich.edu
4735258Sksewell@umich.edu    // Squash if we're not already in a state update mode.
4745258Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
4755258Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
4765258Sksewell@umich.edu    }
4775258Sksewell@umich.edu}
4785258Sksewell@umich.edu
4795258Sksewell@umich.edutemplate <class Impl>
4805258Sksewell@umich.eduvoid
4814172Ssaidi@eecs.umich.eduO3ThreadContext<Impl>::setMiscRegNoEffect(int misc_reg, const MiscReg &val)
4822817Sksewell@umich.edu{
4834172Ssaidi@eecs.umich.edu    cpu->setMiscRegNoEffect(misc_reg, val, thread->readTid());
4842817Sksewell@umich.edu
4852817Sksewell@umich.edu    // Squash if we're not already in a state update mode.
4862817Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
4872817Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
4882817Sksewell@umich.edu    }
4892817Sksewell@umich.edu}
4902817Sksewell@umich.edu
4912817Sksewell@umich.edutemplate <class Impl>
4923468Sgblack@eecs.umich.eduvoid
4934172Ssaidi@eecs.umich.eduO3ThreadContext<Impl>::setMiscReg(int misc_reg,
4942817Sksewell@umich.edu                                                const MiscReg &val)
4952817Sksewell@umich.edu{
4964172Ssaidi@eecs.umich.edu    cpu->setMiscReg(misc_reg, val, thread->readTid());
4972817Sksewell@umich.edu
4982817Sksewell@umich.edu    // Squash if we're not already in a state update mode.
4992817Sksewell@umich.edu    if (!thread->trapPending && !thread->inSyscall) {
5002817Sksewell@umich.edu        cpu->squashFromTC(thread->readTid());
5012817Sksewell@umich.edu    }
5022817Sksewell@umich.edu}
5032817Sksewell@umich.edu
5042817Sksewell@umich.edu#if !FULL_SYSTEM
5052817Sksewell@umich.edu
5062817Sksewell@umich.edutemplate <class Impl>
5072817Sksewell@umich.eduTheISA::IntReg
5082817Sksewell@umich.eduO3ThreadContext<Impl>::getSyscallArg(int i)
5092817Sksewell@umich.edu{
5102817Sksewell@umich.edu    return cpu->getSyscallArg(i, thread->readTid());
5112817Sksewell@umich.edu}
5122817Sksewell@umich.edu
5132817Sksewell@umich.edutemplate <class Impl>
5142817Sksewell@umich.eduvoid
5152817Sksewell@umich.eduO3ThreadContext<Impl>::setSyscallArg(int i, IntReg val)
5162817Sksewell@umich.edu{
5172817Sksewell@umich.edu    cpu->setSyscallArg(i, val, thread->readTid());
5182817Sksewell@umich.edu}
5192817Sksewell@umich.edu
5202817Sksewell@umich.edutemplate <class Impl>
5212817Sksewell@umich.eduvoid
5222817Sksewell@umich.eduO3ThreadContext<Impl>::setSyscallReturn(SyscallReturn return_value)
5232817Sksewell@umich.edu{
5242817Sksewell@umich.edu    cpu->setSyscallReturn(return_value, thread->readTid());
5252817Sksewell@umich.edu}
5262817Sksewell@umich.edu
5272817Sksewell@umich.edu#endif // FULL_SYSTEM
5282817Sksewell@umich.edu
529