47 #ifndef __MEM_PACKET_HH__
48 #define __MEM_PACKET_HH__
52 #include <initializer_list>
182 static constexpr
unsigned long long
185 unsigned long long ret = 0;
186 for (
const auto &
attr: attrs)
187 ret |= (1ULL <<
attr);
206 Command _response,
const std::string &_str) :
515 const std::string &prefix =
" ");
573 template <
typename T>
578 while (
t == NULL && sender_state != NULL) {
579 t =
dynamic_cast<T*
>(sender_state);
885 if (
req->hasPaddr()) {
901 if (
req->isHTMCmd()) {
905 if (
req->hasSize()) {
926 if (
req->hasPaddr()) {
927 addr =
req->getPaddr() & ~(_blkSize - 1);
992 if (
req->isHTMCmd()) {
993 if (
req->isHTMAbort())
997 }
else if (
req->isLLSC())
999 else if (
req->isPrefetchEx())
1001 else if (
req->isPrefetch())
1003 else if (
req->isLockedRMW())
1017 else if (
req->isSwap() ||
req->isAtomic())
1019 else if (
req->isCacheInvalidate()) {
1022 }
else if (
req->isCacheClean()) {
1024 }
else if (
req->isLockedRMW()) {
1113 const int blk_size)
const;
1160 template <
typename T>
1177 template <
typename T>
1198 template <
typename T>
1210 template <
typename T>
1219 template <
typename T>
1224 return (
const T*)
data;
1231 template <
typename T>
1238 template <
typename T>
1245 template <
typename T>
1246 T
get(ByteOrder endian)
const;
1249 template <
typename T>
1253 template <
typename T>
1260 template <
typename T>
1261 void set(T
v, ByteOrder endian);
1267 uint64_t
getUintX(ByteOrder endian)
const;
1274 void setUintX(uint64_t
w, ByteOrder endian);
1287 if (
p != getPtr<uint8_t>()) {
1290 std::memcpy(getPtr<uint8_t>(),
p,
getSize());
1312 std::memcpy(
p, getConstPtr<uint8_t>(),
getSize());
1314 assert(
req->getByteEnable().size() ==
getSize());
1316 const uint8_t *
base = getConstPtr<uint8_t>();
1317 for (
unsigned int i = 0;
i <
getSize();
i++) {
1318 if (
req->getByteEnable()[
i]) {
1368 template <
typename T>
1372 template <
typename T>
1393 warn(
"Trying to check against a masked write, skipping."
1394 " (addr: 0x%x, other addr: 0x%x)",
getAddr(),
1404 other->
getPtr<uint8_t>() : NULL);
1451 safe_cast<PrintReqState*>(
senderState)->pushLabel(lbl);
1461 safe_cast<PrintReqState*>(
senderState)->popLabel();
1464 void print(std::ostream &
o,
int verbosity = 0,
1465 const std::string &prefix =
"")
const;
1473 std::string
print()
const;
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
bool isSWPrefetch() const
bool isInvalidate() const
const std::string & toString() const
Return the string to a cmd given by idx.
static constexpr unsigned long long buildAttributes(std::initializer_list< Attribute > attrs)
bool operator==(MemCmd c2) const
bool isWriteback() const
A writeback is an eviction that carries data.
static const CommandInfo commandInfo[]
Array to map Command enum to associated info.
bool isHWPrefetch() const
Command
List of all commands associated with a packet.
bool operator!=(MemCmd c2) const
bool needsResponse() const
bool testCmdAttrib(MemCmd::Attribute attrib) const
Command responseCommand() const
bool hasData() const
Check if this particular packet type carries payload data.
bool needsWritable() const
Attribute
List of command attributes.
@ IsLockedRMW
x86 locked RMW access
@ NeedsResponse
Requester needs response from target.
@ IsRead
Data flows from responder to requester.
@ NeedsWritable
Requires writable copy to complete in-cache.
@ IsFlush
Flush the address from caches.
@ FromCache
Request originated from a caching agent.
@ IsClean
Cleans any existing dirty blocks.
@ IsWrite
Data flows from requester to responder.
@ IsPrint
Print state matching address (for debugging)
@ HasData
There is an associated payload.
@ IsLlsc
Alpha/MIPS LL or SC access.
@ IsResponse
Issue by responder.
@ IsRequest
Issued by requester.
Object used to maintain state of a PrintReq.
void popLabel()
Pop a label off the label stack.
void printObj(Printable *obj)
Print a Printable object to os, because it matched the address on a PrintReq.
PrintReqState(std::ostream &os, int verbosity=0)
void pushLabel(const std::string &lbl, const std::string &prefix=" ")
Push a label onto the label stack, and prepend the given prefix string onto the current prefix.
std::list< LabelStackEntry > LabelStack
const std::string & curPrefix()
Returns the current line prefix.
std::string * curPrefixPtr
void printLabels()
Print all of the pending unprinted labels on the stack.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setExpressSnoop()
The express snoop flag is used for two purposes.
bool responderHadWritable() const
T * getPtr()
get a pointer to the data ptr.
Addr addr
The address of the request.
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.
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
void pushLabel(const std::string &lbl)
Push label for PrintReq (safe to call unconditionally).
void setUintX(uint64_t w, ByteOrder endian)
Set the value in the word w after truncating it to the length of the packet and then byteswapping it ...
void deleteData()
delete the data pointed to in the data pointer.
void setLE(T v)
Set the value in the data pointer to v as little endian.
std::vector< bool > bytesValid
Track the bytes found that satisfy a functional read.
Packet(const PacketPtr pkt, bool clear_flags, bool alloc_data)
Alternate constructor for copying a packet.
void setWriteThrough()
A writeback/writeclean cmd gets propagated further downstream by the receiver when the flag is set.
gem5::Flags< FlagsType > Flags
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,...
void setBE(T v)
Set the value in the data pointer to v as big endian.
uint32_t snoopDelay
Keep track of the extra delay incurred by snooping upwards before sending a request down the memory s...
void setHtmTransactionFailedInCache(const HtmCacheFailure ret_code)
Stipulates that this packet/request has returned from the cache hierarchy in a failed transaction.
void makeTimingResponse()
bool needsWritable() const
T getBE() const
Get the data in the packet byte swapped from big endian to host endian.
AddrRange getAddrRange() const
Get address range to which this packet belongs.
void copyError(Packet *pkt)
void setAddr(Addr _addr)
Update the address of this packet mid-transaction.
static PacketPtr createWrite(const RequestPtr &req)
bool isCleanEviction() const
Is this packet a clean eviction, including both actual clean evict packets, but also clean writebacks...
bool needsResponse() const
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
@ VALID_ADDR
Are the 'addr' and 'size' fields valid?
@ SUPPRESS_FUNC_ERROR
suppress the error if this packet encounters a functional access failure.
@ DYNAMIC_DATA
The data pointer points to a value that should be freed when the packet is destroyed.
@ EXPRESS_SNOOP
Special timing-mode atomic snoop for multi-level coherence.
@ STATIC_DATA
Is the data pointer set to a value that shouldn't be freed when the packet is destroyed?
@ RESPONDER_HAD_WRITABLE
Allow a responding cache to inform the cache hierarchy that it had a writable copy before responding.
SenderState * senderState
This packet's sender state.
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
bool matchAddr(const Addr addr, const bool is_secure) const
Check if packet corresponds to a given address and address space.
RequestorID requestorId() const
static MemCmd makeWriteCmd(const RequestPtr &req)
Generate the appropriate write MemCmd based on the Request flags.
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
int cmdToIndex() const
Return the index of this command.
void setResponderHadWritable()
On responding to a snoop request (which only happens for Modified or Owned lines),...
Addr getOffset(unsigned int blk_size) const
~Packet()
clean up packet variables
T * findNextSenderState() const
Go through the sender state stack and return the first instance that is of type T (as determined by a...
bool mustCheckAbove() const
Does the request need to check for cached copies of the same block in the memory hierarchy above.
void pushSenderState(SenderState *sender_state)
Push a new sender state to the packet and make the current sender state the predecessor of the new on...
void setRaw(T v)
Set the value in the data pointer to v without byte swapping.
uint8_t qosValue() const
QoS Value getter Returns 0 if QoS value was never set (constructor default).
void copyResponderFlags(const PacketPtr pkt)
Copy the reponse flags from an input packet to this packet.
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
bool writeThrough() const
HtmCacheFailure getHtmTransactionFailedInCacheRC() const
If a packet/request has returned from the cache hierarchy in a failed transaction,...
bool isHtmTransactional() const
Returns whether or not this packet/request originates in the CPU executing in transactional mode,...
std::string print() const
A no-args wrapper of print(std::ostream...) meant to be invoked from DPRINTFs avoiding string overhea...
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
void convertScToWrite()
It has been determined that the SC packet should successfully update memory.
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 trySatisfyFunctional(PacketPtr other)
Check a functional request against a memory value stored in another packet (i.e.
uint64_t getHtmTransactionUid() const
If a packet/request originates in a CPU executing in transactional mode, i.e.
Addr getBlockAddr(unsigned int blk_size) const
void set(T v, ByteOrder endian)
Set the value in the data pointer to v using the specified endianness.
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
static PacketPtr createRead(const RequestPtr &req)
Constructor-like methods that return Packets based on Request objects.
RequestPtr req
A pointer to the original request.
unsigned size
The size of the request or transfer.
void setCacheResponding()
Snoop flags.
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
void popLabel()
Pop label for PrintReq (safe to call unconditionally).
bool isExpressSnoop() const
void setFunctionalResponseStatus(bool success)
bool _isSecure
True if the request targets the secure memory space.
void convertLlToRead()
When ruby is in use, Ruby will monitor the cache line and the phys memory should treat LL ops as norm...
void dataStaticConst(const T *p)
Set the data pointer to the following value that should not be freed.
void setHasSharers()
On fills, the hasSharers flag is used by the caches in combination with the cacheResponding flag,...
Packet(const RequestPtr &_req, MemCmd _cmd)
Constructor.
bool matchBlockAddr(const Addr addr, const bool is_secure, const int blk_size) const
Check if packet corresponds to a given block-aligned address and address space.
HtmCacheFailure htmReturnReason
Holds the return status of the transaction.
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
void setHtmTransactional(uint64_t val)
Stipulates that this packet/request originates in the CPU executing in transactional mode,...
void makeHtmTransactionalReqResponse(const HtmCacheFailure ret_code)
Communicates to the core that a packet was processed by the memory subsystem while running in transac...
void setSize(unsigned size)
const T * getConstPtr() const
static MemCmd makeReadCmd(const RequestPtr &req)
Generate the appropriate read MemCmd based on the Request flags.
bool cacheResponding() const
T getRaw() const
Get the data in the packet without byte swapping.
void qosValue(const uint8_t qos_value)
QoS Value setter Interface for setting QoS priority value of the packet.
void makeAtomicResponse()
void setSatisfied()
Set when a request hits in a cache and the cache is not going to respond.
MemCmd cmd
The command field of the packet.
bool suppressFuncError() const
bool isMaskedWrite() const
T get(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness.
bool isInvalidate() const
bool htmTransactionFailedInCache() const
Returns whether or not this packet/request has returned from the cache hierarchy in a failed transact...
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
void setSuppressFuncError()
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
bool isWholeLineWrite(unsigned blk_size)
uint64_t htmTransactionUid
A global unique identifier of the transaction.
bool isBlockCached() const
PacketDataPtr data
A pointer to the data being transferred.
void allocate()
Allocate memory for the packet.
Abstract base class for objects which support being printed to a stream for debugging.
void set(Type mask)
Set all flag's bits matching the given mask.
bool isSet(Type mask) const
Verifies whether any bit matching the given mask is set.
void clear()
Clear all flag's bits.
bool noneSet(Type mask) const
Verifies whether no bits matching the given mask are set.
constexpr RegId o(int index)
ProbePointArg< PacketInfo > Packet
Packet probe point.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< Request > RequestPtr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::list< PacketPtr > PacketList
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Structure that defines attributes and other data associated with a Command.
const Command response
Corresponding response for requests; InvalidCmd if no response is applicable.
const std::bitset< NUM_COMMAND_ATTRIBUTES > attributes
Set of attribute flags.
const std::string str
String representation (for printing)
CommandInfo(std::initializer_list< Attribute > attrs, Command _response, const std::string &_str)
An entry in the label stack.
LabelStackEntry(const std::string &_label, std::string *_prefix)
A virtual base opaque structure used to hold state associated with the packet (e.g....
SenderState * predecessor