summaryrefslogtreecommitdiff
path: root/src/sim/system.hh
diff options
context:
space:
mode:
authorGiacomo Travaglini <giacomo.travaglini@arm.com>2018-04-04 16:27:04 +0100
committerGiacomo Travaglini <giacomo.travaglini@arm.com>2018-04-27 16:00:28 +0000
commit5187a24d496cd16bfe440f52ff0c45ab0e185306 (patch)
treec491ebdad23a5f9e57ef62ffeabcf2b87289f5ce /src/sim/system.hh
parent685cf2d1f8ae2f2ca3168a650efa1d36120783fe (diff)
downloadgem5-5187a24d496cd16bfe440f52ff0c45ab0e185306.tar.xz
sim,cpu,mem,arch: Introduced MasterInfo data structure
With this patch a gem5 System will store more info about its Masters. While it was previously keeping track of the Master name and Master ID only, it is now adding a per-Master pointer to the SimObject related to the Master. This will make it possible for a client to query a System for a Master using either the master's name or the master's pointer. Change-Id: I8b97d328a65cd06f329e2cdd3679451c17d2b8f6 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/9781 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src/sim/system.hh')
-rw-r--r--src/sim/system.hh67
1 files changed, 57 insertions, 10 deletions
diff --git a/src/sim/system.hh b/src/sim/system.hh
index a72f2a762..0d26ffa0d 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014 ARM Limited
+ * Copyright (c) 2012, 2014, 2018 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -57,6 +57,7 @@
#include "base/statistics.hh"
#include "config/the_isa.hh"
#include "enums/MemoryMode.hh"
+#include "mem/mem_master.hh"
#include "mem/mem_object.hh"
#include "mem/physical.hh"
#include "mem/port.hh"
@@ -320,31 +321,77 @@ class System : public MemObject
* It's used to uniquely id any master in the system by name for things
* like cache statistics.
*/
- std::vector<std::string> masterIds;
+ std::vector<MasterInfo> masters;
ThermalModel * thermalModel;
public:
- /** Request an id used to create a request object in the system. All objects
+ /**
+ * Request an id used to create a request object in the system. All objects
* that intend to issues requests into the memory system must request an id
* in the init() phase of startup. All master ids must be fixed by the
* regStats() phase that immediately precedes it. This allows objects in
* the memory system to understand how many masters may exist and
* appropriately name the bins of their per-master stats before the stats
- * are finalized
+ * are finalized.
+ *
+ * Registers a MasterID:
+ * This method takes two parameters, one of which is optional.
+ * The first one is the master object, and it is compulsory; in case
+ * a object has multiple (sub)masters, a second parameter must be
+ * provided and it contains the name of the submaster. The method will
+ * create a master's name by concatenating the SimObject name with the
+ * eventual submaster string, separated by a dot.
+ *
+ * As an example:
+ * For a cpu having two masters: a data master and an instruction master,
+ * the method must be called twice:
+ *
+ * instMasterId = getMasterId(cpu, "inst");
+ * dataMasterId = getMasterId(cpu, "data");
+ *
+ * and the masters' names will be:
+ * - "cpu.inst"
+ * - "cpu.data"
+ *
+ * @param master SimObject related to the master
+ * @param submaster String containing the submaster's name
+ * @return the master's ID.
+ */
+ MasterID getMasterId(const SimObject* master,
+ std::string submaster = std::string());
+
+ /**
+ * Registers a GLOBAL MasterID, which is a MasterID not related
+ * to any particular SimObject; since no SimObject is passed,
+ * the master gets registered by providing the full master name.
+ *
+ * @param masterName full name of the master
+ * @return the master's ID.
*/
- MasterID getMasterId(std::string req_name);
+ MasterID getGlobalMasterId(std::string master_name);
- /** Get the name of an object for a given request id.
+ /**
+ * Get the name of an object for a given request id.
*/
std::string getMasterName(MasterID master_id);
/** Get the number of masters registered in the system */
- MasterID maxMasters()
- {
- return masterIds.size();
- }
+ MasterID maxMasters() { return masters.size(); }
+
+ protected:
+ /** helper function for getMasterId */
+ MasterID _getMasterId(const SimObject* master, std::string master_name);
+
+ /**
+ * Helper function for constructing the full (sub)master name
+ * by providing the root master and the relative submaster name.
+ */
+ std::string leafMasterName(const SimObject* master,
+ const std::string& submaster);
+
+ public:
void regStats() override;
/**