gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Steve Reinhardt
42  * Nathan Binkert
43  */
44 
45 /* @file
46  * User Console Definitions
47  */
48 
49 #ifndef __SIM_OBJECT_HH__
50 #define __SIM_OBJECT_HH__
51 
52 #include <string>
53 #include <vector>
54 
55 #include "base/stats/group.hh"
56 #include "params/SimObject.hh"
57 #include "sim/drain.hh"
58 #include "sim/eventq.hh"
59 #include "sim/eventq_impl.hh"
60 #include "sim/port.hh"
61 #include "sim/serialize.hh"
62 
63 class EventManager;
64 class ProbeManager;
65 
96 class SimObject : public EventManager, public Serializable, public Drainable,
97  public Stats::Group
98 {
99  private:
101 
103  static SimObjectList simObjectList;
104 
107 
108  protected:
110  const SimObjectParams *_params;
111 
112  public:
113  typedef SimObjectParams Params;
114  const Params *params() const { return _params; }
115  SimObject(const Params *_params);
116  virtual ~SimObject();
117 
118  public:
119 
120  virtual const std::string name() const { return params()->name; }
121 
128  virtual void init();
129 
141  virtual void loadState(CheckpointIn &cp);
142 
148  virtual void initState();
149 
153  virtual void regProbePoints();
154 
158  virtual void regProbeListeners();
159 
164 
174  virtual Port &getPort(const std::string &if_name,
175  PortID idx=InvalidPortID);
176 
183  virtual void startup();
184 
189  DrainState drain() override { return DrainState::Drained; }
190 
199  virtual void memWriteback() {};
200 
212  virtual void memInvalidate() {};
213 
214  void serialize(CheckpointOut &cp) const override {};
215  void unserialize(CheckpointIn &cp) override {};
216 
220  static void serializeAll(CheckpointOut &cp);
221 
222 #ifdef DEBUG
223  public:
224  bool doDebugBreak;
225  static void debugObjectBreak(const std::string &objs);
226 #endif
227 
233  static SimObject *find(const char *name);
234 };
235 
243 {
244  public:
245  virtual ~SimObjectResolver() { }
246 
247  // Find a SimObject given a full path name
248  virtual SimObject *resolveSimObject(const std::string &name) = 0;
249 };
250 
251 #ifdef DEBUG
252 void debugObjectBreak(const char *objs);
253 #endif
254 
255 #endif // __SIM_OBJECT_HH__
virtual void memWriteback()
Write back dirty buffers to memory using functional writes.
Definition: sim_object.hh:199
Ports are used to interface objects to each other.
Definition: port.hh:60
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Definition: sim_object.cc:126
const PortID InvalidPortID
Definition: types.hh:238
DrainState
Object drain/handover states.
Definition: drain.hh:71
SimObjectParams Params
Definition: sim_object.hh:113
static void serializeAll(CheckpointOut &cp)
Serialize all SimObjects in the system.
Definition: sim_object.cc:135
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Definition: probe.hh:152
Definition: cprintf.cc:42
virtual ~SimObjectResolver()
Definition: sim_object.hh:245
Base class to wrap object resolving functionality.
Definition: sim_object.hh:242
STL vector class.
Definition: stl.hh:40
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:223
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: sim_object.cc:76
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: sim_object.hh:214
static SimObjectList simObjectList
List of all instantiated simulation objects.
Definition: sim_object.hh:103
const Params * params() const
Definition: sim_object.hh:114
virtual void memInvalidate()
Invalidate the contents of memory buffers.
Definition: sim_object.hh:212
ProbeManager * probeManager
Manager coordinates hooking up probe points with listeners.
Definition: sim_object.hh:106
SimObject(const Params *_params)
Definition: sim_object.cc:58
virtual void regProbePoints()
Register probe points for this object.
Definition: sim_object.cc:107
virtual void regProbeListeners()
Register probe listeners for this object.
Definition: sim_object.cc:115
Draining buffers pending serialization/handover.
virtual const std::string name() const
Definition: sim_object.hh:120
std::vector< SimObject * > SimObjectList
Definition: sim_object.hh:100
Statistics container.
Definition: group.hh:85
Basic support for object serialization.
Definition: serialize.hh:153
Port Object Declaration.
static SimObject * find(const char *name)
Find the SimObject with the given name and return a pointer to it.
Definition: sim_object.cc:174
std::ostream CheckpointOut
Definition: serialize.hh:68
ProbeManager * getProbeManager()
Get the probe manager for this object.
Definition: sim_object.cc:120
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
DrainState drain() override
Provide a default implementation of the drain interface for objects that don&#39;t need draining...
Definition: sim_object.hh:189
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: sim_object.hh:215
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: sim_object.cc:94
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
virtual ~SimObject()
Definition: sim_object.cc:70
Abstract superclass for simulation objects.
Definition: sim_object.hh:96
virtual void loadState(CheckpointIn &cp)
loadState() is called on each SimObject when restoring from a checkpoint.
Definition: sim_object.cc:81
virtual void startup()
startup() is the final initialization call before simulation.
Definition: sim_object.cc:99

Generated on Fri Feb 28 2020 16:27:03 for gem5 by doxygen 1.8.13