54#include "debug/Loader.hh"
55#include "debug/Quiesce.hh"
56#include "debug/WorkItems.hh"
59#include "params/System.hh"
81 return csprintf(
"%s.threads[%d]", context->getSystemPtr()->name(),
82 context->contextId());
89 context->getSystemPtr()->workload->recordQuiesce();
111 panic_if(!
t.context,
"Can't replace a context which doesn't exist.");
112 if (
t.resumeEvent->scheduled()) {
113 Tick when =
t.resumeEvent->when();
114 t.context->getCpuPtr()->deschedule(
t.resumeEvent);
148 [[maybe_unused]]
BaseCPU *cpu =
t.context->getCpuPtr();
149 DPRINTFS(Quiesce, cpu,
"quiesce()\n");
157 BaseCPU *cpu =
t.context->getCpuPtr();
159 DPRINTFS(Quiesce, cpu,
"quiesceTick until %u\n", when);
173 physmem(
name() +
".physmem",
p.memories,
p.mmap_using_noreserve,
174 p.shared_backstore,
p.auto_unlink_shared_backstore),
176 p.shadow_rom_ranges.
end()),
187 "(could use StubWorkload?).",
name());
196 warn_once(
"Cache line size is neither 16, 32, 64 nor 128 bytes.\n");
212 for (
int x = 0;
x <
params().memories.size();
x++)
213 params().memories[
x]->system(
this);
270 auto *otc =
threads[context_id];
316 "No device memory found for Requestor %d\n", rid);
332 if (
t.resumeEvent &&
t.resumeEvent->scheduled())
333 when =
t.resumeEvent->when();
350 !when || !
t.resumeEvent) {
353 t.context->getCpuPtr()->schedule(
t.resumeEvent, when);
367 std::stringstream namestr;
368 ccprintf(namestr,
"work_item_type%d", j);
371 .desc(
"Run time stat for" + namestr.str())
384 DPRINTF(WorkItems,
"Work item end: %d\t%d\t%lld\n", tid, workid, samp);
387 fatal(
"Got workid greater than specified in system configuration\n");
406 for (;
i != end; ++
i) {
408 std::cerr <<
"System " << sys->
name() <<
": " << std::hex << sys
412 std::cerr.flags(
flags);
425 return requestor_name.substr(
name().size() + 1);
427 return requestor_name;
448 "Cannot lookup RequestorID by SimObject pointer: "
449 "More than one requestor is sharing the same SimObject\n");
483 const std::string& requestor_name)
499 fatal(
"Can't request a requestorId after regStats(). "
500 "You must do so in init().\n");
514 const std::string& subrequestor)
516 if (subrequestor.empty()) {
517 return requestor->
name();
521 return requestor->
name() +
"." + subrequestor;
529 fatal(
"Invalid requestor_id passed to getRequestorName()\n");
531 const auto& requestor_info =
requestors[requestor_id];
532 return requestor_info.req_name;
AbstractMemory declaration.
#define DPRINTFS(x, s,...)
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
virtual std::string name() const
virtual bool schedule(PCEvent *event)=0
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
AddrRange getAddrRange() const
Get address range to which this packet belongs.
RequestorID requestorId() const
Ports are used to interface objects to each other.
@ funcRequestorId
This requestor id is used for functional requests that don't come from a particular device.
@ invldRequestorId
Invalid requestor id for assertion checking only.
@ wbRequestorId
This requestor id is used for writeback requests by the caches.
@ intRequestorId
This requestor id is used for message signaled interrupts.
Abstract superclass for simulation objects.
const_iterator end() const
void quiesceTick(ContextID id, Tick when)
const_iterator begin() const
void quiesce(ContextID id)
Thread & thread(ContextID id)
void insert(ThreadContext *tc)
std::vector< Thread > threads
void replace(ThreadContext *tc, ContextID id)
ThreadContext * findFree()
void serialize(CheckpointOut &cp) const override
Serialize an object.
RequestorID lookupRequestorId(const SimObject *obj) const
Looks up the RequestorID for a given SimObject returns an invalid RequestorID (invldRequestorId) if n...
bool remove(PCEvent *event) override
RequestorID _getRequestorId(const SimObject *requestor, const std::string &requestor_name)
helper function for getRequestorId
static int numSystemsRunning
void registerThreadContext(ThreadContext *tc)
enums::MemoryMode memoryMode
std::string leafRequestorName(const SimObject *requestor, const std::string &subrequestor)
Helper function for constructing the full (sub)requestor name by providing the root requestor and the...
void addDeviceMemory(RequestorID requestorId, memory::AbstractMemory *deviceMemory)
Add a physical memory range for a device.
Addr memSize() const
Amount of physical memory that exists.
std::unordered_map< RequestorID, std::vector< memory::AbstractMemory * > > deviceMemMap
std::string getRequestorName(RequestorID requestor_id)
Get the name of an object for a given request id.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
bool isMemAddr(Addr addr) const
Check if a physical address is within a range of a memory that is part of the global address map.
RequestorID getRequestorId(const SimObject *requestor, std::string subrequestor={})
Request an id used to create a request object in the system.
bool schedule(PCEvent *event) override
bool isDeviceMemAddr(const PacketPtr &pkt) const
Similar to isMemAddr but for devices.
std::map< std::pair< uint32_t, uint32_t >, Tick > lastWorkItemStarted
memory::PhysicalMemory physmem
static void printSystems()
std::map< uint32_t, statistics::Histogram * > workItemStats
std::string stripSystemName(const std::string &requestor_name) const
Strips off the system name from a requestor name.
void setMemoryMode(enums::MemoryMode mode)
Change the memory mode of the system.
void workItemEnd(uint32_t tid, uint32_t workid)
Workload * workload
OS kernel.
std::vector< RedirectPath * > redirectPaths
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
const Addr _cacheLineSize
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Additional function to return the Port of a memory object.
ThermalModel * thermalModel
void regStats() override
Callback to set stat parameters.
RequestorID getGlobalRequestorId(const std::string &requestor_name)
Registers a GLOBAL RequestorID, which is a RequestorID not related to any particular SimObject; since...
memory::AbstractMemory * getDeviceMemory(const PacketPtr &pkt) const
Return a pointer to the device memory.
std::list< PCEvent * > liveEvents
std::vector< RequestorInfo > requestors
This array is a per-system list of all devices capable of issuing a memory system request and an asso...
static std::vector< System * > systemList
bool trapToGdb(GDBSignal signal, ContextID ctx_id) const
AddrRangeList ShadowRomRanges
void replaceThreadContext(ThreadContext *tc, ContextID context_id)
const AddrRange _m5opRange
Range for memory-mapped m5 pseudo ops.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void activate()=0
Set the status to Active.
virtual System * getSystemPtr()=0
virtual BaseCPU * getCpuPtr()=0
@ Halted
Permanently shut down.
@ Halting
Trying to exit and waiting for an event to completely exit.
virtual Status status() const =0
virtual void setContextId(ContextID id)=0
virtual void replaceThreadContext(ThreadContext *tc)
virtual void registerThreadContext(ThreadContext *tc)
bool trapToGdb(GDBSignal sig, ContextID ctx_id)
virtual void setSystem(System *sys)
An abstract memory represents a contiguous block of physical memory, with an associated address range...
bool isMemAddr(Addr addr) const
Check if a physical address is within a range of a memory that is part of the global address map.
uint64_t totalSize() const
Get the total physical memory size.
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
AddrRange RangeSize(Addr start, Addr size)
DrainState drainState() const
Return the current drain state of an object.
@ Drained
Buffers drained, ready for serialization/handover.
void schedule(Event &event, Tick when)
void reschedule(Event &event, Tick when, bool always=false)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
#define fatal(...)
This implements a cprintf based fatal() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m, bool do_warn=true)
This function is used for restoring optional parameters from the checkpoint.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
const Params & params() const
virtual void regStats()
Callback to set stat parameters.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
bool startswith(const char *s, const char *prefix)
Return true if 's' starts with the prefix string 'prefix'.
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
int ContextID
Globally unique thread context ID.
std::string csprintf(const char *format, const Args &...args)
void ccprintf(cp::Print &print)