53 #ifndef __MEM_PACKET_HH__ 54 #define __MEM_PACKET_HH__ 265 COPY_FLAGS = 0x0000003F,
268 RESPONDER_FLAGS = 0x00000009,
272 HAS_SHARERS = 0x00000001,
276 EXPRESS_SNOOP = 0x00000002,
281 RESPONDER_HAD_WRITABLE = 0x00000004,
285 CACHE_RESPONDING = 0x00000008,
289 WRITE_THROUGH = 0x00000010,
293 SATISFIED = 0x00000020,
296 VALID_ADDR = 0x00000100,
297 VALID_SIZE = 0x00000200,
301 STATIC_DATA = 0x00001000,
305 DYNAMIC_DATA = 0x00002000,
309 SUPPRESS_FUNC_ERROR = 0x00008000,
313 BLOCK_CACHED = 0x00010000
443 const std::string &
curPrefix() {
return *curPrefixPtr; }
450 void pushLabel(
const std::string &lbl,
451 const std::string &prefix =
" ");
509 template <
typename T>
514 while (t == NULL && sender_state != NULL) {
515 t =
dynamic_cast<T*
>(sender_state);
562 getOffset(blk_size) == 0 && getSize() == blk_size;
588 assert(!flags.
isSet(CACHE_RESPONDING));
589 flags.
set(CACHE_RESPONDING);
647 assert(cacheResponding());
648 assert(!responderHadWritable());
649 flags.
set(RESPONDER_HAD_WRITABLE);
652 {
return flags.
isSet(RESPONDER_HAD_WRITABLE); }
661 void copyResponderFlags(
const PacketPtr pkt);
671 flags.
set(WRITE_THROUGH);
684 assert(!flags.
isSet(SATISFIED));
685 flags.
set(SATISFIED);
701 inline uint8_t
qosValue()
const {
return _qosValue; }
710 { _qosValue = qos_value; }
736 unsigned getSize()
const { assert(flags.
isSet(VALID_SIZE));
return size; }
747 return getAddr() &
Addr(blk_size - 1);
752 return getAddr() & ~(
Addr(blk_size - 1));
757 assert(flags.
isSet(VALID_ADDR));
797 : cmd(_cmd), id((
PacketId)_req.get()), req(_req),
798 data(nullptr), addr(0), _isSecure(false), size(0),
799 _qosValue(0), headerDelay(0), snoopDelay(0),
800 payloadDelay(0), senderState(NULL)
802 if (req->hasPaddr()) {
803 addr = req->getPaddr();
804 flags.
set(VALID_ADDR);
805 _isSecure = req->isSecure();
807 if (req->hasSize()) {
808 size = req->getSize();
809 flags.
set(VALID_SIZE);
819 : cmd(_cmd), id(_id ? _id : (
PacketId)_req.get()), req(_req),
820 data(nullptr), addr(0), _isSecure(false),
821 _qosValue(0), headerDelay(0),
822 snoopDelay(0), payloadDelay(0), senderState(NULL)
824 if (req->hasPaddr()) {
825 addr = req->getPaddr() & ~(_blkSize - 1);
826 flags.
set(VALID_ADDR);
827 _isSecure = req->isSecure();
830 flags.
set(VALID_SIZE);
841 : cmd(pkt->cmd), id(pkt->id), req(pkt->req),
843 addr(pkt->addr), _isSecure(pkt->_isSecure), size(pkt->size),
844 bytesValid(pkt->bytesValid),
845 _qosValue(pkt->qosValue()),
846 headerDelay(pkt->headerDelay),
848 payloadDelay(pkt->payloadDelay),
849 senderState(pkt->senderState)
854 flags.
set(pkt->
flags & (VALID_ADDR|VALID_SIZE));
866 flags.
set(STATIC_DATA);
881 else if (req->isPrefetchEx())
883 else if (req->isPrefetch())
897 else if (req->isSwap() || req->isAtomic())
899 else if (req->isCacheInvalidate()) {
902 }
else if (req->isCacheClean()) {
915 return new Packet(req, makeReadCmd(req));
921 return new Packet(req, makeWriteCmd(req));
945 flags.
clear(EXPRESS_SNOOP);
975 assert(!flags.
isSet(VALID_SIZE));
978 flags.
set(VALID_SIZE);
990 bool matchBlockAddr(
const Addr addr,
const bool is_secure,
991 const int blk_size)
const;
1001 bool matchBlockAddr(
const PacketPtr pkt,
const int blk_size)
const;
1010 bool matchAddr(
const Addr addr,
const bool is_secure)
const;
1019 bool matchAddr(
const PacketPtr pkt)
const;
1038 template <
typename T>
1042 assert(flags.
noneSet(STATIC_DATA|DYNAMIC_DATA));
1044 flags.
set(STATIC_DATA);
1055 template <
typename T>
1059 assert(flags.
noneSet(STATIC_DATA|DYNAMIC_DATA));
1061 flags.
set(STATIC_DATA);
1076 template <
typename T>
1080 assert(flags.
noneSet(STATIC_DATA|DYNAMIC_DATA));
1082 flags.
set(DYNAMIC_DATA);
1088 template <
typename T>
1092 assert(flags.
isSet(STATIC_DATA|DYNAMIC_DATA));
1093 assert(!isMaskedWrite());
1097 template <
typename T>
1101 assert(flags.
isSet(STATIC_DATA|DYNAMIC_DATA));
1102 return (
const T*)
data;
1109 template <
typename T>
1116 template <
typename T>
1123 template <
typename T>
1127 template <
typename T>
1131 template <
typename T>
1138 template <
typename T>
1145 uint64_t getUintX(
ByteOrder endian)
const;
1163 assert(p != getPtr<uint8_t>() || flags.
isSet(STATIC_DATA));
1165 if (p != getPtr<uint8_t>()) {
1168 std::memcpy(getPtr<uint8_t>(), p, getSize());
1189 if (!isMaskedWrite()) {
1190 std::memcpy(p, getConstPtr<uint8_t>(), getSize());
1192 assert(req->getByteEnable().size() == getSize());
1194 const uint8_t *
base = getConstPtr<uint8_t>();
1195 for (
int i = 0;
i < getSize();
i++) {
1196 if (req->getByteEnable()[
i]) {
1213 writeData(blk_data +
getOffset(blkSize));
1223 if (flags.
isSet(DYNAMIC_DATA))
1226 flags.
clear(STATIC_DATA|DYNAMIC_DATA);
1236 if (
hasData() || hasRespData()) {
1237 assert(flags.
noneSet(STATIC_DATA|DYNAMIC_DATA));
1238 flags.
set(DYNAMIC_DATA);
1239 data =
new uint8_t[getSize()];
1246 template <
typename T>
1250 template <
typename T>
1268 if (_isSecure == other->
isSecure() &&
1270 other->
getAddr() <= (getAddr() + getSize() - 1)) {
1271 warn(
"Trying to check against a masked write, skipping." 1272 " (addr: 0x%x, other addr: 0x%x)", getAddr(),
1279 return trySatisfyFunctional(other, other->
getAddr(), other->
isSecure(),
1282 other->
getPtr<uint8_t>() : NULL);
1342 void print(std::ostream &o,
int verbosity = 0,
1343 const std::string &prefix =
"")
const;
1351 std::string print()
const;
1354 #endif //__MEM_PACKET_HH Alpha/MIPS LL or SC access.
Requires writable copy to complete in-cache.
std::vector< bool > bytesValid
Track the bytes found that satisfy a functional read.
void setResponderHadWritable()
On responding to a snoop request (which only happens for Modified or Owned lines), make sure that we can transform an Owned response to a Modified one.
bool isExpressSnoop() const
void setSize(unsigned size)
bool suppressFuncError() const
void setHasSharers()
On fills, the hasSharers flag is used by the caches in combination with the cacheResponding flag...
bool mustCheckAbove() const
Does the request need to check for cached copies of the same block in the memory hierarchy above...
Data flows from requester to responder.
T * findNextSenderState() const
Go through the sender state stack and return the first instance that is of type T (as determined by a...
There is an associated payload.
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
bool testCmdAttrib(MemCmd::Attribute attrib) const
void setSuppressFuncError()
void qosValue(const uint8_t qos_value)
QoS Value setter Interface for setting QoS priority value of the packet.
Object used to maintain state of a PrintReq.
uint32_t snoopDelay
Keep track of the extra delay incurred by snooping upwards before sending a request down the memory s...
void makeTimingResponse()
Flush the address from caches.
bool isCleanEviction() const
Is this packet a clean eviction, including both actual clean evict packets, but also clean writebacks...
const std::string & toString() const
Return the string to a cmd given by idx.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
std::shared_ptr< Request > RequestPtr
::Flags< FlagsType > Flags
bool isSWPrefetch() const
static PacketPtr createWrite(const RequestPtr &req)
bool cacheResponding() const
Requester needs response from target.
Packet(const RequestPtr &_req, MemCmd _cmd, int _blkSize, PacketId _id=0)
Alternate constructor if you are trying to create a packet with a request that is for a whole block...
Cleans any existing dirty blocks.
static const CommandInfo commandInfo[]
Array to map Command enum to associated info.
const std::string & curPrefix()
Returns the current line prefix.
static MemCmd makeReadCmd(const RequestPtr &req)
Generate the appropriate read MemCmd based on the Request flags.
void pushLabel(const std::string &lbl)
Push label for PrintReq (safe to call unconditionally).
bool isInvalidate() const
T * getPtr()
get a pointer to the data ptr.
void setSatisfied()
Set when a request hits in a cache and the cache is not going to respond.
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
bool needsWritable() const
Addr getBlockAddr(unsigned int blk_size) const
RequestPtr req
A pointer to the original request.
bool isBlockCached() const
void setFunctionalResponseStatus(bool success)
Structure that defines attributes and other data associated with a Command.
PacketDataPtr data
A pointer to the data being transferred.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
An entry in the label stack.
unsigned size
The size of the request or transfer.
bool isWriteback() const
A writeback is an eviction that carries data.
void convertScToWrite()
It has been determined that the SC packet should successfully update memory.
bool needsResponse() const
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
Addr getOffset(unsigned int blk_size) const
SenderState * predecessor
Attribute
List of command attributes.
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
void makeAtomicResponse()
uint8_t qosValue() const
QoS Value getter Returns 0 if QoS value was never set (constructor default).
void deleteData()
delete the data pointed to in the data pointer.
bool trySatisfyFunctional(PacketPtr other)
Check a functional request against a memory value stored in another packet (i.e.
void popLabel()
Pop label for PrintReq (safe to call unconditionally).
bool needsWritable() const
bool writeThrough() const
bool isHWPrefetch() const
void dataStaticConst(const T *p)
Set the data pointer to the following value that should not be freed.
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
MasterID masterId() const
Addr getOffset(Addr addr)
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
bool _isSecure
True if the request targets the secure memory space.
Addr addr
The address of the request.
friend class Packet
Packet probe point.
void convertLlToRead()
When ruby is in use, Ruby will monitor the cache line and the phys memory should treat LL ops as norm...
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
static PacketPtr createRead(const RequestPtr &req)
Constructor-like methods that return Packets based on Request objects.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
const std::bitset< NUM_COMMAND_ATTRIBUTES > attributes
Set of attribute flags.
Print state matching address (for debugging)
std::string * curPrefixPtr
Abstract base class for objects which support being printed to a stream for debugging.
void setDataFromBlock(const uint8_t *blk_data, int blkSize)
Copy data into the packet from the provided block pointer, which is aligned to the given block size...
bool responderHadWritable() const
A virtual base opaque structure used to hold state associated with the packet (e.g., an MSHR), specific to a SimObject that sees the packet.
static MemCmd makeWriteCmd(const RequestPtr &req)
Generate the appropriate write MemCmd based on the Request flags.
Command responseCommand() const
int cmdToIndex() const
Return the index of this command.
bool isMaskedWrite() const
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
void setAddr(Addr _addr)
Update the address of this packet mid-transaction.
Packet(const RequestPtr &_req, MemCmd _cmd)
Constructor.
~Packet()
clean up packet variables
Data flows from responder to requester.
bool needsResponse() const
const Command response
Corresponding response for requests; InvalidCmd if no response is applicable.
bool hasData() const
Check if this particular packet type carries payload data.
SenderState * senderState
This packet's sender state.
MemCmd cmd
The command field of the packet.
void writeDataToBlock(uint8_t *blk_data, int blkSize) const
Copy data from the packet to the provided block pointer, which is aligned to the given block size...
std::list< PacketPtr > PacketList
bool operator==(MemCmd c2) const
const T * getConstPtr() const
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
Request originated from a caching agent.
void copyError(Packet *pkt)
void setExpressSnoop()
The express snoop flag is used for two purposes.
Command
List of all commands associated with a packet.
bool isWholeLineWrite(unsigned blk_size)
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
Packet(const PacketPtr pkt, bool clear_flags, bool alloc_data)
Alternate constructor for copying a packet.
const std::string str
String representation (for printing)
bool isInvalidate() const
std::list< LabelStackEntry > LabelStack
bool operator!=(MemCmd c2) const
void allocate()
Allocate memory for the packet.
void setCacheResponding()
Snoop flags.
void setWriteThrough()
A writeback/writeclean cmd gets propagated further downstream by the receiver when the flag is set...