* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Steve Reinhardt
- * Nathan Binkert
*/
/* @file
#ifndef __SIM_OBJECT_HH__
#define __SIM_OBJECT_HH__
-#include <iostream>
-#include <list>
-#include <map>
#include <string>
#include <vector>
-#include "enums/MemoryMode.hh"
+#include "base/stats/group.hh"
#include "params/SimObject.hh"
#include "sim/drain.hh"
+#include "sim/eventq.hh"
#include "sim/eventq_impl.hh"
+#include "sim/port.hh"
#include "sim/serialize.hh"
-class BaseCPU;
-class Event;
+class EventManager;
class ProbeManager;
+
/**
* Abstract superclass for simulation objects. Represents things that
* correspond to physical components and can be specified via the
* SimObject.py). This has the effect of calling the method on the
* parent node <i>before</i> its children.
*/
-class SimObject : public EventManager, public Serializable, public Drainable
+class SimObject : public EventManager, public Serializable, public Drainable,
+ public Stats::Group
{
private:
typedef std::vector<SimObject *> SimObjectList;
*/
virtual void initState();
- /**
- * Register statistics for this object.
- */
- virtual void regStats();
-
- /**
- * Reset statistics associated with this object.
- */
- virtual void resetStats();
-
/**
* Register probe points for this object.
*/
*/
ProbeManager *getProbeManager();
+ /**
+ * Get a port with a given name and index. This is used at binding time
+ * and returns a reference to a protocol-agnostic port.
+ *
+ * @param if_name Port name
+ * @param idx Index in the case of a VectorPort
+ *
+ * @return A reference to the given port
+ */
+ virtual Port &getPort(const std::string &if_name,
+ PortID idx=InvalidPortID);
+
/**
* startup() is the final initialization call before simulation.
* All state is initialized (including unserialized state, if any,
virtual void startup();
/**
- * Provide a default implementation of the drain interface that
- * simply returns 0 (draining completed) and sets the drain state
- * to Drained.
+ * Provide a default implementation of the drain interface for
+ * objects that don't need draining.
*/
- unsigned int drain(DrainManager *drainManger);
+ DrainState drain() override { return DrainState::Drained; }
/**
* Write back dirty buffers to memory using functional writes.
*/
virtual void memInvalidate() {};
- void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE {};
- void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE {};
+ void serialize(CheckpointOut &cp) const override {};
+ void unserialize(CheckpointIn &cp) override {};
/**
* Serialize all SimObjects in the system.
static SimObject *find(const char *name);
};
+/**
+ * Base class to wrap object resolving functionality.
+ *
+ * This can be provided to the serialization framework to allow it to
+ * map object names onto C++ objects.
+ */
+class SimObjectResolver
+{
+ public:
+ virtual ~SimObjectResolver() { }
+
+ // Find a SimObject given a full path name
+ virtual SimObject *resolveSimObject(const std::string &name) = 0;
+};
+
#ifdef DEBUG
void debugObjectBreak(const char *objs);
#endif