#include "base/cprintf.hh"
+void
+CacheBlk::insert(const Addr tag, const State is_secure,
+ const int src_master_ID, const uint32_t task_ID)
+{
+ // Touch block
+ isTouched = true;
+
+ // Set block tag
+ this->tag = tag;
+
+ // Set source requestor ID
+ srcMasterId = src_master_ID;
+
+ // Set task ID
+ task_id = task_ID;
+
+ // Set insertion tick as current tick
+ tickInserted = curTick();
+
+ // Insertion counts as a reference to the block
+ refCount = 1;
+
+ // Set secure state
+ if (is_secure) {
+ status = BlkSecure;
+ } else {
+ status = 0;
+ }
+}
+
void
CacheBlkPrintWrapper::print(std::ostream &os, int verbosity,
const std::string &prefix) const
return (status & BlkSecure) != 0;
}
+ /**
+ * Set member variables when a block insertion occurs. Resets reference
+ * count to 1 (the insertion counts as a reference), and touch block if
+ * it hadn't been touched previously. Sets the insertion tick to the
+ * current tick. Does not make block valid.
+ *
+ * @param tag Block address tag.
+ * @param is_secure Whether the block is in secure space or not.
+ * @param src_master_ID The source requestor ID.
+ * @param task_ID The new task ID.
+ */
+ void insert(const Addr tag, const State is_secure, const int src_master_ID,
+ const uint32_t task_ID);
+
/**
* Track the fact that a local locked was issued to the
* block. Invalidate any previous LL to the same address.
}
tags->insertBlock(pkt, blk);
- blk->status = (BlkValid | BlkReadable);
- if (pkt->isSecure()) {
- blk->status |= BlkSecure;
- }
+ blk->status |= (BlkValid | BlkReadable);
}
// only mark the block dirty if we got a writeback command,
// and leave it as is for a clean writeback
}
tags->insertBlock(pkt, blk);
- blk->status = (BlkValid | BlkReadable);
- if (pkt->isSecure()) {
- blk->status |= BlkSecure;
- }
+ blk->status |= (BlkValid | BlkReadable);
}
}
blk->invalidate();
}
- // Touch block
- blk->isTouched = true;
- blk->refCount = 1;
- blk->tickInserted = curTick();
-
// Previous block, if existed, has been removed, and now we have
// to insert the new one
tagsInUse++;
- // Set tag for new block. Caller is responsible for setting status.
- blk->tag = extractTag(addr);
-
// Deal with what we are bringing in
MasterID master_id = pkt->req->masterId();
assert(master_id < cache->system->maxMasters());
occupancies[master_id]++;
- blk->srcMasterId = master_id;
- // Set task id
- blk->task_id = pkt->req->taskId();
+ // Insert block with tag, src master id and task id
+ blk->insert(extractTag(addr), pkt->isSecure(), master_id,
+ pkt->req->taskId());
// We only need to write into one tag and one data block.
tagAccesses += 1;