#include "arch/remote_gdb.hh"
#include "arch/utility.hh"
+#include "base/compiler.hh"
#include "base/loader/object_file.hh"
#include "base/loader/symtab.hh"
#include "base/str.hh"
#include "base/trace.hh"
+#include "config/the_isa.hh"
#include "config/use_kvm.hh"
#if USE_KVM
#include "cpu/kvm/base.hh"
#include "cpu/kvm/vm.hh"
#endif
+#if THE_ISA != NULL_ISA
#include "cpu/base.hh"
+#endif
#include "cpu/thread_context.hh"
#include "debug/Loader.hh"
#include "debug/Quiesce.hh"
#include "sim/full_system.hh"
#include "sim/redirect_path.hh"
-using namespace std;
-using namespace TheISA;
-
-vector<System *> System::systemList;
+std::vector<System *> System::systemList;
void
System::Threads::Thread::resume()
# if THE_ISA != NULL_ISA
int port = getRemoteGDBPort();
if (port) {
- t.gdb = new RemoteGDB(sys, tc, port + id);
+ t.gdb = new TheISA::RemoteGDB(sys, tc, port + id);
t.gdb->listen();
}
# endif
{
auto &t = thread(id);
# if THE_ISA != NULL_ISA
- BaseCPU M5_VAR_USED *cpu = t.context->getCpuPtr();
+ M5_VAR_USED BaseCPU *cpu = t.context->getCpuPtr();
DPRINTFS(Quiesce, cpu, "quiesce()\n");
# endif
t.quiesce();
int System::numSystemsRunning = 0;
-System::System(Params *p)
+System::System(const Params &p)
: SimObject(p), _systemPort("system_port", this),
- multiThread(p->multi_thread),
+ multiThread(p.multi_thread),
pagePtr(0),
- init_param(p->init_param),
- physProxy(_systemPort, p->cache_line_size),
- workload(p->workload),
+ init_param(p.init_param),
+ physProxy(_systemPort, p.cache_line_size),
+ workload(p.workload),
#if USE_KVM
- kvmVM(p->kvm_vm),
+ kvmVM(p.kvm_vm),
#else
kvmVM(nullptr),
#endif
- physmem(name() + ".physmem", p->memories, p->mmap_using_noreserve,
- p->shared_backstore),
- memoryMode(p->mem_mode),
- _cacheLineSize(p->cache_line_size),
+ physmem(name() + ".physmem", p.memories, p.mmap_using_noreserve,
+ p.shared_backstore),
+ memoryMode(p.mem_mode),
+ _cacheLineSize(p.cache_line_size),
workItemsBegin(0),
workItemsEnd(0),
- numWorkIds(p->num_work_ids),
- thermalModel(p->thermal_model),
+ numWorkIds(p.num_work_ids),
+ thermalModel(p.thermal_model),
_params(p),
- _m5opRange(p->m5ops_base ?
- RangeSize(p->m5ops_base, 0x10000) :
+ _m5opRange(p.m5ops_base ?
+ RangeSize(p.m5ops_base, 0x10000) :
AddrRange(1, 0)), // Create an empty range if disabled
- totalNumInsts(0),
- redirectPaths(p->redirect_paths)
+ redirectPaths(p.redirect_paths)
{
if (workload)
workload->system = this;
_cacheLineSize == 64 || _cacheLineSize == 128))
warn_once("Cache line size is neither 16, 32, 64 nor 128 bytes.\n");
- // Get the generic system master IDs
- MasterID tmp_id M5_VAR_USED;
- tmp_id = getMasterId(this, "writebacks");
- assert(tmp_id == Request::wbMasterId);
- tmp_id = getMasterId(this, "functional");
- assert(tmp_id == Request::funcMasterId);
- tmp_id = getMasterId(this, "interrupt");
- assert(tmp_id == Request::intMasterId);
+ // Get the generic system requestor IDs
+ M5_VAR_USED RequestorID tmp_id;
+ tmp_id = getRequestorId(this, "writebacks");
+ assert(tmp_id == Request::wbRequestorId);
+ tmp_id = getRequestorId(this, "functional");
+ assert(tmp_id == Request::funcRequestorId);
+ tmp_id = getRequestorId(this, "interrupt");
+ assert(tmp_id == Request::intRequestorId);
// increment the number of running systems
numSystemsRunning++;
// Set back pointers to the system in all memories
- for (int x = 0; x < params()->memories.size(); x++)
- params()->memories[x]->system(this);
+ for (int x = 0; x < params().memories.size(); x++)
+ params().memories[x]->system(this);
}
System::~System()
delete workItemStats[j];
}
-void
-System::init()
-{
- // check that the system port is connected
- if (!_systemPort.isConnected())
- panic("System port on %s is not connected.\n", name());
-}
-
void
System::startup()
{
Addr
System::allocPhysPages(int npages)
{
- Addr return_addr = pagePtr << PageShift;
+ Addr return_addr = pagePtr << TheISA::PageShift;
pagePtr += npages;
- Addr next_return_addr = pagePtr << PageShift;
+ Addr next_return_addr = pagePtr << TheISA::PageShift;
if (_m5opRange.contains(next_return_addr)) {
warn("Reached m5ops MMIO region\n");
return_addr = 0xffffffff;
- pagePtr = 0xffffffff >> PageShift;
+ pagePtr = 0xffffffff >> TheISA::PageShift;
}
- if ((pagePtr << PageShift) > physmem.totalSize())
+ if ((pagePtr << TheISA::PageShift) > physmem.totalSize())
fatal("Out of memory, please increase size of physical memory.");
return return_addr;
}
Addr
System::freeMemSize() const
{
- return physmem.totalSize() - (pagePtr << PageShift);
+ return physmem.totalSize() - (pagePtr << TheISA::PageShift);
}
bool
}
void
-System::addDeviceMemory(MasterID masterId, AbstractMemory *deviceMemory)
+System::addDeviceMemory(RequestorID requestor_id, AbstractMemory *deviceMemory)
{
- if (!deviceMemMap.count(masterId)) {
- deviceMemMap.insert(std::make_pair(masterId, deviceMemory));
+ if (!deviceMemMap.count(requestor_id)) {
+ deviceMemMap.insert(std::make_pair(requestor_id, deviceMemory));
}
}
bool
System::isDeviceMemAddr(PacketPtr pkt) const
{
- const MasterID& mid = pkt->masterId();
+ const RequestorID& id = pkt->requestorId();
- return (deviceMemMap.count(mid) &&
- deviceMemMap.at(mid)->getAddrRange().contains(pkt->getAddr()));
+ return (deviceMemMap.count(id) &&
+ deviceMemMap.at(id)->getAddrRange().contains(pkt->getAddr()));
}
AbstractMemory *
-System::getDeviceMemory(MasterID mid) const
+System::getDeviceMemory(RequestorID id) const
{
- panic_if(!deviceMemMap.count(mid),
- "No device memory found for MasterID %d\n", mid);
- return deviceMemMap.at(mid);
-}
-
-void
-System::drainResume()
-{
- totalNumInsts = 0;
+ panic_if(!deviceMemMap.count(id),
+ "No device memory found for RequestorID %d\n", id);
+ return deviceMemMap.at(id);
}
void
SimObject::regStats();
for (uint32_t j = 0; j < numWorkIds ; j++) {
- workItemStats[j] = new Stats::Histogram();
- stringstream namestr;
+ workItemStats[j] = new Stats::Histogram(this);
+ std::stringstream namestr;
ccprintf(namestr, "work_item_type%d", j);
workItemStats[j]->init(20)
.name(name() + "." + namestr.str())
void
System::printSystems()
{
- ios::fmtflags flags(cerr.flags());
+ std::ios::fmtflags flags(std::cerr.flags());
- vector<System *>::iterator i = systemList.begin();
- vector<System *>::iterator end = systemList.end();
+ std::vector<System *>::iterator i = systemList.begin();
+ std::vector<System *>::iterator end = systemList.end();
for (; i != end; ++i) {
System *sys = *i;
- cerr << "System " << sys->name() << ": " << hex << sys << endl;
+ std::cerr << "System " << sys->name() << ": " << std::hex << sys
+ << std::endl;
}
- cerr.flags(flags);
+ std::cerr.flags(flags);
}
void
}
std::string
-System::stripSystemName(const std::string& master_name) const
+System::stripSystemName(const std::string& requestor_name) const
{
- if (startswith(master_name, name())) {
- return master_name.substr(name().size());
+ if (startswith(requestor_name, name())) {
+ return requestor_name.substr(name().size());
} else {
- return master_name;
+ return requestor_name;
}
}
-MasterID
-System::lookupMasterId(const SimObject* obj) const
+RequestorID
+System::lookupRequestorId(const SimObject* obj) const
{
- MasterID id = Request::invldMasterId;
+ RequestorID id = Request::invldRequestorId;
// number of occurrences of the SimObject pointer
- // in the master list.
+ // in the requestor list.
auto obj_number = 0;
- for (int i = 0; i < masters.size(); i++) {
- if (masters[i].obj == obj) {
+ for (int i = 0; i < requestors.size(); i++) {
+ if (requestors[i].obj == obj) {
id = i;
obj_number++;
}
}
fatal_if(obj_number > 1,
- "Cannot lookup MasterID by SimObject pointer: "
- "More than one master is sharing the same SimObject\n");
+ "Cannot lookup RequestorID by SimObject pointer: "
+ "More than one requestor is sharing the same SimObject\n");
return id;
}
-MasterID
-System::lookupMasterId(const std::string& master_name) const
+RequestorID
+System::lookupRequestorId(const std::string& requestor_name) const
{
- std::string name = stripSystemName(master_name);
+ std::string name = stripSystemName(requestor_name);
- for (int i = 0; i < masters.size(); i++) {
- if (masters[i].masterName == name) {
+ for (int i = 0; i < requestors.size(); i++) {
+ if (requestors[i].req_name == name) {
return i;
}
}
- return Request::invldMasterId;
+ return Request::invldRequestorId;
}
-MasterID
-System::getGlobalMasterId(const std::string& master_name)
+RequestorID
+System::getGlobalRequestorId(const std::string& requestor_name)
{
- return _getMasterId(nullptr, master_name);
+ return _getRequestorId(nullptr, requestor_name);
}
-MasterID
-System::getMasterId(const SimObject* master, std::string submaster)
+RequestorID
+System::getRequestorId(const SimObject* requestor, std::string subrequestor)
{
- auto master_name = leafMasterName(master, submaster);
- return _getMasterId(master, master_name);
+ auto requestor_name = leafRequestorName(requestor, subrequestor);
+ return _getRequestorId(requestor, requestor_name);
}
-MasterID
-System::_getMasterId(const SimObject* master, const std::string& master_name)
+RequestorID
+System::_getRequestorId(const SimObject* requestor,
+ const std::string& requestor_name)
{
- std::string name = stripSystemName(master_name);
+ std::string name = stripSystemName(requestor_name);
// CPUs in switch_cpus ask for ids again after switching
- for (int i = 0; i < masters.size(); i++) {
- if (masters[i].masterName == name) {
+ for (int i = 0; i < requestors.size(); i++) {
+ if (requestors[i].req_name == name) {
return i;
}
}
// they will be too small
if (Stats::enabled()) {
- fatal("Can't request a masterId after regStats(). "
+ fatal("Can't request a requestorId after regStats(). "
"You must do so in init().\n");
}
- // Generate a new MasterID incrementally
- MasterID master_id = masters.size();
+ // Generate a new RequestorID incrementally
+ RequestorID requestor_id = requestors.size();
- // Append the new Master metadata to the group of system Masters.
- masters.emplace_back(master, name, master_id);
+ // Append the new Requestor metadata to the group of system Requestors.
+ requestors.emplace_back(requestor, name, requestor_id);
- return masters.back().masterId;
+ return requestors.back().id;
}
std::string
-System::leafMasterName(const SimObject* master, const std::string& submaster)
+System::leafRequestorName(const SimObject* requestor,
+ const std::string& subrequestor)
{
- if (submaster.empty()) {
- return master->name();
+ if (subrequestor.empty()) {
+ return requestor->name();
} else {
- // Get the full master name by appending the submaster name to
- // the root SimObject master name
- return master->name() + "." + submaster;
+ // Get the full requestor name by appending the subrequestor name to
+ // the root SimObject requestor name
+ return requestor->name() + "." + subrequestor;
}
}
std::string
-System::getMasterName(MasterID master_id)
+System::getRequestorName(RequestorID requestor_id)
{
- if (master_id >= masters.size())
- fatal("Invalid master_id passed to getMasterName()\n");
+ if (requestor_id >= requestors.size())
+ fatal("Invalid requestor_id passed to getRequestorName()\n");
- const auto& master_info = masters[master_id];
- return master_info.masterName;
-}
-
-System *
-SystemParams::create()
-{
- return new System(this);
+ const auto& requestor_info = requestors[requestor_id];
+ return requestor_info.req_name;
}