diff options
Diffstat (limited to 'src/sim/system.hh')
-rw-r--r-- | src/sim/system.hh | 67 |
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; /** |