46 #include "arch/remote_gdb.hh" 47 #include "arch/utility.hh" 52 #include "config/use_kvm.hh" 59 #include "debug/Loader.hh" 60 #include "debug/WorkItems.hh" 63 #include "params/System.hh" 73 #if THE_ISA != NULL_ISA 86 :
SimObject(p), _systemPort(
"system_port", this),
87 multiThread(p->multi_thread),
89 init_param(p->init_param),
90 physProxy(_systemPort, p->cache_line_size),
91 workload(p->workload),
97 physmem(
name() +
".physmem", p->memories, p->mmap_using_noreserve),
98 memoryMode(p->mem_mode),
99 _cacheLineSize(p->cache_line_size),
102 numWorkIds(p->num_work_ids),
103 thermalModel(p->thermal_model),
105 _m5opRange(p->m5ops_base ?
109 redirectPaths(p->redirect_paths)
126 warn_once(
"Cache line size is neither 16, 32, 64 nor 128 bytes.\n");
141 for (
int x = 0;
x <
params()->memories.size();
x++)
142 params()->memories[
x]->system(
this);
156 panic(
"System port on %s is not connected.\n",
name());
166 #if THE_ISA != NULL_ISA 168 auto *cpu = tc->getCpuPtr();
169 auto id = tc->contextId();
174 if (cpu->waitForRemoteGDB()) {
175 inform(
"%s: Waiting for a remote GDB connection on port %d.\n",
176 cpu->name(), rgdb->port());
220 "Cannot have two CPUs with the same id (%d)\n",
id);
226 #if THE_ISA != NULL_ISA 229 RemoteGDB *rgdb =
new RemoteGDB(
this, tc, port +
id);
260 all = tc->schedule(event) && all;
270 all = tc->remove(event) && all;
277 return std::count_if(
291 panic(
"replaceThreadContext: bad id, %d >= %d\n",
312 if (dynamic_cast<BaseKvmCPU*>(tc->getCpuPtr()) ==
nullptr) {
331 warn(
"Reached m5ops MMIO region\n");
332 return_addr = 0xffffffff;
337 fatal(
"Out of memory, please increase size of physical memory.");
391 stringstream namestr;
392 ccprintf(namestr,
"work_item_type%d",
j);
394 .name(
name() +
"." + namestr.str())
395 .desc(
"Run time stat for" + namestr.str())
408 DPRINTF(WorkItems,
"Work item end: %d\t%d\t%lld\n", tid, workid, samp);
411 fatal(
"Got workid greater than specified in system configuration\n");
420 ios::fmtflags flags(cerr.flags());
424 for (; i != end; ++
i) {
426 cerr <<
"System " << sys->
name() <<
": " << hex << sys << endl;
442 return master_name.substr(
name().size());
465 "Cannot lookup MasterID by SimObject pointer: " 466 "More than one master is sharing the same SimObject\n");
477 if (
masters[
i].masterName == name) {
505 if (
masters[
i].masterName == name) {
515 fatal(
"Can't request a masterId after regStats(). " 516 "You must do so in init().\n");
523 masters.emplace_back(master, name, master_id);
525 return masters.back().masterId;
531 if (submaster.empty()) {
532 return master->
name();
536 return master->
name() +
"." + submaster;
543 if (master_id >=
masters.size())
544 fatal(
"Invalid master_id passed to getMasterName()\n");
546 const auto& master_info =
masters[master_id];
547 return master_info.masterName;
551 SystemParams::create()
bool schedule(PCEvent *event) override
#define panic(...)
This implements a cprintf based panic() function.
void ccprintf(cp::Print &print)
AddrRange RangeSize(Addr start, Addr size)
Ports are used to interface objects to each other.
#define fatal(...)
This implements a cprintf based fatal() function.
const std::string & name()
std::string getMasterName(MasterID master_id)
Get the name of an object for a given request id.
Enums::MemoryMode memoryMode
ContextID registerThreadContext(ThreadContext *tc, ContextID assigned=InvalidContextID)
Trying to exit and waiting for an event to completely exit.
uint64_t totalSize() const
Get the total physical memory size.
const Params * params() const
Addr freeMemSize() const
Amount of physical memory that is still free.
bool contains(const Addr &a) const
Determine if the range contains an address.
static void printSystems()
Addr allocPhysPages(int npages)
Allocate npages contiguous unused physical pages.
void workItemEnd(uint32_t tid, uint32_t workid)
Overload hash function for BasicBlockRange type.
bool isConnected() const
Is this port currently connected to a peer?
std::list< PCEvent * > liveEvents
ThreadContext is the external interface to all thread state for anything outside of the CPU...
This master id is used for functional requests that don't come from a particular device.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
virtual bool schedule(PCEvent *event)=0
int numRunningContexts()
Return number of running (non-halted) thread contexts in system.
DrainState drainState() const
Return the current drain state of an object.
void setSystem(System *s)
Initialize system pointer.
AbstractMemory declaration.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
void regStats() override
Callback to set stat parameters.
#define UNSERIALIZE_SCALAR(scalar)
Draining buffers pending serialization/handover.
virtual void startup()
startup() is the final initialization call before simulation.
Tick curTick()
The current simulated tick.
Addr memSize() const
Amount of physical memory that exists.
This master id is used for message signaled interrupts.
MasterID getGlobalMasterId(const std::string &master_name)
Registers a GLOBAL MasterID, which is a MasterID not related to any particular SimObject; since no Si...
void drainResume() override
Resume execution after a successful drain.
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 Tick
Tick count type.
const unsigned int _cacheLineSize
void serialize(CheckpointOut &cp) const override
Serialize an object.
MasterID getMasterId(const SimObject *master, std::string submaster=std::string())
Request an id used to create a request object in the system.
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...
const AddrRange _m5opRange
Range for memory-mapped m5 pseudo ops.
std::vector< ThreadContext * > threadContexts
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
ThreadContext * findFreeContext()
std::map< uint32_t, Stats::Histogram * > workItemStats
Workload * workload
OS kernel.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::vector< bool > activeCpus
bool startswith(const char *s, const char *prefix)
Return true if 's' starts with the prefix string 'prefix'.
#define SERIALIZE_SCALAR(scalar)
MasterID lookupMasterId(const SimObject *obj) const
Looks up the MasterID for a given SimObject returns an invalid MasterID (invldMasterId) if not found...
std::vector< MasterInfo > masters
This array is a per-system list of all devices capable of issuing a memory system request and an asso...
virtual const std::string name() const
bool validKvmEnvironment() const
Verify gem5 configuration will support KVM emulation.
std::ostream CheckpointOut
bool remove(PCEvent *event) override
static int numSystemsRunning
MasterID _getMasterId(const SimObject *master, const std::string &master_name)
helper function for getMasterId
const ContextID InvalidContextID
void replaceThreadContext(ThreadContext *tc, ContextID context_id)
std::map< std::pair< uint32_t, uint32_t >, Tick > lastWorkItemStarted
std::vector< BaseRemoteGDB * > remoteGDB
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
std::string stripSystemName(const std::string &master_name) const
Strips off the system name from a master name.
virtual void regStats()
Callback to set stat parameters.
This master id is used for writeback requests by the caches.
Abstract superclass for simulation objects.
int ContextID
Globally unique thread context ID.
Invalid master id for assertion checking only.
void startup() override
startup() is the final initialization call before simulation.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Additional function to return the Port of a memory object.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
std::string leafMasterName(const SimObject *master, const std::string &submaster)
Helper function for constructing the full (sub)master name by providing the root master and the relat...
void setMemoryMode(Enums::MemoryMode mode)
Change the memory mode of the system.
static std::vector< System * > systemList