48 #include "debug/LLSC.hh"
49 #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),
69 "Memory range %s must be valid with non-zero size.",
78 const auto &file =
params().image_file;
83 fatal_if(!
object,
"%s: Could not load %s.",
name(), file);
90 warn(
"%s: Moving image from %s to memory address range %s.",
118 : statistics::
Group(&_mem),
mem(_mem),
119 ADD_STAT(bytesRead, statistics::units::Byte::get(),
120 "Number of bytes read from this memory"),
121 ADD_STAT(bytesInstRead, statistics::units::Byte::get(),
122 "Number of instructions bytes read from this memory"),
123 ADD_STAT(bytesWritten, statistics::units::Byte::get(),
124 "Number of bytes written to this memory"),
126 "Number of read requests responded to by this memory"),
128 "Number of write requests responded to by this memory"),
130 "Number of other requests responded to by this memory"),
131 ADD_STAT(bwRead, statistics::units::Rate<
132 statistics::units::Byte, statistics::units::Second>::get(),
133 "Total read bandwidth from this memory"),
135 statistics::units::Rate<
136 statistics::units::Byte, statistics::units::Second>::get(),
137 "Instruction read bandwidth from this memory"),
138 ADD_STAT(bwWrite, statistics::units::Rate<
139 statistics::units::Byte, statistics::units::Second>::get(),
140 "Write bandwidth from this memory"),
141 ADD_STAT(bwTotal, statistics::units::Rate<
142 statistics::units::Byte, statistics::units::Second>::get(),
143 "Total bandwidth to/from this memory")
150 using namespace statistics;
159 .init(max_requestors)
162 for (
int i = 0;
i < max_requestors;
i++) {
167 .init(max_requestors)
170 for (
int i = 0;
i < max_requestors;
i++) {
175 .init(max_requestors)
178 for (
int i = 0;
i < max_requestors;
i++) {
183 .init(max_requestors)
186 for (
int i = 0;
i < max_requestors;
i++) {
191 .init(max_requestors)
194 for (
int i = 0;
i < max_requestors;
i++) {
199 .init(max_requestors)
202 for (
int i = 0;
i < max_requestors;
i++) {
211 for (
int i = 0;
i < max_requestors;
i++) {
217 .prereq(bytesInstRead)
220 for (
int i = 0;
i < max_requestors;
i++) {
226 .prereq(bytesWritten)
229 for (
int i = 0;
i < max_requestors;
i++) {
238 for (
int i = 0;
i < max_requestors;
i++) {
245 bwTotal = (bytesRead + bytesWritten) /
simSeconds;
268 if (
i->matchesContext(req)) {
269 DPRINTF(LLSC,
"Modifying lock record: context %d addr %#x\n",
270 req->contextId(), paddr);
277 DPRINTF(LLSC,
"Adding lock record: context %d addr %#x\n",
278 req->contextId(), paddr);
293 bool isLLSC = pkt->
isLLSC();
298 bool allowStore = !isLLSC;
309 if (
i->addr == paddr &&
i->matchesContext(req)) {
312 DPRINTF(LLSC,
"StCond success: context %d addr %#x\n",
313 req->contextId(), paddr);
322 req->setExtraData(allowStore ? 1 : 0);
331 if (
i->addr == paddr) {
332 DPRINTF(LLSC,
"Erasing lock record: context %d addr %#x\n",
333 i->contextId, paddr);
336 ContextID requestor_cid = req->hasContextId() ?
339 if (owner_cid != requestor_cid) {
360 DPRINTF(MemoryAccess,
"%s from %s of size %i on address %#x data "
364 pkt->
req->isUncacheable() ?
'U' :
'C');
367 DPRINTF(MemoryAccess,
"%s from %s of size %i on address %#x %c\n",
373 # define TRACE_PACKET(A) tracePacket(system(), A, pkt)
375 # define TRACE_PACKET(A)
382 DPRINTF(MemoryAccess,
"Cache responding to %#llx: not responding\n",
388 DPRINTF(MemoryAccess,
"CleanEvict on 0x%x: not responding\n",
405 uint64_t condition_val64;
406 uint32_t condition_val32;
409 "(i.e. null=False)");
411 bool overwrite_mem =
true;
417 if (pkt->
req->isCondSwap()) {
418 if (pkt->
getSize() ==
sizeof(uint64_t)) {
419 condition_val64 = pkt->
req->getExtraData();
420 overwrite_mem = !std::memcmp(&condition_val64, host_addr,
422 }
else if (pkt->
getSize() ==
sizeof(uint32_t)) {
423 condition_val32 = (uint32_t)pkt->
req->getExtraData();
424 overwrite_mem = !std::memcmp(&condition_val32, host_addr,
427 panic(
"Invalid size for conditional read/write\n");
431 std::memcpy(host_addr, &overwrite_val[0], pkt->
getSize());
433 assert(!pkt->
req->isInstFetch());
437 }
else if (pkt->
isRead()) {
451 if (pkt->
req->isInstFetch())
463 DPRINTF(MemoryAccess,
"%s write due to %s\n",
464 __func__, pkt->
print());
466 assert(!pkt->
req->isInstFetch());
509 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....
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
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.
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
RequestPtr req
A pointer to the original request.
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,...
unsigned int cacheLineSize() const
Get the cache line size of the system.
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.
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.
System * system() const
read the system pointer Implemented for completeness with the setter
AbstractMemory(const AbstractMemory &)
bool checkLockedAddrList(PacketPtr pkt)
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
uint8_t * toHostAddr(Addr addr) const
Transform a gem5 address space address into its physical counterpart in the host address space.
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.
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.
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.