2 * Copyright (c) 2006 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "config/full_system.hh"
33 #include "config/use_checker.hh"
35 #include "arch/isa_traits.hh" // For MachInst
36 #include "base/trace.hh"
37 #include "cpu/base.hh"
38 #include "cpu/simple_thread.hh"
39 #include "cpu/thread_context.hh"
40 #include "cpu/exetrace.hh"
41 #include "cpu/ozone/cpu.hh"
42 #include "cpu/quiesce_event.hh"
43 #include "cpu/static_inst.hh"
44 #include "sim/sim_object.hh"
45 #include "sim/stats.hh"
48 #include "arch/faults.hh"
49 #include "arch/alpha/osfpal.hh"
50 #include "arch/alpha/tlb.hh"
51 #include "arch/alpha/types.hh"
52 #include "arch/vtophys.hh"
53 #include "base/callback.hh"
54 #include "cpu/profile.hh"
55 #include "kern/kernel_stats.hh"
56 #include "mem/physical.hh"
57 #include "sim/faults.hh"
58 #include "sim/sim_events.hh"
59 #include "sim/sim_exit.hh"
60 #include "sim/system.hh"
62 #include "sim/process.hh"
66 #include "cpu/checker/thread_context.hh"
69 using namespace TheISA;
72 OzoneCPU<Impl>::TickEvent::TickEvent(OzoneCPU *c, int w)
73 : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c), width(w)
79 OzoneCPU<Impl>::TickEvent::process()
86 OzoneCPU<Impl>::TickEvent::description()
88 return "OzoneCPU tick event";
92 OzoneCPU<Impl>::OzoneCPU(Params *p)
94 : BaseCPU(p), thread(this, 0), tickEvent(this, p->width),
96 : BaseCPU(p), thread(this, 0, p->workload[0], 0, p->mem),
97 tickEvent(this, p->width),
99 mem(p->mem), comm(5, 5)
101 frontEnd = new FrontEnd(p);
102 backEnd = new BackEnd(p);
108 BaseCPU *temp_checker = p->checker;
109 checker = dynamic_cast<Checker<DynInstPtr> *>(temp_checker);
110 checker->setMemory(mem);
112 checker->setSystem(p->system);
114 checkerTC = new CheckerThreadContext<OzoneTC>(&ozoneTC, checker);
115 thread.tc = checkerTC;
118 panic("Checker enabled but not compiled in!");
121 // If checker is not being used, then the xcProxy points
122 // directly to the CPU's ExecContext.
124 thread.tc = &ozoneTC;
129 ozoneTC.thread = &thread;
131 thread.inSyscall = false;
133 thread.setStatus(ThreadContext::Suspended);
135 // Setup thread state stuff.
139 thread.quiesceEvent = new EndQuiesceEvent(tc);
144 physmem = p->system->physmem;
147 thread.profile = new FunctionProfile(p->system->kernelSymtab);
148 // @todo: This might be better as an ThreadContext instead of OzoneTC
150 new MakeCallback<OzoneTC,
151 &OzoneTC::dumpFuncProfile>(&ozoneTC);
152 registerExitCallback(cb);
155 // let's fill with a dummy node for now so we don't get a segfault
156 // on the first cycle when there's no node available.
157 static ProfileNode dummyNode;
158 thread.profileNode = &dummyNode;
159 thread.profilePC = 3;
162 #endif // !FULL_SYSTEM
167 threadContexts.push_back(tc);
169 frontEnd->setCPU(this);
170 backEnd->setCPU(this);
175 frontEnd->setThreadState(&thread);
176 backEnd->setThreadState(&thread);
178 frontEnd->setCommBuffer(&comm);
179 backEnd->setCommBuffer(&comm);
181 frontEnd->setBackEnd(backEnd);
182 backEnd->setFrontEnd(frontEnd);
187 checkInterrupts = false;
192 // Setup rename table, initializing all values to ready.
193 for (int i = 0; i < TheISA::TotalNumRegs; ++i) {
194 thread.renameTable[i] = new DynInst(this);
195 thread.renameTable[i]->setResultReady();
198 frontEnd->renameTable.copyFrom(thread.renameTable);
199 backEnd->renameTable.copyFrom(thread.renameTable);
202 /* Use this port to for syscall emulation writes to memory. */
204 TranslatingPort *trans_port;
205 trans_port = new TranslatingPort(csprintf("%s-%d-funcport",
207 p->workload[0]->pTable,
209 mem_port = p->mem->getPort("functional");
210 mem_port->setPeer(trans_port);
211 trans_port->setPeer(mem_port);
212 thread.setMemPort(trans_port);
215 FunctionalPort *phys_port;
216 VirtualPort *virt_port;
217 phys_port = new FunctionalPort(csprintf("%s-%d-funcport",
219 mem_port = system->physmem->getPort("functional");
220 mem_port->setPeer(phys_port);
221 phys_port->setPeer(mem_port);
223 virt_port = new VirtualPort(csprintf("%s-%d-vport",
225 mem_port = system->physmem->getPort("functional");
226 mem_port->setPeer(virt_port);
227 virt_port->setPeer(mem_port);
229 thread.setPhysPort(phys_port);
230 thread.setVirtPort(virt_port);
233 DPRINTF(OzoneCPU, "OzoneCPU: Created Ozone cpu object.\n");
236 template <class Impl>
237 OzoneCPU<Impl>::~OzoneCPU()
241 template <class Impl>
243 OzoneCPU<Impl>::switchOut()
245 BaseCPU::switchOut();
247 // Front end needs state from back end, so switch out the back end first.
248 backEnd->switchOut();
249 frontEnd->switchOut();
252 template <class Impl>
254 OzoneCPU<Impl>::signalSwitched()
256 // Only complete the switchout when both the front end and back
257 // end have signalled they are ready to switch.
258 if (++switchCount == 2) {
259 backEnd->doSwitchOut();
260 frontEnd->doSwitchOut();
263 checker->switchOut();
266 _status = SwitchedOut;
268 // Loop through all registers
269 for (int i = 0; i < AlphaISA::TotalNumRegs; ++i) {
270 assert(thread.renameTable[i] == frontEnd->renameTable[i]);
272 assert(thread.renameTable[i] == backEnd->renameTable[i]);
274 DPRINTF(OzoneCPU, "Checking if register %i matches.\n", i);
278 if (tickEvent.scheduled())
281 assert(switchCount <= 2);
284 template <class Impl>
286 OzoneCPU<Impl>::takeOverFrom(BaseCPU *oldCPU)
288 BaseCPU::takeOverFrom(oldCPU);
290 thread.trapPending = false;
291 thread.inSyscall = false;
293 backEnd->takeOverFrom();
294 frontEnd->takeOverFrom();
295 frontEnd->renameTable.copyFrom(thread.renameTable);
296 backEnd->renameTable.copyFrom(thread.renameTable);
297 assert(!tickEvent.scheduled());
300 // Check rename table.
301 for (int i = 0; i < TheISA::TotalNumRegs; ++i) {
302 assert(thread.renameTable[i]->isResultReady());
306 // @todo: Fix hardcoded number
307 // Clear out any old information in time buffer.
308 for (int i = 0; i < 15; ++i) {
312 // if any of this CPU's ThreadContexts are active, mark the CPU as
313 // running and schedule its tick event.
314 for (int i = 0; i < threadContexts.size(); ++i) {
315 ThreadContext *tc = threadContexts[i];
316 if (tc->status() == ThreadContext::Active &&
317 _status != Running) {
319 tickEvent.schedule(curTick);
322 // Nothing running, change status to reflect that we're no longer
324 if (_status == SwitchedOut) {
329 template <class Impl>
331 OzoneCPU<Impl>::activateContext(int thread_num, int delay)
333 // Eventually change this in SMT.
334 assert(thread_num == 0);
336 assert(_status == Idle);
338 scheduleTickEvent(delay);
341 if (thread.quiesceEvent && thread.quiesceEvent->scheduled())
342 thread.quiesceEvent->deschedule();
344 thread.setStatus(ThreadContext::Active);
345 frontEnd->wakeFromQuiesce();
348 template <class Impl>
350 OzoneCPU<Impl>::suspendContext(int thread_num)
352 // Eventually change this in SMT.
353 assert(thread_num == 0);
354 // @todo: Figure out how to initially set the status properly so
356 // assert(_status == Running);
358 unscheduleTickEvent();
362 template <class Impl>
364 OzoneCPU<Impl>::deallocateContext(int thread_num, int delay)
366 // for now, these are equivalent
367 suspendContext(thread_num);
370 template <class Impl>
372 OzoneCPU<Impl>::haltContext(int thread_num)
374 // for now, these are equivalent
375 suspendContext(thread_num);
378 template <class Impl>
380 OzoneCPU<Impl>::regStats()
382 using namespace Stats;
387 .name(name() + ".num_insts")
388 .desc("Number of instructions executed")
392 .name(name() + ".num_refs")
393 .desc("Number of memory references")
397 .name(name() + ".not_idle_fraction")
398 .desc("Percentage of non-idle cycles")
402 .name(name() + ".idle_fraction")
403 .desc("Percentage of idle cycles")
407 .name(name() + ".quiesce_cycles")
408 .desc("Number of cycles spent in quiesce")
411 idleFraction = constant(1.0) - notIdleFraction;
413 frontEnd->regStats();
417 template <class Impl>
419 OzoneCPU<Impl>::resetStats()
421 // startNumInst = numInst;
422 notIdleFraction = (_status != Idle);
425 template <class Impl>
427 OzoneCPU<Impl>::init()
431 // Mark this as in syscall so it won't need to squash
432 thread.inSyscall = true;
434 for (int i = 0; i < threadContexts.size(); ++i) {
435 ThreadContext *tc = threadContexts[i];
437 // initialize CPU, including PC
438 TheISA::initCPU(tc, tc->readCpuId());
441 frontEnd->renameTable.copyFrom(thread.renameTable);
442 backEnd->renameTable.copyFrom(thread.renameTable);
444 thread.inSyscall = false;
447 template <class Impl>
449 OzoneCPU<Impl>::getPort(const std::string &if_name, int idx)
451 if (if_name == "dcache_port")
452 return backEnd->getDcachePort();
453 else if (if_name == "icache_port")
454 return frontEnd->getIcachePort();
456 panic("No Such Port\n");
459 template <class Impl>
461 OzoneCPU<Impl>::serialize(std::ostream &os)
463 BaseCPU::serialize(os);
464 SERIALIZE_ENUM(_status);
465 nameOut(os, csprintf("%s.tc", name()));
466 ozoneTC.serialize(os);
467 nameOut(os, csprintf("%s.tickEvent", name()));
468 tickEvent.serialize(os);
470 // Use SimpleThread's ability to checkpoint to make it easier to
471 // write out the registers. Also make this static so it doesn't
472 // get instantiated multiple times (causes a panic in statistics).
473 static SimpleThread temp;
475 nameOut(os, csprintf("%s.xc.0", name()));
476 temp.copyTC(thread.getTC());
480 template <class Impl>
482 OzoneCPU<Impl>::unserialize(Checkpoint *cp, const std::string §ion)
484 BaseCPU::unserialize(cp, section);
485 UNSERIALIZE_ENUM(_status);
486 ozoneTC.unserialize(cp, csprintf("%s.tc", section));
487 tickEvent.unserialize(cp, csprintf("%s.tickEvent", section));
489 // Use SimpleThread's ability to checkpoint to make it easier to
490 // read in the registers. Also make this static so it doesn't
491 // get instantiated multiple times (causes a panic in statistics).
492 static SimpleThread temp;
494 temp.copyTC(thread.getTC());
495 temp.unserialize(cp, csprintf("%s.xc.0", section));
496 thread.getTC()->copyArchRegs(temp.getTC());
499 template <class Impl>
501 OzoneCPU<Impl>::copySrcTranslate(Addr src)
503 panic("Copy not implemented!\n");
506 static bool no_warn = true;
507 int blk_size = (dcacheInterface) ? dcacheInterface->getBlockSize() : 64;
508 // Only support block sizes of 64 atm.
509 assert(blk_size == 64);
510 int offset = src & (blk_size - 1);
512 // Make sure block doesn't span page
514 (src & TheISA::PageMask) != ((src + blk_size) & TheISA::PageMask) &&
515 (src >> 40) != 0xfffffc) {
516 warn("Copied block source spans pages %x.", src);
520 memReq->reset(src & ~(blk_size - 1), blk_size);
522 // translate to physical address
523 Fault fault = tc->translateDataReadReq(memReq);
525 assert(fault != Alignment_Fault);
527 if (fault == NoFault) {
528 tc->copySrcAddr = src;
529 tc->copySrcPhysAddr = memReq->paddr + offset;
532 tc->copySrcPhysAddr = 0;
538 template <class Impl>
540 OzoneCPU<Impl>::copy(Addr dest)
542 panic("Copy not implemented!\n");
545 static bool no_warn = true;
546 int blk_size = (dcacheInterface) ? dcacheInterface->getBlockSize() : 64;
547 // Only support block sizes of 64 atm.
548 assert(blk_size == 64);
549 uint8_t data[blk_size];
550 //assert(tc->copySrcAddr);
551 int offset = dest & (blk_size - 1);
553 // Make sure block doesn't span page
555 (dest & TheISA::PageMask) != ((dest + blk_size) & TheISA::PageMask) &&
556 (dest >> 40) != 0xfffffc) {
558 warn("Copied block destination spans pages %x. ", dest);
561 memReq->reset(dest & ~(blk_size -1), blk_size);
562 // translate to physical address
563 Fault fault = tc->translateDataWriteReq(memReq);
565 assert(fault != Alignment_Fault);
567 if (fault == NoFault) {
568 Addr dest_addr = memReq->paddr + offset;
569 // Need to read straight from memory since we have more than 8 bytes.
570 memReq->paddr = tc->copySrcPhysAddr;
571 tc->mem->read(memReq, data);
572 memReq->paddr = dest_addr;
573 tc->mem->write(memReq, data);
574 if (dcacheInterface) {
576 memReq->completionEvent = NULL;
577 memReq->paddr = tc->copySrcPhysAddr;
578 memReq->dest = dest_addr;
580 memReq->time = curTick;
581 dcacheInterface->access(memReq);
589 template <class Impl>
591 OzoneCPU<Impl>::dbg_vtophys(Addr addr)
593 return vtophys(tc, addr);
595 #endif // FULL_SYSTEM
598 template <class Impl>
600 OzoneCPU<Impl>::post_interrupt(int int_num, int index)
602 BaseCPU::post_interrupt(int_num, index);
604 if (_status == Idle) {
605 DPRINTF(IPI,"Suspended Processor awoke\n");
606 // thread.activate();
607 // Hack for now. Otherwise might have to go through the tc, or
608 // I need to figure out what's the right thing to call.
609 activateContext(thread.readTid(), 1);
612 #endif // FULL_SYSTEM
614 /* start simulation, program loaded, processor precise state initialized */
615 template <class Impl>
617 OzoneCPU<Impl>::tick()
619 DPRINTF(OzoneCPU, "\n\nOzoneCPU: Ticking cpu.\n");
622 thread.renameTable[ZeroReg]->setIntResult(0);
623 thread.renameTable[ZeroReg+TheISA::FP_Base_DepTag]->
624 setDoubleResult(0.0);
630 // check for instruction-count-based events
631 comInstEventQueue[0]->serviceEvents(numInst);
633 if (!tickEvent.scheduled() && _status == Running)
634 tickEvent.schedule(curTick + cycles(1));
637 template <class Impl>
639 OzoneCPU<Impl>::squashFromTC()
641 thread.inSyscall = true;
642 backEnd->generateTCEvent();
646 template <class Impl>
648 OzoneCPU<Impl>::syscall(uint64_t &callnum)
650 // Not sure this copy is needed, depending on how the TC proxy is made.
651 thread.renameTable.copyFrom(backEnd->renameTable);
653 thread.inSyscall = true;
655 thread.funcExeInst++;
657 DPRINTF(OzoneCPU, "FuncExeInst: %i\n", thread.funcExeInst);
659 thread.process->syscall(callnum, tc);
661 thread.funcExeInst--;
663 thread.inSyscall = false;
665 frontEnd->renameTable.copyFrom(thread.renameTable);
666 backEnd->renameTable.copyFrom(thread.renameTable);
669 template <class Impl>
671 OzoneCPU<Impl>::setSyscallReturn(SyscallReturn return_value, int tid)
673 // check for error condition. Alpha syscall convention is to
674 // indicate success/failure in reg a3 (r19) and put the
675 // return value itself in the standard return value reg (v0).
676 if (return_value.successful()) {
678 thread.renameTable[SyscallSuccessReg]->setIntResult(0);
679 thread.renameTable[ReturnValueReg]->setIntResult(
680 return_value.value());
682 // got an error, return details
683 thread.renameTable[SyscallSuccessReg]->setIntResult((IntReg) -1);
684 thread.renameTable[ReturnValueReg]->setIntResult(
685 -return_value.value());
689 template <class Impl>
691 OzoneCPU<Impl>::hwrei()
693 // Need to move this to ISA code
694 // May also need to make this per thread
697 lockAddrList.clear();
698 thread.kernelStats->hwrei();
700 checkInterrupts = true;
702 // FIXME: XXX check for interrupts? XXX
706 template <class Impl>
708 OzoneCPU<Impl>::processInterrupts()
710 // Check for interrupts here. For now can copy the code that
711 // exists within isa_fullsys_traits.hh. Also assume that thread 0
712 // is the one that handles the interrupts.
714 // Check if there are any outstanding interrupts
715 //Handle the interrupts
719 checkInterrupts = false;
721 if (thread.readMiscReg(IPR_ASTRR))
722 panic("asynchronous traps not implemented\n");
724 if (thread.readMiscReg(IPR_SIRR)) {
725 for (int i = INTLEVEL_SOFTWARE_MIN;
726 i < INTLEVEL_SOFTWARE_MAX; i++) {
727 if (thread.readMiscReg(IPR_SIRR) & (ULL(1) << i)) {
728 // See table 4-19 of the 21164 hardware reference
729 ipl = (i - INTLEVEL_SOFTWARE_MIN) + 1;
730 summary |= (ULL(1) << i);
735 uint64_t interrupts = intr_status();
738 for (int i = INTLEVEL_EXTERNAL_MIN;
739 i < INTLEVEL_EXTERNAL_MAX; i++) {
740 if (interrupts & (ULL(1) << i)) {
741 // See table 4-19 of the 21164 hardware reference
743 summary |= (ULL(1) << i);
748 if (ipl && ipl > thread.readMiscReg(IPR_IPLR)) {
749 thread.setMiscReg(IPR_ISR, summary);
750 thread.setMiscReg(IPR_INTID, ipl);
752 // @todo: Make this more transparent
754 checker->threadBase()->setMiscReg(IPR_ISR, summary);
755 checker->threadBase()->setMiscReg(IPR_INTID, ipl);
758 Fault fault = new InterruptFault;
759 fault->invoke(thread.getTC());
760 DPRINTF(Flow, "Interrupt! IPLR=%d ipl=%d summary=%x\n",
761 thread.readMiscReg(IPR_IPLR), ipl, summary);
765 template <class Impl>
767 OzoneCPU<Impl>::simPalCheck(int palFunc)
769 // Need to move this to ISA code
770 // May also need to make this per thread
771 thread.kernelStats->callpal(palFunc, tc);
775 haltContext(thread.readTid());
776 if (--System::numSystemsRunning == 0)
777 exitSimLoop("all cpus halted");
782 if (system->breakpoint())
791 template <class Impl>
793 OzoneCPU<Impl>::OzoneTC::getCpuPtr()
798 template <class Impl>
800 OzoneCPU<Impl>::OzoneTC::setCpuId(int id)
803 thread->setCpuId(id);
807 template <class Impl>
809 OzoneCPU<Impl>::OzoneTC::delVirtPort(VirtualPort *vp)
811 delete vp->getPeer();
816 template <class Impl>
818 OzoneCPU<Impl>::OzoneTC::setStatus(Status new_status)
820 thread->setStatus(new_status);
823 template <class Impl>
825 OzoneCPU<Impl>::OzoneTC::activate(int delay)
827 cpu->activateContext(thread->readTid(), delay);
830 /// Set the status to Suspended.
831 template <class Impl>
833 OzoneCPU<Impl>::OzoneTC::suspend()
835 cpu->suspendContext(thread->readTid());
838 /// Set the status to Unallocated.
839 template <class Impl>
841 OzoneCPU<Impl>::OzoneTC::deallocate(int delay)
843 cpu->deallocateContext(thread->readTid(), delay);
846 /// Set the status to Halted.
847 template <class Impl>
849 OzoneCPU<Impl>::OzoneTC::halt()
851 cpu->haltContext(thread->readTid());
855 template <class Impl>
857 OzoneCPU<Impl>::OzoneTC::dumpFuncProfile()
859 thread->dumpFuncProfile();
863 template <class Impl>
865 OzoneCPU<Impl>::OzoneTC::takeOverFrom(ThreadContext *old_context)
867 // some things should already be set up
869 assert(getSystemPtr() == old_context->getSystemPtr());
871 assert(getProcessPtr() == old_context->getProcessPtr());
874 // copy over functional state
875 setStatus(old_context->status());
876 copyArchRegs(old_context);
877 setCpuId(old_context->readCpuId());
879 thread->setInst(old_context->getInst());
881 setFuncExeInst(old_context->readFuncExeInst());
883 EndQuiesceEvent *other_quiesce = old_context->getQuiesceEvent();
885 // Point the quiesce event's TC at this TC so that it wakes up
887 other_quiesce->tc = this;
889 if (thread->quiesceEvent) {
890 thread->quiesceEvent->tc = this;
893 // Copy kernel stats pointer from old context.
894 thread->kernelStats = old_context->getKernelStats();
895 // storeCondFailures = 0;
896 cpu->lockFlag = false;
899 old_context->setStatus(ThreadContext::Unallocated);
902 template <class Impl>
904 OzoneCPU<Impl>::OzoneTC::regStats(const std::string &name)
907 thread->kernelStats = new Kernel::Statistics(cpu->system);
908 thread->kernelStats->regStats(name + ".kern");
912 template <class Impl>
914 OzoneCPU<Impl>::OzoneTC::serialize(std::ostream &os)
916 // Once serialization is added, serialize the quiesce event and
917 // kernel stats. Will need to make sure there aren't multiple
918 // things that serialize them.
921 template <class Impl>
923 OzoneCPU<Impl>::OzoneTC::unserialize(Checkpoint *cp, const std::string §ion)
927 template <class Impl>
929 OzoneCPU<Impl>::OzoneTC::getQuiesceEvent()
931 return thread->quiesceEvent;
934 template <class Impl>
936 OzoneCPU<Impl>::OzoneTC::readLastActivate()
938 return thread->lastActivate;
941 template <class Impl>
943 OzoneCPU<Impl>::OzoneTC::readLastSuspend()
945 return thread->lastSuspend;
948 template <class Impl>
950 OzoneCPU<Impl>::OzoneTC::profileClear()
952 thread->profileClear();
955 template <class Impl>
957 OzoneCPU<Impl>::OzoneTC::profileSample()
959 thread->profileSample();
963 template <class Impl>
965 OzoneCPU<Impl>::OzoneTC::getThreadNum()
967 return thread->readTid();
970 template <class Impl>
972 OzoneCPU<Impl>::OzoneTC::getInst()
974 return thread->getInst();
977 template <class Impl>
979 OzoneCPU<Impl>::OzoneTC::copyArchRegs(ThreadContext *tc)
981 thread->PC = tc->readPC();
982 thread->nextPC = tc->readNextPC();
984 cpu->frontEnd->setPC(thread->PC);
985 cpu->frontEnd->setNextPC(thread->nextPC);
987 // First loop through the integer registers.
988 for (int i = 0; i < TheISA::NumIntRegs; ++i) {
989 /* DPRINTF(OzoneCPU, "Copying over register %i, had data %lli, "
990 "now has data %lli.\n",
991 i, thread->renameTable[i]->readIntResult(),
994 thread->renameTable[i]->setIntResult(tc->readIntReg(i));
997 // Then loop through the floating point registers.
998 for (int i = 0; i < TheISA::NumFloatRegs; ++i) {
999 int fp_idx = i + TheISA::FP_Base_DepTag;
1000 thread->renameTable[fp_idx]->setIntResult(tc->readFloatRegBits(i));
1004 thread->funcExeInst = tc->readFuncExeInst();
1007 // Need to copy the TC values into the current rename table,
1008 // copy the misc regs.
1009 copyMiscRegs(tc, this);
1012 template <class Impl>
1014 OzoneCPU<Impl>::OzoneTC::clearArchRegs()
1016 panic("Unimplemented!");
1019 template <class Impl>
1021 OzoneCPU<Impl>::OzoneTC::readIntReg(int reg_idx)
1023 return thread->renameTable[reg_idx]->readIntResult();
1026 template <class Impl>
1028 OzoneCPU<Impl>::OzoneTC::readFloatReg(int reg_idx, int width)
1030 int idx = reg_idx + TheISA::FP_Base_DepTag;
1033 return thread->renameTable[idx]->readFloatResult();
1035 return thread->renameTable[idx]->readDoubleResult();
1037 panic("Unsupported width!");
1042 template <class Impl>
1044 OzoneCPU<Impl>::OzoneTC::readFloatReg(int reg_idx)
1046 int idx = reg_idx + TheISA::FP_Base_DepTag;
1047 return thread->renameTable[idx]->readFloatResult();
1050 template <class Impl>
1052 OzoneCPU<Impl>::OzoneTC::readFloatRegBits(int reg_idx, int width)
1054 int idx = reg_idx + TheISA::FP_Base_DepTag;
1055 return thread->renameTable[idx]->readIntResult();
1058 template <class Impl>
1060 OzoneCPU<Impl>::OzoneTC::readFloatRegBits(int reg_idx)
1062 int idx = reg_idx + TheISA::FP_Base_DepTag;
1063 return thread->renameTable[idx]->readIntResult();
1066 template <class Impl>
1068 OzoneCPU<Impl>::OzoneTC::setIntReg(int reg_idx, uint64_t val)
1070 thread->renameTable[reg_idx]->setIntResult(val);
1072 if (!thread->inSyscall) {
1073 cpu->squashFromTC();
1077 template <class Impl>
1079 OzoneCPU<Impl>::OzoneTC::setFloatReg(int reg_idx, FloatReg val, int width)
1081 int idx = reg_idx + TheISA::FP_Base_DepTag;
1084 panic("Unimplemented!");
1087 thread->renameTable[idx]->setDoubleResult(val);
1090 panic("Unsupported width!");
1093 if (!thread->inSyscall) {
1094 cpu->squashFromTC();
1098 template <class Impl>
1100 OzoneCPU<Impl>::OzoneTC::setFloatReg(int reg_idx, FloatReg val)
1102 int idx = reg_idx + TheISA::FP_Base_DepTag;
1104 thread->renameTable[idx]->setDoubleResult(val);
1106 if (!thread->inSyscall) {
1107 cpu->squashFromTC();
1111 template <class Impl>
1113 OzoneCPU<Impl>::OzoneTC::setFloatRegBits(int reg_idx, FloatRegBits val,
1116 panic("Unimplemented!");
1119 template <class Impl>
1121 OzoneCPU<Impl>::OzoneTC::setFloatRegBits(int reg_idx, FloatRegBits val)
1123 panic("Unimplemented!");
1126 template <class Impl>
1128 OzoneCPU<Impl>::OzoneTC::setPC(Addr val)
1131 cpu->frontEnd->setPC(val);
1133 if (!thread->inSyscall) {
1134 cpu->squashFromTC();
1138 template <class Impl>
1140 OzoneCPU<Impl>::OzoneTC::setNextPC(Addr val)
1142 thread->nextPC = val;
1143 cpu->frontEnd->setNextPC(val);
1145 if (!thread->inSyscall) {
1146 cpu->squashFromTC();
1150 template <class Impl>
1152 OzoneCPU<Impl>::OzoneTC::readMiscReg(int misc_reg)
1154 return thread->miscRegFile.readReg(misc_reg);
1157 template <class Impl>
1159 OzoneCPU<Impl>::OzoneTC::readMiscRegWithEffect(int misc_reg, Fault &fault)
1161 return thread->miscRegFile.readRegWithEffect(misc_reg,
1165 template <class Impl>
1167 OzoneCPU<Impl>::OzoneTC::setMiscReg(int misc_reg, const MiscReg &val)
1169 // Needs to setup a squash event unless we're in syscall mode
1170 Fault ret_fault = thread->miscRegFile.setReg(misc_reg, val);
1172 if (!thread->inSyscall) {
1173 cpu->squashFromTC();
1179 template <class Impl>
1181 OzoneCPU<Impl>::OzoneTC::setMiscRegWithEffect(int misc_reg, const MiscReg &val)
1183 // Needs to setup a squash event unless we're in syscall mode
1184 Fault ret_fault = thread->miscRegFile.setRegWithEffect(misc_reg, val,
1187 if (!thread->inSyscall) {
1188 cpu->squashFromTC();