summaryrefslogtreecommitdiff
path: root/src/sim/system.cc
diff options
context:
space:
mode:
authorAli Saidi <Ali.Saidi@ARM.com>2012-02-12 16:07:38 -0600
committerAli Saidi <Ali.Saidi@ARM.com>2012-02-12 16:07:38 -0600
commit8aaa39e93dfe000ad423b585e78a4c2ee7418363 (patch)
tree0f7b6d1efb630745bd6bf6af05a722a08c8640cb /src/sim/system.cc
parent7e104a1af235823e3d641a972ea920937f7ec67d (diff)
downloadgem5-8aaa39e93dfe000ad423b585e78a4c2ee7418363.tar.xz
mem: Add a master ID to each request object.
This change adds a master id to each request object which can be used identify every device in the system that is capable of issuing a request. This is part of the way to removing the numCpus+1 stats in the cache and replacing them with the master ids. This is one of a series of changes that make way for the stats output to be changed to python.
Diffstat (limited to 'src/sim/system.cc')
-rw-r--r--src/sim/system.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/sim/system.cc b/src/sim/system.cc
index e5e68bf89..1f7527426 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -113,6 +113,16 @@ System::System(Params *p)
physProxy = new PortProxy(*getSystemPort());
virtProxy = new FSTranslatingPortProxy(*getSystemPort());
}
+
+ // Get the generic system master IDs
+ MasterID tmp_id M5_VAR_USED;
+ tmp_id = getMasterId("writebacks");
+ assert(tmp_id == Request::wbMasterId);
+ tmp_id = getMasterId("functional");
+ assert(tmp_id == Request::funcMasterId);
+ tmp_id = getMasterId("interrupt");
+ assert(tmp_id == Request::intMasterId);
+
}
System::~System()
@@ -399,6 +409,42 @@ printSystems()
System::printSystems();
}
+MasterID
+System::getMasterId(std::string master_name)
+{
+ // strip off system name if the string starts with it
+ if (master_name.size() > name().size() &&
+ master_name.compare(0, name().size(), name()) == 0)
+ master_name = master_name.erase(0, name().size() + 1);
+
+ // CPUs in switch_cpus ask for ids again after switching
+ for (int i = 0; i < masterIds.size(); i++) {
+ if (masterIds[i] == master_name) {
+ return i;
+ }
+ }
+
+ // todo: Check if stats are enabled yet
+ // I just don't know a good way to do it
+
+ if (false)
+ fatal("Can't request a masterId after regStats(). \
+ You must do so in init().\n");
+
+ masterIds.push_back(master_name);
+
+ return masterIds.size() - 1;
+}
+
+std::string
+System::getMasterName(MasterID master_id)
+{
+ if (master_id >= masterIds.size())
+ fatal("Invalid master_id passed to getMasterName()\n");
+
+ return masterIds[master_id];
+}
+
const char *System::MemoryModeStrings[3] = {"invalid", "atomic",
"timing"};