52 #include "arch/remote_gdb.hh" 53 #include "arch/utility.hh" 58 #include "config/use_kvm.hh" 65 #include "debug/Loader.hh" 66 #include "debug/WorkItems.hh" 69 #include "params/System.hh" 79 #if THE_ISA != NULL_ISA 92 :
SimObject(p), _systemPort(
"system_port", this),
93 multiThread(p->multi_thread),
95 init_param(p->init_param),
96 physProxy(_systemPort, p->cache_line_size),
97 kernelSymtab(nullptr),
99 loadAddrMask(p->load_addr_mask),
100 loadAddrOffset(p->load_offset),
106 physmem(
name() +
".physmem", p->memories, p->mmap_using_noreserve),
107 memoryMode(p->mem_mode),
108 _cacheLineSize(p->cache_line_size),
111 numWorkIds(p->num_work_ids),
112 thermalModel(p->thermal_model),
114 _m5opRange(p->m5ops_base ?
118 redirectPaths(p->redirect_paths)
139 warn_once(
"Cache line size is neither 16, 32, 64 nor 128 bytes.\n");
152 inform(
"No kernel set for full system simulation. " 153 "Assuming you know what you're doing\n");
183 fatal(
"could not load kernel symbols\n");
186 fatal(
"could not load kernel local symbols\n");
189 fatal(
"could not load kernel symbols\n");
192 fatal(
"could not load kernel local symbols\n");
198 if (p->kernel_extras_addrs.empty())
199 p->kernel_extras_addrs.resize(p->kernel_extras.size(),
MaxAddr);
200 fatal_if(p->kernel_extras.size() != p->kernel_extras_addrs.size(),
201 "Additional kernel objects, not all load addresses specified\n");
202 for (
int ker_idx = 0; ker_idx < p->kernel_extras.size(); ker_idx++) {
203 const std::string &obj_name = p->kernel_extras[ker_idx];
204 const bool raw = p->kernel_extras_addrs[ker_idx] !=
MaxAddr;
206 fatal_if(!obj,
"Failed to build additional kernel object '%s'.\n",
216 for (
int x = 0;
x <
params()->memories.size();
x++)
217 params()->memories[
x]->system(
this);
234 panic(
"System port on %s is not connected.\n",
name());
273 "Cannot have two CPUs with the same id (%d)\n",
id);
279 #if THE_ISA != NULL_ISA 282 RemoteGDB *rgdb =
new RemoteGDB(
this, tc, port +
id);
287 inform(
"%s: Waiting for a remote GDB connection on port %d.\n",
288 cpu->
name(), rgdb->port());
321 all = tc->schedule(event) && all;
331 all = tc->remove(event) && all;
338 return std::count_if(
357 auto mapper = [
this](
Addr a) {
360 if (
params()->kernel !=
"") {
361 if (
params()->kernel_addr_check) {
365 fatal(
"Kernel is mapped to invalid location (not memory). " 366 "kernelStart 0x(%x) - kernelEnd 0x(%x) %#x:%#x\n",
377 DPRINTF(Loader,
"Kernel loaded...\n");
379 std::function<Addr(Addr)> extra_mapper;
380 for (
auto ker_idx = 0; ker_idx <
kernelExtras.size(); ker_idx++) {
381 const Addr load_addr =
params()->kernel_extras_addrs[ker_idx];
384 image = image.offset(load_addr);
386 image = image.move(mapper);
396 panic(
"replaceThreadContext: bad id, %d >= %d\n",
417 if (dynamic_cast<BaseKvmCPU*>(tc->getCpuPtr()) ==
nullptr) {
436 warn(
"Reached m5ops MMIO region\n");
437 return_addr = 0xffffffff;
442 fatal(
"Out of memory, please increase size of physical memory.");
502 stringstream namestr;
503 ccprintf(namestr,
"work_item_type%d",
j);
505 .name(
name() +
"." + namestr.str())
506 .desc(
"Run time stat for" + namestr.str())
519 DPRINTF(WorkItems,
"Work item end: %d\t%d\t%lld\n", tid, workid, samp);
522 fatal(
"Got workid greater than specified in system configuration\n");
531 ios::fmtflags flags(cerr.flags());
535 for (; i != end; ++
i) {
537 cerr <<
"System " << sys->
name() <<
": " << hex << sys << endl;
553 return master_name.substr(
name().size());
576 "Cannot lookup MasterID by SimObject pointer: " 577 "More than one master is sharing the same SimObject\n");
588 if (
masters[
i].masterName == name) {
616 if (
masters[
i].masterName == name) {
626 fatal(
"Can't request a masterId after regStats(). " 627 "You must do so in init().\n");
634 masters.emplace_back(master, name, master_id);
636 return masters.back().masterId;
642 if (submaster.empty()) {
643 return master->
name();
647 return master->
name() +
"." + submaster;
654 if (master_id >=
masters.size())
655 fatal(
"Invalid master_id passed to getMasterName()\n");
657 const auto& master_info =
masters[master_id];
658 return master_info.masterName;
662 SystemParams::create()
bool schedule(PCEvent *event) override
#define panic(...)
This implements a cprintf based panic() function.
void ccprintf(cp::Print &print)
This master id is used for message signaled interrupts.
AddrRange RangeSize(Addr start, Addr size)
Ports are used to interface objects to each other.
MemoryImage & move(std::function< Addr(Addr)> mapper)
virtual void unserializeSymtab(CheckpointIn &cp)
If needed, unserialize additional symbol table entries for a specific subclass of this system...
#define fatal(...)
This implements a cprintf based fatal() function.
const std::string & name()
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
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)
bool write(const PortProxy &proxy) const
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
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
ObjectFile * createObjectFile(const std::string &fname, bool raw)
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()
DrainState drainState() const
Return the current drain state of an object.
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Addr allocPhysPages(int npages)
Allocate npages contiguous unused physical pages.
virtual void regStats()
Callback to set stat parameters.
void workItemEnd(uint32_t tid, uint32_t workid)
SymbolTable * debugSymbolTable
Global unified debugging symbol table (for target).
Overload hash function for BasicBlockRange type.
virtual BaseCPU * getCpuPtr()=0
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 writeback requests by the caches.
void init() override
After all objects have been created and all ports are connected, check that the system port is connec...
virtual bool schedule(PCEvent *event)=0
int numRunningContexts()
Return number of running (non-halted) thread contexts in system.
void setSystem(System *s)
Initialize system pointer.
AbstractMemory declaration.
Addr kernelStart
Beginning of kernel code.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
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)
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
virtual MemoryImage buildImage() const =0
Tick curTick()
The current simulated tick.
Addr memSize() const
Amount of physical memory that exists.
MasterID getGlobalMasterId(const std::string &master_name)
Registers a GLOBAL MasterID, which is a MasterID not related to any particular SimObject; since no Si...
Addr loadAddrMask
Mask that should be anded for binary/symbol loading.
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.
virtual bool loadLocalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
std::vector< ThreadContext * > threadContexts
Addr kernelEntry
Entry point in the kernel to start at.
#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
std::vector< ObjectFile * > kernelExtras
Additional object files.
void serialize(const std::string &base, CheckpointOut &cp) const
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Draining buffers pending serialization/handover.
virtual const std::string name() const
bool waitForRemoteGDB() const
This master id is used for functional requests that don't come from a particular device.
std::vector< bool > activeCpus
SymbolTable * kernelSymtab
kernel symbol table
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...
ObjectFile * kernel
Object pointer for the kernel code.
std::vector< MasterInfo > masters
This array is a per-system list of all devices capable of issuing a memory system request and an asso...
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
Invalid master id for assertion checking only.
int findMsbSet(uint64_t val)
Returns the bit position of the MSB that is set in the input.
void replaceThreadContext(ThreadContext *tc, ContextID context_id)
void unserialize(const std::string &base, CheckpointIn &cp)
virtual void serializeSymtab(CheckpointOut &os) const
If needed, serialize additional symbol table entries for a specific subclass of this system...
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.
Addr loadAddrOffset
Offset that should be used for binary/symbol loading.
static const int NumArgumentRegs M5_VAR_USED
virtual bool loadGlobalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Abstract superclass for simulation objects.
int ContextID
Globally unique thread context ID.
Addr kernelEnd
End of kernel code.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Additional function to return the Port of a memory 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