gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 "params/SimObject.hh"
56 #include "sim/drain.hh"
57 #include "sim/eventq.hh"
58 #include "sim/eventq_impl.hh"
59 #include "sim/serialize.hh"
60 
61 class EventManager;
62 class ProbeManager;
63 
94 class SimObject : public EventManager, public Serializable, public Drainable
95 {
96  private:
98 
101 
104 
105  protected:
107  const SimObjectParams *_params;
108 
109  public:
110  typedef SimObjectParams Params;
111  const Params *params() const { return _params; }
112  SimObject(const Params *_params);
113  virtual ~SimObject();
114 
115  public:
116 
117  virtual const std::string name() const { return params()->name; }
118 
125  virtual void init();
126 
138  virtual void loadState(CheckpointIn &cp);
139 
145  virtual void initState();
146 
150  virtual void regStats();
151 
155  virtual void resetStats();
156 
160  virtual void regProbePoints();
161 
165  virtual void regProbeListeners();
166 
171 
178  virtual void startup();
179 
184  DrainState drain() override { return DrainState::Drained; }
185 
194  virtual void memWriteback() {};
195 
207  virtual void memInvalidate() {};
208 
209  void serialize(CheckpointOut &cp) const override {};
210  void unserialize(CheckpointIn &cp) override {};
211 
215  static void serializeAll(CheckpointOut &cp);
216 
217 #ifdef DEBUG
218  public:
219  bool doDebugBreak;
220  static void debugObjectBreak(const std::string &objs);
221 #endif
222 
228  static SimObject *find(const char *name);
229 };
230 
238 {
239  public:
240  virtual ~SimObjectResolver() { }
241 
242  // Find a SimObject given a full path name
243  virtual SimObject *resolveSimObject(const std::string &name) = 0;
244 };
245 
246 #ifdef DEBUG
247 void debugObjectBreak(const char *objs);
248 #endif
249 
250 #endif // __SIM_OBJECT_HH__
virtual void memWriteback()
Write back dirty buffers to memory using functional writes.
Definition: sim_object.hh:194
virtual void resetStats()
Reset statistics associated with this object.
Definition: sim_object.cc:110
const std::string & name()
Definition: trace.cc:49
DrainState
Object drain/handover states.
Definition: drain.hh:71
SimObjectParams Params
Definition: sim_object.hh:110
static void serializeAll(CheckpointOut &cp)
Serialize all SimObjects in the system.
Definition: sim_object.cc:140
const Params * params() const
Definition: sim_object.hh:111
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Definition: probe.hh:152
virtual void regStats()
Register statistics for this object.
Definition: sim_object.cc:105
virtual ~SimObjectResolver()
Definition: sim_object.hh:240
Base class to wrap object resolving functionality.
Definition: sim_object.hh:237
STL vector class.
Definition: stl.hh:40
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:223
virtual SimObject * resolveSimObject(const std::string &name)=0
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: sim_object.cc:74
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: sim_object.hh:209
static SimObjectList simObjectList
List of all instantiated simulation objects.
Definition: sim_object.hh:100
virtual void memInvalidate()
Invalidate the contents of memory buffers.
Definition: sim_object.hh:207
ProbeManager * probeManager
Manager coordinates hooking up probe points with listeners.
Definition: sim_object.hh:103
SimObject(const Params *_params)
Definition: sim_object.cc:58
virtual void regProbePoints()
Register probe points for this object.
Definition: sim_object.cc:118
virtual void regProbeListeners()
Register probe listeners for this object.
Definition: sim_object.cc:126
Draining buffers pending serialization/handover.
std::vector< SimObject * > SimObjectList
Definition: sim_object.hh:97
Basic support for object serialization.
Definition: serialize.hh:220
static SimObject * find(const char *name)
Find the SimObject with the given name and return a pointer to it.
Definition: sim_object.cc:179
virtual const std::string name() const
Definition: sim_object.hh:117
std::ostream CheckpointOut
Definition: serialize.hh:67
ProbeManager * getProbeManager()
Get the probe manager for this object.
Definition: sim_object.cc:131
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:107
DrainState drain() override
Provide a default implementation of the drain interface for objects that don't need draining...
Definition: sim_object.hh:184
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: sim_object.hh:210
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: sim_object.cc:92
virtual ~SimObject()
Definition: sim_object.cc:68
Abstract superclass for simulation objects.
Definition: sim_object.hh:94
virtual void loadState(CheckpointIn &cp)
loadState() is called on each SimObject when restoring from a checkpoint.
Definition: sim_object.cc:79
virtual void startup()
startup() is the final initialization call before simulation.
Definition: sim_object.cc:97

Generated on Fri Jun 9 2017 13:03:51 for gem5 by doxygen 1.8.6