Go to the documentation of this file.
46 #include "arch/remote_gdb.hh"
47 #include "arch/utility.hh"
53 #include "config/use_kvm.hh"
60 #include "debug/Loader.hh"
61 #include "debug/Quiesce.hh"
62 #include "debug/WorkItems.hh"
65 #include "params/System.hh"
79 # if THE_ISA != NULL_ISA
80 DPRINTFS(Quiesce, context->getCpuPtr(),
"activating\n");
89 return csprintf(
"%s.threads[%d]", context->getSystemPtr()->name(),
90 context->contextId());
97 auto *workload = context->getSystemPtr()->workload;
99 workload->recordQuiesce();
106 for (
id = 0;
id < size();
id++) {
107 if (!threads[
id].context)
113 threads.resize(
id + 1);
116 "Cannot have two thread contexts with the same id (%d).",
id);
120 auto &
t = thread(
id);
125 [
this,
id](){ thread(
id).resume(); }, sys->name());
126 # if THE_ISA != NULL_ISA
129 t.gdb =
new RemoteGDB(sys, tc, port +
id);
140 auto &
t = thread(
id);
141 panic_if(!
t.context,
"Can't replace a context which doesn't exist.");
143 t.gdb->replaceThreadContext(tc);
144 # if THE_ISA != NULL_ISA
145 if (
t.resumeEvent->scheduled()) {
146 Tick when =
t.resumeEvent->when();
147 t.context->getCpuPtr()->deschedule(
t.resumeEvent);
148 tc->
getCpuPtr()->schedule(
t.resumeEvent, when);
157 for (
auto &thread: threads) {
159 return thread.context;
168 for (
auto &thread: threads) {
169 auto status = thread.context->status();
181 auto &
t = thread(
id);
182 # if THE_ISA != NULL_ISA
183 BaseCPU M5_VAR_USED *cpu =
t.context->getCpuPtr();
184 DPRINTFS(Quiesce, cpu,
"quiesce()\n");
192 # if THE_ISA != NULL_ISA
193 auto &
t = thread(
id);
194 BaseCPU *cpu =
t.context->getCpuPtr();
196 DPRINTFS(Quiesce, cpu,
"quiesceTick until %u\n", when);
199 cpu->reschedule(
t.resumeEvent, when,
true);
206 :
SimObject(
p), _systemPort(
"system_port", this),
207 multiThread(
p->multi_thread),
209 init_param(
p->init_param),
210 physProxy(_systemPort,
p->cache_line_size),
211 workload(
p->workload),
217 physmem(
name() +
".physmem",
p->memories,
p->mmap_using_noreserve,
218 p->shared_backstore),
219 memoryMode(
p->mem_mode),
220 _cacheLineSize(
p->cache_line_size),
223 numWorkIds(
p->num_work_ids),
224 thermalModel(
p->thermal_model),
226 _m5opRange(
p->m5ops_base ?
230 redirectPaths(
p->redirect_paths)
247 warn_once(
"Cache line size is neither 16, 32, 64 nor 128 bytes.\n");
262 for (
int x = 0;
x <
params()->memories.size();
x++)
263 params()->memories[
x]->system(
this);
277 panic(
"System port on %s is not connected.\n",
name());
287 #if THE_ISA != NULL_ISA
290 auto *cpu =
threads[
i]->getCpuPtr();
291 if (gdb && cpu->waitForRemoteGDB()) {
292 inform(
"%s: Waiting for a remote GDB connection on port %d.",
293 cpu->name(), gdb->port());
341 all = tc->schedule(
event) && all;
351 all = tc->remove(
event) && all;
358 auto *otc =
threads[context_id];
375 if (!
dynamic_cast<BaseKvmCPU *
>(tc->getCpuPtr()))
394 warn(
"Reached m5ops MMIO region\n");
395 return_addr = 0xffffffff;
400 fatal(
"Out of memory, please increase size of physical memory.");
426 deviceMemMap.insert(std::make_pair(requestor_id, deviceMemory));
443 "No device memory found for RequestorID %d\n",
id);
460 if (
t.resumeEvent &&
t.resumeEvent->scheduled())
461 when =
t.resumeEvent->when();
480 !when || !
t.resumeEvent) {
483 # if THE_ISA != NULL_ISA
484 t.context->getCpuPtr()->schedule(
t.resumeEvent, when);
499 stringstream namestr;
500 ccprintf(namestr,
"work_item_type%d",
j);
502 .name(
name() +
"." + namestr.str())
503 .desc(
"Run time stat for" + namestr.str())
516 DPRINTF(WorkItems,
"Work item end: %d\t%d\t%lld\n", tid, workid, samp);
519 fatal(
"Got workid greater than specified in system configuration\n");
528 ios::fmtflags flags(cerr.flags());
532 for (;
i != end; ++
i) {
534 cerr <<
"System " << sys->
name() <<
": " << hex << sys << endl;
550 return requestor_name.substr(
name().size());
552 return requestor_name;
573 "Cannot lookup RequestorID by SimObject pointer: "
574 "More than one requestor is sharing the same SimObject\n");
608 const std::string& requestor_name)
624 fatal(
"Can't request a requestorId after regStats(). "
625 "You must do so in init().\n");
639 const std::string& subrequestor)
641 if (subrequestor.empty()) {
642 return requestor->
name();
646 return requestor->
name() +
"." + subrequestor;
654 fatal(
"Invalid requestor_id passed to getRequestorName()\n");
656 const auto& requestor_info =
requestors[requestor_id];
657 return requestor_info.req_name;
661 SystemParams::create()
@ intRequestorId
This requestor id is used for message signaled interrupts.
#define fatal(...)
This implements a cprintf based fatal() function.
std::unordered_map< RequestorID, AbstractMemory * > deviceMemMap
virtual void regStats()
Callback to set stat parameters.
RequestorID getRequestorId(const SimObject *requestor, std::string subrequestor=std::string())
Request an id used to create a request object in the system.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
std::list< PCEvent * > liveEvents
#define UNSERIALIZE_SCALAR(scalar)
void startup() override
startup() is the final initialization call before simulation.
void workItemEnd(uint32_t tid, uint32_t workid)
@ Halting
Trying to exit and waiting for an event to completely exit.
void init() override
After all objects have been created and all ports are connected, check that the system port is connec...
int ContextID
Globally unique thread context ID.
RequestorID _getRequestorId(const SimObject *requestor, const std::string &requestor_name)
helper function for getRequestorId
uint64_t Tick
Tick count type.
ContextID registerThreadContext(ThreadContext *tc, ContextID assigned=InvalidContextID)
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
bool contains(const Addr &a) const
Determine if the range contains an address.
const unsigned int _cacheLineSize
RequestorID getGlobalRequestorId(const std::string &requestor_name)
Registers a GLOBAL RequestorID, which is a RequestorID not related to any particular SimObject; since...
RequestorID requestorId() const
const ContextID InvalidContextID
bool validKvmEnvironment() const
Verify gem5 configuration will support KVM emulation.
void replaceThreadContext(ThreadContext *tc, ContextID context_id)
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
void replace(ThreadContext *tc, ContextID id)
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
ThreadContext * findFree()
static void printSystems()
std::string stripSystemName(const std::string &requestor_name) const
Strips off the system name from a requestor name.
RequestorID lookupRequestorId(const SimObject *obj) const
Looks up the RequestorID for a given SimObject returns an invalid RequestorID (invldRequestorId) if n...
@ Drained
Buffers drained, ready for serialization/handover.
Enums::MemoryMode memoryMode
virtual void startup()
startup() is the final initialization call before simulation.
static std::vector< System * > systemList
An abstract memory represents a contiguous block of physical memory, with an associated address range...
Workload * workload
OS kernel.
Base class for KVM based CPU models.
void setMemoryMode(Enums::MemoryMode mode)
Change the memory mode of the system.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
virtual bool schedule(PCEvent *event)=0
uint64_t totalSize() const
Get the total physical memory size.
@ Halted
Permanently shut down.
@ wbRequestorId
This requestor id is used for writeback requests by the caches.
bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m, bool warn=true)
This function is used for restoring optional parameters from the checkpoint.
Ports are used to interface objects to each other.
void quiesceTick(ContextID id, Tick when)
void quiesce(ContextID id)
void setSystem(System *s)
Initialize system pointer.
AddrRange RangeSize(Addr start, Addr size)
ContextID insert(ThreadContext *tc, ContextID id=InvalidContextID)
bool schedule(PCEvent *event) override
@ invldRequestorId
Invalid requestor id for assertion checking only.
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...
Addr memSize() const
Amount of physical memory that exists.
static int numSystemsRunning
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Thread & thread(ContextID id)
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
DrainState drainState() const
Return the current drain state of an object.
@ funcRequestorId
This requestor id is used for functional requests that don't come from a particular device.
Addr freeMemSize() const
Amount of physical memory that is still free.
virtual const std::string name() const
std::map< std::pair< uint32_t, uint32_t >, Tick > lastWorkItemStarted
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Additional function to return the Port of a memory object.
std::map< uint32_t, Stats::Histogram * > workItemStats
const AddrRange _m5opRange
Range for memory-mapped m5 pseudo ops.
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.
bool isDeviceMemAddr(PacketPtr pkt) const
Similar to isMemAddr but for devices.
Overload hash function for BasicBlockRange type.
bool startswith(const char *s, const char *prefix)
Return true if 's' starts with the prefix string 'prefix'.
void serialize(CheckpointOut &cp) const override
Serialize an object.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
bool isConnected() const
Is this port currently connected to a peer?
void ccprintf(cp::Print &print)
std::vector< RequestorInfo > requestors
This array is a per-system list of all devices capable of issuing a memory system request and an asso...
std::ostream CheckpointOut
void addDeviceMemory(RequestorID requestorId, AbstractMemory *deviceMemory)
Add a physical memory range for a device.
bool remove(PCEvent *event) override
std::string getRequestorName(RequestorID requestor_id)
Get the name of an object for a given request id.
Addr allocPhysPages(int npages)
Allocate npages contiguous unused physical pages.
AbstractMemory * getDeviceMemory(RequestorID _id) const
Return a pointer to the device memory.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
virtual BaseCPU * getCpuPtr()=0
void regStats() override
Callback to set stat parameters.
const Params * params() const
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.
std::vector< Thread > threads
std::string csprintf(const char *format, const Args &...args)
virtual System * getSystemPtr()=0
#define panic(...)
This implements a cprintf based panic() function.
void drainResume() override
Resume execution after a successful drain.
Tick curTick()
The current simulated tick.
Abstract superclass for simulation objects.
Generated on Wed Sep 30 2020 14:02:01 for gem5 by doxygen 1.8.17