gem5  v21.1.0.2
cxx_config.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
51 #ifndef __SIM_CXX_CONFIG_HH__
52 #define __SIM_CXX_CONFIG_HH__
53 
54 #include <map>
55 #include <string>
56 #include <vector>
57 
58 #include "sim/sim_object.hh"
59 
60 namespace gem5
61 {
62 
63 class CxxConfigParams;
64 
70 {
71  public:
72  /* Class to represent parameters and SimObject references within
73  * SimObjects */
74  class ParamDesc
75  {
76  public:
77  const std::string name;
78 
79  /* Is this a vector or singleton parameters/SimObject */
80  const bool isVector;
81 
84  const bool isSimObject;
85 
86  ParamDesc(const std::string &name_,
87  bool isVector_, bool isSimObject_) :
88  name(name_), isVector(isVector_), isSimObject(isSimObject_)
89  { }
90  };
91 
93  class PortDesc
94  {
95  public:
96  const std::string name;
97 
98  /* Is this a vector or singleton parameters/SimObject */
99  const bool isVector;
100 
102  const bool isRequestor;
103 
104  PortDesc(const std::string &name_,
105  bool isVector_, bool isRequestor_) :
106  name(name_), isVector(isVector_), isRequestor(isRequestor_)
107  { }
108  };
109 
111  std::map<std::string, ParamDesc *> parameters;
112 
114  std::map<std::string, PortDesc *> ports;
115 
117  virtual CxxConfigParams *makeParamsObject() const { return NULL; }
118 
120 };
121 
127 {
128  private:
129  static const std::string invalidName;
130 
131  public:
134  typedef uint32_t FlagsType;
136 
138  /* static const FlagsType MY_NEW_FLAG = 0x00000001; */
139 
140  public:
142  virtual void setName(const std::string &name_) { }
143 
145  virtual const std::string &getName() { return invalidName; }
146 
150  virtual bool setSimObject(const std::string &name,
151  SimObject *simObject)
152  { return false; }
153 
155  virtual bool setSimObjectVector(const std::string &name,
156  const std::vector<SimObject *> &simObjects)
157  { return false; }
158 
163  virtual bool setParam(const std::string &name,
164  const std::string &value, const Flags flags)
165  { return false; }
166 
169  virtual bool setParamVector(const std::string &name,
170  const std::vector<std::string> &values, const Flags flags)
171  { return false; }
172 
175  virtual bool setPortConnectionCount(const std::string &name,
176  unsigned int count)
177  { return false; }
178 
180  virtual SimObject *simObjectCreate() { return NULL; }
181 
183 
184  virtual ~CxxConfigParams() { }
185 };
186 
189 {
190  public:
192  virtual ~CxxConfigFileBase() { }
193 
197  virtual bool getParam(const std::string &object_name,
198  const std::string &param_name,
199  std::string &value) const = 0;
200 
202  virtual bool getParamVector(const std::string &object_name,
203  const std::string &param_name,
204  std::vector<std::string> &values) const = 0;
205 
207  virtual bool getPortPeers(const std::string &object_name,
208  const std::string &port_name,
209  std::vector<std::string> &peers) const = 0;
210 
212  virtual bool objectExists(const std::string &object_name) const = 0;
213 
215  virtual void getAllObjectNames(std::vector<std::string> &list) const = 0;
216 
220  virtual void getObjectChildren(const std::string &object_name,
221  std::vector<std::string> &children,
222  bool return_paths = false) const = 0;
223 
225  virtual bool load(const std::string &filename) = 0;
226 
229  virtual CxxConfigParams::Flags getFlags() const { return 0; }
230 };
231 
233 extern std::map<std::string, CxxConfigDirectoryEntry *>
235 
238 void cxxConfigInit();
239 
240 } // namespace gem5
241 
242 #endif // __SIM_CXX_CONFIG_HH__
gem5::CxxConfigFileBase::getAllObjectNames
virtual void getAllObjectNames(std::vector< std::string > &list) const =0
Get all SimObjects in the config.
gem5::CxxConfigFileBase::~CxxConfigFileBase
virtual ~CxxConfigFileBase()
Definition: cxx_config.hh:192
gem5::CxxConfigFileBase::CxxConfigFileBase
CxxConfigFileBase()
Definition: cxx_config.hh:191
gem5::CxxConfigFileBase::getPortPeers
virtual bool getPortPeers(const std::string &object_name, const std::string &port_name, std::vector< std::string > &peers) const =0
Get the peer (connected) ports of the named ports.
gem5::CxxConfigParams::invalidName
static const std::string invalidName
Definition: cxx_config.hh:129
gem5::CxxConfigParams::FlagsType
uint32_t FlagsType
Flags passable to setParam...
Definition: cxx_config.hh:134
gem5::CxxConfigParams::setPortConnectionCount
virtual bool setPortConnectionCount(const std::string &name, unsigned int count)
Set the number of connections expected for the named port.
Definition: cxx_config.hh:175
gem5::CxxConfigParams::Flags
gem5::Flags< FlagsType > Flags
Definition: cxx_config.hh:135
gem5::CxxConfigParams::setSimObject
virtual bool setSimObject(const std::string &name, SimObject *simObject)
Set a SimObject valued parameter with a reference to the given SimObject.
Definition: cxx_config.hh:150
gem5::CxxConfigDirectoryEntry::parameters
std::map< std::string, ParamDesc * > parameters
All parameters (including SimObjects) in order.
Definition: cxx_config.hh:111
gem5::CxxConfigParams
Base for peer classes of SimObjectParams derived classes with parameter modifying member functions.
Definition: cxx_config.hh:126
gem5::CxxConfigParams::CxxConfigParams
CxxConfigParams()
Definition: cxx_config.hh:182
sc_dt::list
static scfx_rep_node * list
Definition: scfx_rep.cc:368
gem5::CxxConfigDirectoryEntry::PortDesc::name
const std::string name
Definition: cxx_config.hh:96
std::vector
STL vector class.
Definition: stl.hh:37
gem5::cxxConfigInit
void cxxConfigInit()
Initialise cxx_config_directory.
gem5::CxxConfigDirectoryEntry::PortDesc::PortDesc
PortDesc(const std::string &name_, bool isVector_, bool isRequestor_)
Definition: cxx_config.hh:104
gem5::CxxConfigParams::~CxxConfigParams
virtual ~CxxConfigParams()
Definition: cxx_config.hh:184
gem5::CxxConfigDirectoryEntry::makeParamsObject
virtual CxxConfigParams * makeParamsObject() const
Make a ...Param structure for the SimObject class of this entry.
Definition: cxx_config.hh:117
gem5::CxxConfigFileBase::getParamVector
virtual bool getParamVector(const std::string &object_name, const std::string &param_name, std::vector< std::string > &values) const =0
Get a list/vector parameter.
gem5::cxx_config_directory
std::map< std::string, CxxConfigDirectoryEntry * > cxx_config_directory
Directory of all SimObject classes config details.
Definition: cxx_config.cc:46
gem5::Flags< FlagsType >
gem5::CxxConfigFileBase::getParam
virtual bool getParam(const std::string &object_name, const std::string &param_name, std::string &value) const =0
Get a single parameter value as a string returned in value.
gem5::CxxConfigDirectoryEntry::ParamDesc::name
const std::string name
Definition: cxx_config.hh:77
gem5::CxxConfigDirectoryEntry::PortDesc::isVector
const bool isVector
Definition: cxx_config.hh:99
sim_object.hh
gem5::X86ISA::count
count
Definition: misc.hh:709
gem5::CxxConfigDirectoryEntry::ParamDesc::isVector
const bool isVector
Definition: cxx_config.hh:80
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::CxxConfigDirectoryEntry::PortDesc
Similar to ParamDesc to describe ports.
Definition: cxx_config.hh:93
gem5::CxxConfigDirectoryEntry::ParamDesc::ParamDesc
ParamDesc(const std::string &name_, bool isVector_, bool isSimObject_)
Definition: cxx_config.hh:86
name
const std::string & name()
Definition: trace.cc:49
gem5::CxxConfigDirectoryEntry::ports
std::map< std::string, PortDesc * > ports
Ports.
Definition: cxx_config.hh:114
gem5::CxxConfigFileBase
Config file wrapper providing a common interface to CxxConfigManager.
Definition: cxx_config.hh:188
gem5::CxxConfigFileBase::load
virtual bool load(const std::string &filename)=0
Load config file.
gem5::CxxConfigParams::getName
virtual const std::string & getName()
Get full path name string.
Definition: cxx_config.hh:145
gem5::CxxConfigFileBase::objectExists
virtual bool objectExists(const std::string &object_name) const =0
Does an object with this path exist?
gem5::CxxConfigParams::setName
virtual void setName(const std::string &name_)
Example flag.
Definition: cxx_config.hh:142
gem5::CxxConfigFileBase::getObjectChildren
virtual void getObjectChildren(const std::string &object_name, std::vector< std::string > &children, bool return_paths=false) const =0
Get the names or paths of all the children SimObjects of this SimObject.
gem5::CxxConfigDirectoryEntry::~CxxConfigDirectoryEntry
virtual ~CxxConfigDirectoryEntry()
Definition: cxx_config.hh:119
gem5::CxxConfigDirectoryEntry
Config details entry for a SimObject.
Definition: cxx_config.hh:69
gem5::CxxConfigParams::setParamVector
virtual bool setParamVector(const std::string &name, const std::vector< std::string > &values, const Flags flags)
As setParamVector but for parameters given as vectors pre-separated into elements.
Definition: cxx_config.hh:169
gem5::CxxConfigDirectoryEntry::ParamDesc
Definition: cxx_config.hh:74
gem5::CxxConfigFileBase::getFlags
virtual CxxConfigParams::Flags getFlags() const
Get the flags which should be used to modify parameter parsing behaviour.
Definition: cxx_config.hh:229
gem5::CxxConfigDirectoryEntry::ParamDesc::isSimObject
const bool isSimObject
Is this a SimObject, and so is to be set with setSimObject...
Definition: cxx_config.hh:84
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::CxxConfigParams::setParam
virtual bool setParam(const std::string &name, const std::string &value, const Flags flags)
Set a parameter with a value parsed from the given string.
Definition: cxx_config.hh:163
gem5::CxxConfigParams::simObjectCreate
virtual SimObject * simObjectCreate()
Create the associated SimObject.
Definition: cxx_config.hh:180
gem5::CxxConfigParams::setSimObjectVector
virtual bool setSimObjectVector(const std::string &name, const std::vector< SimObject * > &simObjects)
As setSimObjectVector but set a whole vector of references.
Definition: cxx_config.hh:155
gem5::CxxConfigDirectoryEntry::PortDesc::isRequestor
const bool isRequestor
Is this a request or response port.
Definition: cxx_config.hh:102

Generated on Tue Sep 21 2021 12:25:47 for gem5 by doxygen 1.8.17