45 #include "arch/locked_mem.hh" 50 #include "debug/LLSC.hh" 51 #include "debug/MemoryAccess.hh" 59 backdoor(params()->range, nullptr,
62 confTableReported(p->conf_table_reported), inAddrMap(p->in_addr_map),
63 kvmMap(p->kvm_map), _system(NULL),
67 "Memory range %s must be valid with non-zero size.",
76 const auto &file =
params()->image_file;
81 fatal_if(!
object,
"%s: Could not load %s.",
name(), file);
84 "%s: Could not load symbols from %s.",
name(), file);
88 AddrRange image_range(image.minAddr(), image.maxAddr());
90 warn(
"%s: Moving image from %s to memory address range %s.",
93 image_range =
AddrRange(image.minAddr(), image.maxAddr());
95 panic_if(!image_range.isSubset(
range),
"%s: memory image %s doesn't fit.",
100 panic_if(!image.write(proxy),
"%s: Unable to write image.");
118 bytesRead(this,
"bytes_read",
119 "Number of bytes read from this memory"),
120 bytesInstRead(this,
"bytes_inst_read",
121 "Number of instructions bytes read from this memory"),
122 bytesWritten(this,
"bytes_written",
123 "Number of bytes written to this memory"),
124 numReads(this,
"num_reads",
125 "Number of read requests responded to by this memory"),
126 numWrites(this,
"num_writes",
127 "Number of write requests responded to by this memory"),
128 numOther(this,
"num_other",
129 "Number of other requests responded to by this memory"),
130 bwRead(this,
"bw_read",
131 "Total read bandwidth from this memory (bytes/s)"),
132 bwInstRead(this,
"bw_inst_read",
133 "Instruction read bandwidth from this memory (bytes/s)"),
134 bwWrite(this,
"bw_write",
135 "Write bandwidth from this memory (bytes/s)"),
136 bwTotal(this,
"bw_total",
137 "Total bandwidth to/from this memory (bytes/s)")
144 using namespace Stats;
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++) {
180 for (
int i = 0;
i < max_masters;
i++) {
188 for (
int i = 0;
i < max_masters;
i++) {
196 for (
int i = 0;
i < max_masters;
i++) {
205 for (
int i = 0;
i < max_masters;
i++) {
214 for (
int i = 0;
i < max_masters;
i++) {
223 for (
int i = 0;
i < max_masters;
i++) {
232 for (
int i = 0;
i < max_masters;
i++) {
262 if (i->matchesContext(req)) {
263 DPRINTF(LLSC,
"Modifying lock record: context %d addr %#x\n",
264 req->contextId(), paddr);
271 DPRINTF(LLSC,
"Adding lock record: context %d addr %#x\n",
272 req->contextId(), paddr);
286 bool isLLSC = pkt->
isLLSC();
291 bool allowStore = !isLLSC;
302 if (i->addr == paddr && i->matchesContext(req)) {
305 DPRINTF(LLSC,
"StCond success: context %d addr %#x\n",
306 req->contextId(), paddr);
315 req->setExtraData(allowStore ? 1 : 0);
324 if (i->addr == paddr) {
325 DPRINTF(LLSC,
"Erasing lock record: context %d addr %#x\n",
326 i->contextId, paddr);
329 ContextID requester_cid = req->hasContextId() ?
332 if (owner_cid != requester_cid) {
351 #if THE_ISA != NULL_ISA 352 if (size == 1 || size == 2 || size == 4 || size == 8) {
353 DPRINTF(MemoryAccess,
"%s from %s of size %i on address %#x data " 356 pkt->
req->isUncacheable() ?
'U' :
'C');
360 DPRINTF(MemoryAccess,
"%s from %s of size %i on address %#x %c\n",
362 size, pkt->
getAddr(), pkt->
req->isUncacheable() ?
'U' :
'C');
366 # define TRACE_PACKET(A) tracePacket(system(), A, pkt) 368 # define TRACE_PACKET(A) 375 DPRINTF(MemoryAccess,
"Cache responding to %#llx: not responding\n",
381 DPRINTF(MemoryAccess,
"CleanEvict on 0x%x: not responding\n",
398 uint64_t condition_val64;
399 uint32_t condition_val32;
402 "(i.e. null=False)");
404 bool overwrite_mem =
true;
410 if (pkt->
req->isCondSwap()) {
411 if (pkt->
getSize() ==
sizeof(uint64_t)) {
412 condition_val64 = pkt->
req->getExtraData();
413 overwrite_mem = !std::memcmp(&condition_val64, host_addr,
415 }
else if (pkt->
getSize() ==
sizeof(uint32_t)) {
416 condition_val32 = (uint32_t)pkt->
req->getExtraData();
417 overwrite_mem = !std::memcmp(&condition_val32, host_addr,
420 panic(
"Invalid size for conditional read/write\n");
424 std::memcpy(host_addr, &overwrite_val[0], pkt->
getSize());
426 assert(!pkt->
req->isInstFetch());
428 stats.numOther[pkt->
req->masterId()]++;
430 }
else if (pkt->
isRead()) {
442 stats.numReads[pkt->
req->masterId()]++;
444 if (pkt->
req->isInstFetch())
456 DPRINTF(MemoryAccess,
"%s write due to %s\n",
457 __func__, pkt->
print());
459 assert(!pkt->
req->isInstFetch());
461 stats.numWrites[pkt->
req->masterId()]++;
502 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.
ObjectFile * createObjectFile(const std::string &fname, bool raw)
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.
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
bool contains(const Addr &a) const
Determine if the range contains an address.
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)
Overload hash function for BasicBlockRange type.
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
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)
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
bool valid() const
Determine if the range is valid.
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.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
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.
This object is a proxy for a port or other object which implements the functional response protocol...
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
virtual const std::string name() const
const Params * params() const
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.
const ContextID InvalidContextID
const T * getConstPtr() const
An abstract memory represents a contiguous block of physical memory, with an associated address range...
Addr start() const
Get the start address of the range.
Addr size() const
Get the size of the address range.
const ByteOrder GuestByteOrder
virtual void regStats()
Callback to set stat parameters.
std::string to_string() const
Get a string representation of the 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.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Stats::Vector numReads
Number of read requests.