gem5  v20.1.0.0
sim_object.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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  * Copyright (c) 2001-2005 The Regents of The University of Michigan
15  * Copyright (c) 2010 Advanced Micro Devices, Inc.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
42 /* @file
43  * User Console Definitions
44  */
45 
46 #ifndef __SIM_OBJECT_HH__
47 #define __SIM_OBJECT_HH__
48 
49 #include <string>
50 #include <vector>
51 
52 #include "base/stats/group.hh"
53 #include "params/SimObject.hh"
54 #include "sim/drain.hh"
55 #include "sim/eventq.hh"
56 #include "sim/port.hh"
57 #include "sim/serialize.hh"
58 
59 class EventManager;
60 class ProbeManager;
61 
92 class SimObject : public EventManager, public Serializable, public Drainable,
93  public Stats::Group
94 {
95  private:
97 
100 
103 
104  protected:
110  const SimObjectParams *_params;
111 
112  public:
113  typedef SimObjectParams Params;
119  const Params *params() const { return _params; }
120 
124  SimObject(const Params *_params);
125 
126  virtual ~SimObject();
127 
128  public:
129 
133  virtual const std::string name() const { return params()->name; }
134 
143  virtual void init();
144 
158  virtual void loadState(CheckpointIn &cp);
159 
167  virtual void initState();
168 
174  virtual void regProbePoints();
175 
181  virtual void regProbeListeners();
182 
194 
218  virtual Port &getPort(const std::string &if_name,
219  PortID idx=InvalidPortID);
220 
229  virtual void startup();
230 
235  DrainState drain() override { return DrainState::Drained; }
236 
247  virtual void memWriteback() {};
248 
262  virtual void memInvalidate() {};
263 
264  void serialize(CheckpointOut &cp) const override {};
265  void unserialize(CheckpointIn &cp) override {};
266 
270  static void serializeAll(CheckpointOut &cp);
271 
272 #ifdef DEBUG
273  public:
274  bool doDebugBreak;
275  static void debugObjectBreak(const std::string &objs);
276 #endif
277 
285  static SimObject *find(const char *name);
286 };
287 
295 {
296  public:
297  virtual ~SimObjectResolver() { }
298 
304  virtual SimObject *resolveSimObject(const std::string &name) = 0;
305 };
306 
307 #ifdef DEBUG
308 void debugObjectBreak(const char *objs);
309 #endif
310 
311 #endif // __SIM_OBJECT_HH__
SimObject::regProbeListeners
virtual void regProbeListeners()
Register probe listeners for this object.
Definition: sim_object.cc:112
SimObjectResolver
Base class to wrap object resolving functionality.
Definition: sim_object.hh:294
SimObjectResolver::~SimObjectResolver
virtual ~SimObjectResolver()
Definition: sim_object.hh:297
SimObject::memInvalidate
virtual void memInvalidate()
Invalidate the contents of memory buffers.
Definition: sim_object.hh:262
SimObject::Params
SimObjectParams Params
Definition: sim_object.hh:113
SimObject::~SimObject
virtual ~SimObject()
Definition: sim_object.cc:67
SimObject::initState
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: sim_object.cc:91
serialize.hh
group.hh
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
SimObject::serializeAll
static void serializeAll(CheckpointOut &cp)
Serialize all SimObjects in the system.
Definition: sim_object.cc:132
SimObject::simObjectList
static SimObjectList simObjectList
List of all instantiated simulation objects.
Definition: sim_object.hh:99
Serializable
Basic support for object serialization.
Definition: serialize.hh:172
SimObjectResolver::resolveSimObject
virtual SimObject * resolveSimObject(const std::string &name)=0
Find a SimObject given a full path name.
SimObject::memWriteback
virtual void memWriteback()
Write back dirty buffers to memory using functional writes.
Definition: sim_object.hh:247
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
std::vector
STL vector class.
Definition: stl.hh:37
SimObject::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: sim_object.hh:265
DrainState::Drained
@ Drained
Buffers drained, ready for serialization/handover.
SimObject::startup
virtual void startup()
startup() is the final initialization call before simulation.
Definition: sim_object.cc:96
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
cp
Definition: cprintf.cc:40
Drainable
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:230
SimObject::getPort
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Definition: sim_object.cc:123
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
SimObject::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: sim_object.hh:264
SimObject::SimObjectList
std::vector< SimObject * > SimObjectList
Definition: sim_object.hh:96
port.hh
SimObject::params
const Params * params() const
Definition: sim_object.hh:119
name
const std::string & name()
Definition: trace.cc:50
SimObject::getProbeManager
ProbeManager * getProbeManager()
Get the probe manager for this object.
Definition: sim_object.cc:117
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
SimObject::drain
DrainState drain() override
Provide a default implementation of the drain interface for objects that don't need draining.
Definition: sim_object.hh:235
SimObject::regProbePoints
virtual void regProbePoints()
Register probe points for this object.
Definition: sim_object.cc:104
SimObject::loadState
virtual void loadState(CheckpointIn &cp)
loadState() is called on each SimObject when restoring from a checkpoint.
Definition: sim_object.cc:78
ProbeManager
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Definition: probe.hh:150
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
SimObject::SimObject
SimObject(const Params *_params)
Definition: sim_object.cc:55
Stats::Group
Statistics container.
Definition: group.hh:83
SimObject::init
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: sim_object.cc:73
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
drain.hh
EventManager
Definition: eventq.hh:973
SimObject::probeManager
ProbeManager * probeManager
Manager coordinates hooking up probe points with listeners.
Definition: sim_object.hh:102
CheckpointIn
Definition: serialize.hh:67
SimObject::find
static SimObject * find(const char *name)
Find the SimObject with the given name and return a pointer to it.
Definition: sim_object.cc:171
eventq.hh
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17