cache.cc (12345:70c783a93195) | cache.cc (12346:9b1144d046ca) |
---|---|
1/* 2 * Copyright (c) 2010-2016 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 416 unchanged lines hidden (view full) --- 425 } else if (pkt->cmd == MemCmd::WriteClean) { 426 // WriteClean handling is a special case. We can allocate a 427 // block directly if it doesn't exist and we can update the 428 // block immediately. The WriteClean transfers the ownership 429 // of the block as well. 430 assert(blkSize == pkt->getSize()); 431 432 if (!blk) { | 1/* 2 * Copyright (c) 2010-2016 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 416 unchanged lines hidden (view full) --- 425 } else if (pkt->cmd == MemCmd::WriteClean) { 426 // WriteClean handling is a special case. We can allocate a 427 // block directly if it doesn't exist and we can update the 428 // block immediately. The WriteClean transfers the ownership 429 // of the block as well. 430 assert(blkSize == pkt->getSize()); 431 432 if (!blk) { |
433 // a writeback that misses needs to allocate a new block 434 blk = allocateBlock(pkt->getAddr(), pkt->isSecure(), 435 writebacks); 436 if (!blk) { 437 // no replaceable block available: give up, fwd to 438 // next level. 439 incMissCount(pkt); | 433 if (pkt->writeThrough()) { 434 // if this is a write through packet, we don't try to 435 // allocate if the block is not present |
440 return false; | 436 return false; |
441 } 442 tags->insertBlock(pkt, blk); | 437 } else { 438 // a writeback that misses needs to allocate a new block 439 blk = allocateBlock(pkt->getAddr(), pkt->isSecure(), 440 writebacks); 441 if (!blk) { 442 // no replaceable block available: give up, fwd to 443 // next level. 444 incMissCount(pkt); 445 return false; 446 } 447 tags->insertBlock(pkt, blk); |
443 | 448 |
444 blk->status = (BlkValid | BlkReadable); 445 if (pkt->isSecure()) { 446 blk->status |= BlkSecure; | 449 blk->status = (BlkValid | BlkReadable); 450 if (pkt->isSecure()) { 451 blk->status |= BlkSecure; 452 } |
447 } 448 } 449 450 // at this point either this is a writeback or a write-through 451 // write clean operation and the block is already in this 452 // cache, we need to update the data and the block flags 453 assert(blk); | 453 } 454 } 455 456 // at this point either this is a writeback or a write-through 457 // write clean operation and the block is already in this 458 // cache, we need to update the data and the block flags 459 assert(blk); |
454 blk->status |= BlkDirty; | 460 if (!pkt->writeThrough()) { 461 blk->status |= BlkDirty; 462 } |
455 // nothing else to do; writeback doesn't expect response 456 assert(!pkt->needsResponse()); 457 std::memcpy(blk->data, pkt->getConstPtr<uint8_t>(), blkSize); 458 DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print()); 459 460 incHitCount(pkt); 461 // populate the time when the block will be ready to access. 462 blk->whenReady = clockEdge(fillLatency) + pkt->headerDelay + 463 pkt->payloadDelay; | 463 // nothing else to do; writeback doesn't expect response 464 assert(!pkt->needsResponse()); 465 std::memcpy(blk->data, pkt->getConstPtr<uint8_t>(), blkSize); 466 DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print()); 467 468 incHitCount(pkt); 469 // populate the time when the block will be ready to access. 470 blk->whenReady = clockEdge(fillLatency) + pkt->headerDelay + 471 pkt->payloadDelay; |
464 return true; | 472 // if this a write-through packet it will be sent to cache 473 // below 474 return !pkt->writeThrough(); |
465 } else if (blk && (pkt->needsWritable() ? blk->isWritable() : 466 blk->isReadable())) { 467 // OK to satisfy access 468 incHitCount(pkt); 469 satisfyRequest(pkt, blk); 470 maintainClusivity(pkt->fromCache(), blk); 471 472 return true; --- 1145 unchanged lines hidden (view full) --- 1618 1619 pkt->allocate(); 1620 std::memcpy(pkt->getPtr<uint8_t>(), blk->data, blkSize); 1621 1622 return pkt; 1623} 1624 1625PacketPtr | 475 } else if (blk && (pkt->needsWritable() ? blk->isWritable() : 476 blk->isReadable())) { 477 // OK to satisfy access 478 incHitCount(pkt); 479 satisfyRequest(pkt, blk); 480 maintainClusivity(pkt->fromCache(), blk); 481 482 return true; --- 1145 unchanged lines hidden (view full) --- 1628 1629 pkt->allocate(); 1630 std::memcpy(pkt->getPtr<uint8_t>(), blk->data, blkSize); 1631 1632 return pkt; 1633} 1634 1635PacketPtr |
1626Cache::writecleanBlk(CacheBlk *blk) | 1636Cache::writecleanBlk(CacheBlk *blk, Request::Flags dest) |
1627{ 1628 Request *req = new Request(tags->regenerateBlkAddr(blk->tag, blk->set), 1629 blkSize, 0, Request::wbMasterId); 1630 if (blk->isSecure()) { 1631 req->setFlags(Request::SECURE); 1632 } 1633 req->taskId(blk->task_id); 1634 blk->task_id = ContextSwitchTaskId::Unknown; 1635 PacketPtr pkt = new Packet(req, MemCmd::WriteClean); 1636 DPRINTF(Cache, "Create %s writable: %d, dirty: %d\n", pkt->print(), 1637 blk->isWritable(), blk->isDirty()); 1638 // make sure the block is not marked dirty 1639 blk->status &= ~BlkDirty; 1640 pkt->allocate(); 1641 // We inform the cache below that the block has sharers in the 1642 // system as we retain our copy. 1643 pkt->setHasSharers(); | 1637{ 1638 Request *req = new Request(tags->regenerateBlkAddr(blk->tag, blk->set), 1639 blkSize, 0, Request::wbMasterId); 1640 if (blk->isSecure()) { 1641 req->setFlags(Request::SECURE); 1642 } 1643 req->taskId(blk->task_id); 1644 blk->task_id = ContextSwitchTaskId::Unknown; 1645 PacketPtr pkt = new Packet(req, MemCmd::WriteClean); 1646 DPRINTF(Cache, "Create %s writable: %d, dirty: %d\n", pkt->print(), 1647 blk->isWritable(), blk->isDirty()); 1648 // make sure the block is not marked dirty 1649 blk->status &= ~BlkDirty; 1650 pkt->allocate(); 1651 // We inform the cache below that the block has sharers in the 1652 // system as we retain our copy. 1653 pkt->setHasSharers(); |
1654 if (dest) { 1655 req->setFlags(dest); 1656 pkt->setWriteThrough(); 1657 } |
|
1644 std::memcpy(pkt->getPtr<uint8_t>(), blk->data, blkSize); 1645 return pkt; 1646} 1647 1648 1649PacketPtr 1650Cache::cleanEvictBlk(CacheBlk *blk) 1651{ --- 1098 unchanged lines hidden --- | 1658 std::memcpy(pkt->getPtr<uint8_t>(), blk->data, blkSize); 1659 return pkt; 1660} 1661 1662 1663PacketPtr 1664Cache::cleanEvictBlk(CacheBlk *blk) 1665{ --- 1098 unchanged lines hidden --- |