48#include "debug/LLSC.hh"
49#include "debug/MemoryAccess.hh"
61 backdoor(params().range, nullptr,
65 confTableReported(
p.conf_table_reported), inAddrMap(
p.in_addr_map),
66 kvmMap(
p.kvm_map), writeable(
p.writeable), collectStats(
p.collect_stats),
67 _system(NULL), stats(*this)
70 "Memory range %s must be valid with non-zero size.",
79 const auto &file =
params().image_file;
84 fatal_if(!
object,
"%s: Could not load %s.",
name(), file);
91 warn(
"%s: Moving image from %s to memory address range %s.",
119 : statistics::
Group(&_mem),
mem(_mem),
120 ADD_STAT(bytesRead, statistics::units::Byte::get(),
121 "Number of bytes read from this memory"),
122 ADD_STAT(bytesInstRead, statistics::units::Byte::get(),
123 "Number of instructions bytes read from this memory"),
124 ADD_STAT(bytesWritten, statistics::units::Byte::get(),
125 "Number of bytes written to this memory"),
126 ADD_STAT(numReads, statistics::units::Count::get(),
127 "Number of read requests responded to by this memory"),
128 ADD_STAT(numWrites, statistics::units::Count::get(),
129 "Number of write requests responded to by this memory"),
130 ADD_STAT(numOther, statistics::units::Count::get(),
131 "Number of other requests responded to by this memory"),
132 ADD_STAT(bwRead, statistics::units::Rate<
133 statistics::units::Byte, statistics::units::Second>::get(),
134 "Total read bandwidth from this memory"),
136 statistics::units::Rate<
137 statistics::units::Byte, statistics::units::Second>::get(),
138 "Instruction read bandwidth from this memory"),
139 ADD_STAT(bwWrite, statistics::units::Rate<
140 statistics::units::Byte, statistics::units::Second>::get(),
141 "Write bandwidth from this memory"),
142 ADD_STAT(bwTotal, statistics::units::Rate<
143 statistics::units::Byte, statistics::units::Second>::get(),
144 "Total bandwidth to/from this memory")
151 using namespace statistics;
160 .init(max_requestors)
163 for (
int i = 0;
i < max_requestors;
i++) {
168 .init(max_requestors)
171 for (
int i = 0;
i < max_requestors;
i++) {
176 .init(max_requestors)
179 for (
int i = 0;
i < max_requestors;
i++) {
184 .init(max_requestors)
187 for (
int i = 0;
i < max_requestors;
i++) {
192 .init(max_requestors)
195 for (
int i = 0;
i < max_requestors;
i++) {
200 .init(max_requestors)
203 for (
int i = 0;
i < max_requestors;
i++) {
212 for (
int i = 0;
i < max_requestors;
i++) {
218 .prereq(bytesInstRead)
221 for (
int i = 0;
i < max_requestors;
i++) {
227 .prereq(bytesWritten)
230 for (
int i = 0;
i < max_requestors;
i++) {
239 for (
int i = 0;
i < max_requestors;
i++) {
246 bwTotal = (bytesRead + bytesWritten) /
simSeconds;
269 if (
i->matchesContext(req)) {
270 DPRINTF(LLSC,
"Modifying lock record: context %d addr %#x\n",
271 req->contextId(), paddr);
278 DPRINTF(LLSC,
"Adding lock record: context %d addr %#x\n",
279 req->contextId(), paddr);
294 bool isLLSC = pkt->
isLLSC();
299 bool allowStore = !isLLSC;
310 if (
i->addr == paddr &&
i->matchesContext(req)) {
313 DPRINTF(LLSC,
"StCond success: context %d addr %#x\n",
314 req->contextId(), paddr);
323 req->setExtraData(allowStore ? 1 : 0);
332 if (
i->addr == paddr) {
333 DPRINTF(LLSC,
"Erasing lock record: context %d addr %#x\n",
334 i->contextId, paddr);
337 ContextID requestor_cid = req->hasContextId() ?
340 if (owner_cid != requestor_cid) {
361 DPRINTF(MemoryAccess,
"%s from %s of size %i on address %#x data "
365 pkt->
req->isUncacheable() ?
'U' :
'C');
368 DPRINTF(MemoryAccess,
"%s from %s of size %i on address %#x %c\n",
374# define TRACE_PACKET(A) tracePacket(system(), A, pkt)
376# define TRACE_PACKET(A)
383 DPRINTF(MemoryAccess,
"Cache responding to %#llx: not responding\n",
389 DPRINTF(MemoryAccess,
"CleanEvict on 0x%x: not responding\n",
406 uint64_t condition_val64;
407 uint32_t condition_val32;
410 "(i.e. null=False)");
412 bool overwrite_mem =
true;
418 if (pkt->
req->isCondSwap()) {
419 if (pkt->
getSize() ==
sizeof(uint64_t)) {
420 condition_val64 = pkt->
req->getExtraData();
421 overwrite_mem = !std::memcmp(&condition_val64, host_addr,
423 }
else if (pkt->
getSize() ==
sizeof(uint32_t)) {
424 condition_val32 = (uint32_t)pkt->
req->getExtraData();
425 overwrite_mem = !std::memcmp(&condition_val32, host_addr,
428 panic(
"Invalid size for conditional read/write\n");
432 std::memcpy(host_addr, &overwrite_val[0], pkt->
getSize());
434 assert(!pkt->
req->isInstFetch());
440 }
else if (pkt->
isRead()) {
455 if (pkt->
req->isInstFetch()) {
469 DPRINTF(MemoryAccess,
"%s write due to %s\n",
470 __func__, pkt->
print());
472 assert(!pkt->
req->isInstFetch());
517 panic(
"AbstractMemory: unimplemented functional command %s",
AbstractMemory declaration.
#define DDUMP(x, data, count)
DPRINTF is a debugging trace facility that allows one to selectively enable tracing statements.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
virtual void globalClearExclusive()
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
ClockedObjectParams Params
Parameters of ClockedObject.
Wrapper that groups a few flag bits under the same undelying container.
virtual std::string name() const
Object used to maintain state of a PrintReq.
const std::string & curPrefix()
Returns the current line prefix.
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....
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
AddrRange getAddrRange() const
Get address range to which this packet belongs.
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
bool needsResponse() const
SenderState * senderState
This packet's sender state.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
RequestPtr req
A pointer to the original request.
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
const T * getConstPtr() const
bool cacheResponding() const
MemCmd cmd
The command field of the packet.
bool isInvalidate() const
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
This object is a proxy for a port or other object which implements the functional response protocol,...
std::string getRequestorName(RequestorID requestor_id)
Get the name of an object for a given request id.
RequestorID maxRequestors()
Get the number of requestors registered in the system.
Addr cacheLineSize() const
Get the cache line size of the system.
ByteOrder getGuestByteOrder() const
Get the guest byte order.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual BaseISA * getIsaPtr() const =0
MemoryImage & offset(Addr by)
bool write(const PortProxy &proxy) const
bool insert(const Symbol &symbol)
Insert a new symbol in the table if it does not already exist.
An abstract memory represents a contiguous block of physical memory, with an associated address range...
void access(PacketPtr pkt)
Perform an untimed memory access and update all the state (e.g.
uint64_t size() const
Get the memory size.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void trackLoadLocked(PacketPtr pkt)
void setBackingStore(uint8_t *pmem_addr)
Set the host memory backing store to be used by this memory controller.
AbstractMemory(const AbstractMemory &)
bool checkLockedAddrList(PacketPtr pkt)
uint8_t * toHostAddr(Addr addr) const
Transform a gem5 address space address into its physical counterpart in the host address space.
void functionalAccess(PacketPtr pkt)
Perform an untimed memory read or write without changing anything but the memory itself.
AddrRange getAddrRange() const
Get the address range.
std::list< LockedAddr > lockedAddrList
gem5::memory::AbstractMemory::MemStats stats
System * system() const
read the system pointer Implemented for completeness with the setter
bool writeOK(PacketPtr pkt)
Locked address class that represents a physical address and a context id.
static Addr mask(Addr paddr)
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
bool interleaved() const
Determine if the range is interleaved or not.
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
bool valid() const
Determine if the range is valid.
bool contains(const Addr &a) const
Determine if the range contains an address.
Addr start() const
Get the start address of the range.
Addr size() const
Get the size of the address range.
std::string to_string() const
Get a string representation of the range.
#define panic(...)
This implements a cprintf based panic() function.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
const Params & params() const
virtual void regStats()
Callback to set stat parameters.
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
ObjectFile * createObjectFile(const std::string &fname, bool raw)
const FlagsType nonan
Don't print if this is NAN.
const FlagsType nozero
Don't print if this is zero.
const FlagsType total
Print the total.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::shared_ptr< Request > RequestPtr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int ContextID
Globally unique thread context ID.
const ContextID InvalidContextID
statistics::Formula & simSeconds
void ccprintf(cp::Print &print)
statistics::Vector bytesRead
Number of total bytes read from this memory.
statistics::Vector bytesInstRead
Number of instruction bytes read from this memory.
statistics::Vector numReads
Number of read requests.
MemStats(AbstractMemory &mem)
void regStats() override
Callback to set stat parameters.
statistics::Vector numOther
Number of other requests.
statistics::Vector bytesWritten
Number of bytes written to this memory.
statistics::Vector numWrites
Number of write requests.