base.hh (12724:4f6fac3191d2) base.hh (12728:57bdea4f96aa)
1/*
2 * Copyright (c) 2012-2013, 2015-2016, 2018 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

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

1103 assert(pkt->req->masterId() < system->maxMasters());
1104 hits[pkt->cmdToIndex()][pkt->req->masterId()]++;
1105
1106 }
1107
1108 /**
1109 * Cache block visitor that writes back dirty cache blocks using
1110 * functional writes.
1/*
2 * Copyright (c) 2012-2013, 2015-2016, 2018 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

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

1103 assert(pkt->req->masterId() < system->maxMasters());
1104 hits[pkt->cmdToIndex()][pkt->req->masterId()]++;
1105
1106 }
1107
1108 /**
1109 * Cache block visitor that writes back dirty cache blocks using
1110 * functional writes.
1111 *
1112 * @return Always returns true.
1113 */
1111 */
1114 bool writebackVisitor(CacheBlk &blk);
1112 void writebackVisitor(CacheBlk &blk);
1115
1116 /**
1117 * Cache block visitor that invalidates all blocks in the cache.
1118 *
1119 * @warn Dirty cache lines will not be written back to memory.
1113
1114 /**
1115 * Cache block visitor that invalidates all blocks in the cache.
1116 *
1117 * @warn Dirty cache lines will not be written back to memory.
1120 *
1121 * @return Always returns true.
1122 */
1118 */
1123 bool invalidateVisitor(CacheBlk &blk);
1119 void invalidateVisitor(CacheBlk &blk);
1124
1125 /**
1126 * Take an MSHR, turn it into a suitable downstream packet, and
1127 * send it out. This construct allows a queue entry to choose a suitable
1128 * approach based on its type.
1129 *
1130 * @param mshr The MSHR to turn into a packet and send
1131 * @return True if the port is waiting for a retry

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

1147 *
1148 * We currently don't support checkpointing cache state, so this panics.
1149 */
1150 void serialize(CheckpointOut &cp) const override;
1151 void unserialize(CheckpointIn &cp) override;
1152
1153};
1154
1120
1121 /**
1122 * Take an MSHR, turn it into a suitable downstream packet, and
1123 * send it out. This construct allows a queue entry to choose a suitable
1124 * approach based on its type.
1125 *
1126 * @param mshr The MSHR to turn into a packet and send
1127 * @return True if the port is waiting for a retry

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

1143 *
1144 * We currently don't support checkpointing cache state, so this panics.
1145 */
1146 void serialize(CheckpointOut &cp) const override;
1147 void unserialize(CheckpointIn &cp) override;
1148
1149};
1150
1155/**
1156 * Wrap a method and present it as a cache block visitor.
1157 *
1158 * For example the forEachBlk method in the tag arrays expects a
1159 * callable object/function as their parameter. This class wraps a
1160 * method in an object and presents callable object that adheres to
1161 * the cache block visitor protocol.
1162 */
1163class CacheBlkVisitorWrapper : public CacheBlkVisitor
1164{
1165 public:
1166 typedef bool (BaseCache::*VisitorPtr)(CacheBlk &blk);
1167
1168 CacheBlkVisitorWrapper(BaseCache &_cache, VisitorPtr _visitor)
1169 : cache(_cache), visitor(_visitor) {}
1170
1171 bool operator()(CacheBlk &blk) override {
1172 return (cache.*visitor)(blk);
1173 }
1174
1175 private:
1176 BaseCache &cache;
1177 VisitorPtr visitor;
1178};
1179
1180/**
1181 * Cache block visitor that determines if there are dirty blocks in a
1182 * cache.
1183 *
1184 * Use with the forEachBlk method in the tag array to determine if the
1185 * array contains dirty blocks.
1186 */
1187class CacheBlkIsDirtyVisitor : public CacheBlkVisitor
1188{
1189 public:
1190 CacheBlkIsDirtyVisitor()
1191 : _isDirty(false) {}
1192
1193 bool operator()(CacheBlk &blk) override {
1194 if (blk.isDirty()) {
1195 _isDirty = true;
1196 return false;
1197 } else {
1198 return true;
1199 }
1200 }
1201
1202 /**
1203 * Does the array contain a dirty line?
1204 *
1205 * @return true if yes, false otherwise.
1206 */
1207 bool isDirty() const { return _isDirty; };
1208
1209 private:
1210 bool _isDirty;
1211};
1212
1213#endif //__MEM_CACHE_BASE_HH__
1151#endif //__MEM_CACHE_BASE_HH__