Deleted Added
sdiff udiff text old ( 12427:b0611f1ad833 ) new ( 12749:223c83ed9979 )
full compact
1/*
2 * Copyright (c) 2010-2014 ARM Limited
3 * Copyright (c) 2012-2013 AMD
4 * All rights reserved.
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

--- 374 unchanged lines hidden (view full) ---

383 DPRINTF(Fetch, "[tid:%u] Waking up from cache miss.\n", tid);
384 assert(!cpu->switchedOut());
385
386 // Only change the status if it's still waiting on the icache access
387 // to return.
388 if (fetchStatus[tid] != IcacheWaitResponse ||
389 pkt->req != memReq[tid]) {
390 ++fetchIcacheSquashes;
391 delete pkt;
392 return;
393 }
394
395 memcpy(fetchBuffer[tid], pkt->getConstPtr<uint8_t>(), fetchBufferSize);
396 fetchBufferValid[tid] = true;
397
398 // Wake up the CPU (if it went to sleep and was waiting on

--- 10 unchanged lines hidden (view full) ---

409 fetchStatus[tid] = Blocked;
410 } else {
411 fetchStatus[tid] = IcacheAccessComplete;
412 }
413
414 pkt->req->setAccessLatency();
415 cpu->ppInstAccessComplete->notify(pkt);
416 // Reset the mem req to NULL.
417 delete pkt;
418 memReq[tid] = NULL;
419}
420
421template <class Impl>
422void
423DefaultFetch<Impl>::drainResume()
424{

--- 189 unchanged lines hidden (view full) ---

614 Addr fetchBufferBlockPC = fetchBufferAlignPC(vaddr);
615
616 DPRINTF(Fetch, "[tid:%i] Fetching cache line %#x for addr %#x\n",
617 tid, fetchBufferBlockPC, vaddr);
618
619 // Setup the memReq to do a read of the first instruction's address.
620 // Set the appropriate read size and flags as well.
621 // Build request here.
622 RequestPtr mem_req = std::make_shared<Request>(
623 tid, fetchBufferBlockPC, fetchBufferSize,
624 Request::INST_FETCH, cpu->instMasterId(), pc,
625 cpu->thread[tid]->contextId());
626
627 mem_req->taskId(cpu->taskId());
628
629 memReq[tid] = mem_req;
630
631 // Initiate translation of the icache block
632 fetchStatus[tid] = ItlbWait;
633 FetchTranslation *trans = new FetchTranslation(this);
634 cpu->itb->translateTiming(mem_req, cpu->thread[tid]->getTC(),
635 trans, BaseTLB::Execute);
636 return true;
637}
638
639template <class Impl>
640void
641DefaultFetch::finishTranslation(const Fault &fault,
642 const RequestPtr &mem_req)
643{
644 ThreadID tid = cpu->contextToThread(mem_req->contextId());
645 Addr fetchBufferBlockPC = mem_req->getVaddr();
646
647 assert(!cpu->switchedOut());
648
649 // Wake up CPU if it was idle
650 cpu->wakeCPU();
651
652 if (fetchStatus[tid] != ItlbWait || mem_req != memReq[tid] ||
653 mem_req->getVaddr() != memReq[tid]->getVaddr()) {
654 DPRINTF(Fetch, "[tid:%i] Ignoring itlb completed after squash\n",
655 tid);
656 ++fetchTlbSquashes;
657 return;
658 }
659
660
661 // If translation was successful, attempt to read the icache block.
662 if (fault == NoFault) {
663 // Check that we're not going off into random memory
664 // If we have, just wait around for commit to squash something and put
665 // us on the right track
666 if (!cpu->system->isMemAddr(mem_req->getPaddr())) {
667 warn("Address %#x is outside of physical memory, stopping fetch\n",
668 mem_req->getPaddr());
669 fetchStatus[tid] = NoGoodAddr;
670 memReq[tid] = NULL;
671 return;
672 }
673
674 // Build packet here.
675 PacketPtr data_pkt = new Packet(mem_req, MemCmd::ReadReq);
676 data_pkt->dataDynamic(new uint8_t[fetchBufferSize]);
677

--- 31 unchanged lines hidden (view full) ---

709 finishTranslationEvent.setReq(mem_req);
710 cpu->schedule(finishTranslationEvent,
711 cpu->clockEdge(Cycles(1)));
712 return;
713 }
714 DPRINTF(Fetch, "[tid:%i] Got back req with addr %#x but expected %#x\n",
715 tid, mem_req->getVaddr(), memReq[tid]->getVaddr());
716 // Translation faulted, icache request won't be sent.
717 memReq[tid] = NULL;
718
719 // Send the fault to commit. This thread will not do anything
720 // until commit handles the fault. The only other way it can
721 // wake up is if a squash comes along and changes the PC.
722 TheISA::PCState fetchPC = pc[tid];
723
724 DPRINTF(Fetch, "[tid:%i]: Translation faulted, building noop.\n", tid);

--- 44 unchanged lines hidden (view full) ---

769 tid);
770 memReq[tid] = NULL;
771 }
772
773 // Get rid of the retrying packet if it was from this thread.
774 if (retryTid == tid) {
775 assert(cacheBlocked);
776 if (retryPkt) {
777 delete retryPkt;
778 }
779 retryPkt = NULL;
780 retryTid = InvalidThreadID;
781 }
782
783 fetchStatus[tid] = Squashing;
784

--- 892 unchanged lines hidden ---