packet.hh (13892:0182a0601f66) | packet.hh (13954:2f400a5f2627) |
---|---|
1/* 2 * Copyright (c) 2012-2019 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 --- 1078 unchanged lines hidden (view full) --- 1087 /** 1088 * get a pointer to the data ptr. 1089 */ 1090 template <typename T> 1091 T* 1092 getPtr() 1093 { 1094 assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)); | 1/* 2 * Copyright (c) 2012-2019 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 --- 1078 unchanged lines hidden (view full) --- 1087 /** 1088 * get a pointer to the data ptr. 1089 */ 1090 template <typename T> 1091 T* 1092 getPtr() 1093 { 1094 assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)); |
1095 assert(!isMaskedWrite()); |
|
1095 return (T*)data; 1096 } 1097 1098 template <typename T> 1099 const T* 1100 getConstPtr() const 1101 { 1102 assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)); --- 72 unchanged lines hidden (view full) --- 1175 void 1176 setData(const uint8_t *p) 1177 { 1178 // we should never be copying data onto itself, which means we 1179 // must idenfity packets with static data, as they carry the 1180 // same pointer from source to destination and back 1181 assert(p != getPtr<uint8_t>() || flags.isSet(STATIC_DATA)); 1182 | 1096 return (T*)data; 1097 } 1098 1099 template <typename T> 1100 const T* 1101 getConstPtr() const 1102 { 1103 assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)); --- 72 unchanged lines hidden (view full) --- 1176 void 1177 setData(const uint8_t *p) 1178 { 1179 // we should never be copying data onto itself, which means we 1180 // must idenfity packets with static data, as they carry the 1181 // same pointer from source to destination and back 1182 assert(p != getPtr<uint8_t>() || flags.isSet(STATIC_DATA)); 1183 |
1183 if (p != getPtr | 1184 if (p != getPtr<uint8_t>()) { |
1184 // for packet with allocated dynamic data, we copy data from 1185 // one to the other, e.g. a forwarded response to a response 1186 std::memcpy(getPtr<uint8_t>(), p, getSize()); | 1185 // for packet with allocated dynamic data, we copy data from 1186 // one to the other, e.g. a forwarded response to a response 1187 std::memcpy(getPtr<uint8_t>(), p, getSize()); |
1188 } |
|
1187 } 1188 1189 /** 1190 * Copy data into the packet from the provided block pointer, 1191 * which is aligned to the given block size. 1192 */ 1193 void 1194 setDataFromBlock(const uint8_t *blk_data, int blkSize) 1195 { 1196 setData(blk_data + getOffset(blkSize)); 1197 } 1198 1199 /** 1200 * Copy data from the packet to the memory at the provided pointer. 1201 * @param p Pointer to which data will be copied. 1202 */ 1203 void 1204 writeData(uint8_t *p) const 1205 { | 1189 } 1190 1191 /** 1192 * Copy data into the packet from the provided block pointer, 1193 * which is aligned to the given block size. 1194 */ 1195 void 1196 setDataFromBlock(const uint8_t *blk_data, int blkSize) 1197 { 1198 setData(blk_data + getOffset(blkSize)); 1199 } 1200 1201 /** 1202 * Copy data from the packet to the memory at the provided pointer. 1203 * @param p Pointer to which data will be copied. 1204 */ 1205 void 1206 writeData(uint8_t *p) const 1207 { |
1206 std::memcpy(p, getConstPtr<uint8_t>(), getSize()); | 1208 if (!isMaskedWrite()) { 1209 std::memcpy(p, getConstPtr<uint8_t>(), getSize()); 1210 } else { 1211 assert(req->getByteEnable().size() == getSize()); 1212 // Write only the enabled bytes 1213 const uint8_t *base = getConstPtr<uint8_t>(); 1214 for (int i = 0; i < getSize(); i++) { 1215 if (req->getByteEnable()[i]) { 1216 p[i] = *(base + i); 1217 } 1218 // Disabled bytes stay untouched 1219 } 1220 } |
1207 } 1208 1209 /** 1210 * Copy data from the packet to the provided block pointer, which 1211 * is aligned to the given block size. 1212 * @param blk_data Pointer to block to which data will be copied. 1213 * @param blkSize Block size in bytes. 1214 */ --- 48 unchanged lines hidden (view full) --- 1263 * the other packet provides the data, which is then copied to the 1264 * current packet. If the current packet is a write, and the other 1265 * packet intersects this one, then we update the data 1266 * accordingly. 1267 */ 1268 bool 1269 trySatisfyFunctional(PacketPtr other) 1270 { | 1221 } 1222 1223 /** 1224 * Copy data from the packet to the provided block pointer, which 1225 * is aligned to the given block size. 1226 * @param blk_data Pointer to block to which data will be copied. 1227 * @param blkSize Block size in bytes. 1228 */ --- 48 unchanged lines hidden (view full) --- 1277 * the other packet provides the data, which is then copied to the 1278 * current packet. If the current packet is a write, and the other 1279 * packet intersects this one, then we update the data 1280 * accordingly. 1281 */ 1282 bool 1283 trySatisfyFunctional(PacketPtr other) 1284 { |
1285 if (other->isMaskedWrite()) { 1286 // Do not forward data if overlapping with a masked write 1287 if (_isSecure == other->isSecure() && 1288 getAddr() <= (other->getAddr() + other->getSize() - 1) && 1289 other->getAddr() <= (getAddr() + getSize() - 1)) { 1290 warn("Trying to check against a masked write, skipping." 1291 " (addr: 0x%x, other addr: 0x%x)", getAddr(), 1292 other->getAddr()); 1293 } 1294 return false; 1295 } |
|
1271 // all packets that are carrying a payload should have a valid 1272 // data pointer 1273 return trySatisfyFunctional(other, other->getAddr(), other->isSecure(), 1274 other->getSize(), 1275 other->hasData() ? 1276 other->getPtr<uint8_t>() : NULL); 1277 } 1278 --- 12 unchanged lines hidden (view full) --- 1291 * evict packets, but also clean writebacks. 1292 */ 1293 bool 1294 isCleanEviction() const 1295 { 1296 return cmd == MemCmd::CleanEvict || cmd == MemCmd::WritebackClean; 1297 } 1298 | 1296 // all packets that are carrying a payload should have a valid 1297 // data pointer 1298 return trySatisfyFunctional(other, other->getAddr(), other->isSecure(), 1299 other->getSize(), 1300 other->hasData() ? 1301 other->getPtr<uint8_t>() : NULL); 1302 } 1303 --- 12 unchanged lines hidden (view full) --- 1316 * evict packets, but also clean writebacks. 1317 */ 1318 bool 1319 isCleanEviction() const 1320 { 1321 return cmd == MemCmd::CleanEvict || cmd == MemCmd::WritebackClean; 1322 } 1323 |
1324 bool 1325 isMaskedWrite() const 1326 { 1327 return (cmd == MemCmd::WriteReq && !req->getByteEnable().empty()); 1328 } 1329 |
|
1299 /** 1300 * Check a functional request against a memory value represented 1301 * by a base/size pair and an associated data array. If the 1302 * current packet is a read, it may be satisfied by the memory 1303 * value. If the current packet is a write, it may update the 1304 * memory value. 1305 */ 1306 bool --- 36 unchanged lines hidden --- | 1330 /** 1331 * Check a functional request against a memory value represented 1332 * by a base/size pair and an associated data array. If the 1333 * current packet is a read, it may be satisfied by the memory 1334 * value. If the current packet is a write, it may update the 1335 * memory value. 1336 */ 1337 bool --- 36 unchanged lines hidden --- |