49 #include "arch/locked_mem.hh" 52 #include "debug/LLSC.hh" 53 #include "debug/MemoryAccess.hh" 61 backdoor(params()->range, nullptr,
64 confTableReported(p->conf_table_reported), inAddrMap(p->in_addr_map),
65 kvmMap(p->kvm_map), _system(NULL),
76 panic(
"Memory Size not divisible by page size\n");
94 bytesRead(this,
"bytes_read",
95 "Number of bytes read from this memory"),
96 bytesInstRead(this,
"bytes_inst_read",
97 "Number of instructions bytes read from this memory"),
98 bytesWritten(this,
"bytes_written",
99 "Number of bytes written to this memory"),
100 numReads(this,
"num_reads",
101 "Number of read requests responded to by this memory"),
102 numWrites(this,
"num_writes",
103 "Number of write requests responded to by this memory"),
104 numOther(this,
"num_other",
105 "Number of other requests responded to by this memory"),
106 bwRead(this,
"bw_read",
107 "Total read bandwidth from this memory (bytes/s)"),
108 bwInstRead(this,
"bw_inst_read",
109 "Instruction read bandwidth from this memory (bytes/s)"),
110 bwWrite(this,
"bw_write",
111 "Write bandwidth from this memory (bytes/s)"),
112 bwTotal(this,
"bw_total",
113 "Total bandwidth to/from this memory (bytes/s)")
120 using namespace Stats;
132 for (
int i = 0;
i < max_masters;
i++) {
140 for (
int i = 0;
i < max_masters;
i++) {
148 for (
int i = 0;
i < max_masters;
i++) {
156 for (
int i = 0;
i < max_masters;
i++) {
164 for (
int i = 0;
i < max_masters;
i++) {
172 for (
int i = 0;
i < max_masters;
i++) {
181 for (
int i = 0;
i < max_masters;
i++) {
190 for (
int i = 0;
i < max_masters;
i++) {
199 for (
int i = 0;
i < max_masters;
i++) {
208 for (
int i = 0;
i < max_masters;
i++) {
238 if (i->matchesContext(req)) {
239 DPRINTF(LLSC,
"Modifying lock record: context %d addr %#x\n",
240 req->contextId(), paddr);
247 DPRINTF(LLSC,
"Adding lock record: context %d addr %#x\n",
248 req->contextId(), paddr);
262 bool isLLSC = pkt->
isLLSC();
267 bool allowStore = !isLLSC;
278 if (i->addr == paddr && i->matchesContext(req)) {
281 DPRINTF(LLSC,
"StCond success: context %d addr %#x\n",
282 req->contextId(), paddr);
291 req->setExtraData(allowStore ? 1 : 0);
300 if (i->addr == paddr) {
301 DPRINTF(LLSC,
"Erasing lock record: context %d addr %#x\n",
302 i->contextId, paddr);
305 ContextID requester_cid = req->hasContextId() ?
308 if (owner_cid != requester_cid) {
327 #if THE_ISA != NULL_ISA 328 if (size == 1 || size == 2 || size == 4 || size == 8) {
329 DPRINTF(MemoryAccess,
"%s from %s of size %i on address %#x data " 332 pkt->
req->isUncacheable() ?
'U' :
'C');
336 DPRINTF(MemoryAccess,
"%s from %s of size %i on address %#x %c\n",
338 size, pkt->
getAddr(), pkt->
req->isUncacheable() ?
'U' :
'C');
342 # define TRACE_PACKET(A) tracePacket(system(), A, pkt) 344 # define TRACE_PACKET(A) 351 DPRINTF(MemoryAccess,
"Cache responding to %#llx: not responding\n",
357 DPRINTF(MemoryAccess,
"CleanEvict on 0x%x: not responding\n",
374 uint64_t condition_val64;
375 uint32_t condition_val32;
378 "(i.e. null=False)");
380 bool overwrite_mem =
true;
386 if (pkt->
req->isCondSwap()) {
387 if (pkt->
getSize() ==
sizeof(uint64_t)) {
388 condition_val64 = pkt->
req->getExtraData();
389 overwrite_mem = !std::memcmp(&condition_val64, host_addr,
391 }
else if (pkt->
getSize() ==
sizeof(uint32_t)) {
392 condition_val32 = (uint32_t)pkt->
req->getExtraData();
393 overwrite_mem = !std::memcmp(&condition_val32, host_addr,
396 panic(
"Invalid size for conditional read/write\n");
400 std::memcpy(host_addr, &overwrite_val[0], pkt->
getSize());
402 assert(!pkt->
req->isInstFetch());
404 stats.numOther[pkt->
req->masterId()]++;
406 }
else if (pkt->
isRead()) {
418 stats.numReads[pkt->
req->masterId()]++;
420 if (pkt->
req->isInstFetch())
432 DPRINTF(MemoryAccess,
"%s write due to %s\n",
433 __func__, pkt->
print());
435 assert(!pkt->
req->isInstFetch());
437 stats.numWrites[pkt->
req->masterId()]++;
478 panic(
"AbstractMemory: unimplemented functional command %s",
#define panic(...)
This implements a cprintf based panic() function.
void ccprintf(cp::Print &print)
void functionalAccess(PacketPtr pkt)
Perform an untimed memory read or write without changing anything but the memory itself.
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation...
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
std::string getMasterName(MasterID master_id)
Get the name of an object for a given request id.
Object used to maintain state of a PrintReq.
const FlagsType nonan
Don't print if this is NAN.
std::shared_ptr< Request > RequestPtr
Locked address class that represents a physical address and a context id.
bool writeOK(PacketPtr pkt)
AbstractMemory(const AbstractMemory &)
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
bool cacheResponding() const
#define DDUMP(x, data, count)
virtual void regStats()
Callback to set stat parameters.
Overload hash function for BasicBlockRange type.
void regStats() override
Callback to set stat parameters.
const std::string & curPrefix()
Returns the current line prefix.
bool checkLockedAddrList(PacketPtr pkt)
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
bool isInvalidate() const
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Stats::Formula simSeconds
void globalClearExclusive(XC *xc)
const ByteOrder GuestByteOrder
Derived & init(size_type size)
Set this vector to have the given size.
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits...
AddrRange getAddrRange() const
Get the address range.
ThreadContext * getThreadContext(ContextID tid) const
RequestPtr req
A pointer to the original request.
Stats::Vector bytesWritten
Number of bytes written to this memory.
Stats::Vector numOther
Number of other requests.
AbstractMemory declaration.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
static Addr mask(Addr paddr)
bool needsResponse() const
AbstractMemoryParams Params
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
void printLabels()
Print all of the pending unprinted labels on the stack.
Derived & prereq(const Stat &prereq)
Set the prerequisite stat and marks this stat to print at the end of simulation.
void access(PacketPtr pkt)
Perform an untimed memory access and update all the state (e.g.
AddrRange getAddrRange() const
Get address range to which this packet belongs.
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
std::list< LockedAddr > lockedAddrList
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Stats::Formula bwTotal
Total bandwidth from this memory.
Derived & precision(int _precision)
Set the precision and marks this stat to print at the end of simulation.
Stats::Vector bytesRead
Number of total bytes read from this memory.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Stats::Vector bytesInstRead
Number of instruction bytes read from this memory.
void trackLoadLocked(PacketPtr pkt)
const FlagsType total
Print the total.
MasterID maxMasters()
Get the number of masters registered in the system.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
void init() override
Initialise this memory.
Stats::Vector numWrites
Number of write requests.
System * system() const
read the system pointer Implemented for completeness with the setter
uint8_t * toHostAddr(Addr addr) const
Transform a gem5 address space address into its physical counterpart in the host address space...
const AbstractMemory & mem
bool interleaved() const
Determine if the range is interleaved or not.
void setBackingStore(uint8_t *pmem_addr)
Set the host memory backing store to be used by this memory controller.
Stats::Formula bwRead
Read bandwidth from this memory.
SenderState * senderState
This packet's sender state.
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
MemCmd cmd
The command field of the packet.
uint64_t size() const
Get the memory size.
System * _system
Pointer to the System object.
const ContextID InvalidContextID
const T * getConstPtr() const
An abstract memory represents a contiguous block of physical memory, with an associated address range...
Stats::Formula bwWrite
Write bandwidth from this memory.
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
const FlagsType nozero
Don't print if this is zero.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
std::vector< Info * > stats
Stats::Formula bwInstRead
Read bandwidth from this memory.
MemStats(AbstractMemory &mem)
int ContextID
Globally unique thread context ID.
Addr getPageBytes() const
Get the page bytes for the ISA.
Stats::Vector numReads
Number of read requests.