cpu: Add HTM Instruction Flags
[gem5.git] / src / sim / sim_object.cc
index 503ac56502ee6599449f00bf3a3c8ad521c06bab..7a4b24e7a943f9e600c391b928e0bbf508c39b9e 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2001-2005 The Regents of The University of Michigan
+ * Copyright (c) 2010 Advanced Micro Devices, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * 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
  */
 
-#include <cassert>
+#include "sim/sim_object.hh"
 
-#include "base/callback.hh"
-#include "base/inifile.hh"
+#include "base/logging.hh"
 #include "base/match.hh"
-#include "base/misc.hh"
 #include "base/trace.hh"
-#include "base/types.hh"
-#include "sim/sim_object.hh"
-#include "sim/stats.hh"
+#include "debug/Checkpoint.hh"
+#include "sim/probe/probe.hh"
 
 using namespace std;
 
@@ -58,14 +53,20 @@ SimObject::SimObjectList SimObject::simObjectList;
 // SimObject constructor: used to maintain static simObjectList
 //
 SimObject::SimObject(const Params *p)
-    : EventManager(p->eventq), _params(p)
+    : EventManager(getEventQueue(p->eventq_index)),
+      Stats::Group(nullptr),
+      _params(p)
 {
 #ifdef DEBUG
     doDebugBreak = false;
 #endif
-
     simObjectList.push_back(this);
-    state = Running;
+    probeManager = new ProbeManager(this);
+}
+
+SimObject::~SimObject()
+{
+    delete probeManager;
 }
 
 void
@@ -74,10 +75,16 @@ SimObject::init()
 }
 
 void
-SimObject::loadState(Checkpoint *cp)
-{
-    if (cp->sectionExists(name()))
-        unserialize(cp, name());
+SimObject::loadState(CheckpointIn &cp)
+{
+    if (cp.sectionExists(name())) {
+        DPRINTF(Checkpoint, "unserializing\n");
+        // This works despite name() returning a fully qualified name
+        // since we are at the top level.
+        unserializeSection(cp, name());
+    } else {
+        DPRINTF(Checkpoint, "no checkpoint section found\n");
+    }
 }
 
 void
@@ -90,60 +97,52 @@ SimObject::startup()
 {
 }
 
-//
-// no default statistics, so nothing to do in base implementation
-//
+/**
+ * No probe points by default, so do nothing in base.
+ */
 void
-SimObject::regStats()
+SimObject::regProbePoints()
 {
 }
 
+/**
+ * No probe listeners by default, so do nothing in base.
+ */
 void
-SimObject::regFormulas()
+SimObject::regProbeListeners()
 {
 }
 
-void
-SimObject::resetStats()
+ProbeManager *
+SimObject::getProbeManager()
 {
+    return probeManager;
 }
 
-//
-// static function: serialize all SimObjects.
-//
-void
-SimObject::serializeAll(ostream &os)
+Port &
+SimObject::getPort(const std::string &if_name, PortID idx)
 {
-    SimObjectList::reverse_iterator ri = simObjectList.rbegin();
-    SimObjectList::reverse_iterator rend = simObjectList.rend();
-
-    for (; ri != rend; ++ri) {
-        SimObject *obj = *ri;
-        obj->nameOut(os);
-        obj->serialize(os);
-   }
+    fatal("%s does not have any port named %s\n", name(), if_name);
 }
 
+//
+// static function: serialize all SimObjects.
+//
 void
-SimObject::unserializeAll(Checkpoint *cp)
+SimObject::serializeAll(CheckpointOut &cp)
 {
     SimObjectList::reverse_iterator ri = simObjectList.rbegin();
     SimObjectList::reverse_iterator rend = simObjectList.rend();
 
     for (; ri != rend; ++ri) {
         SimObject *obj = *ri;
-        DPRINTFR(Config, "Unserializing '%s'\n",
-                 obj->name());
-        if(cp->sectionExists(obj->name()))
-            obj->unserialize(cp, obj->name());
-        else
-            warn("Not unserializing '%s': no section found in checkpoint.\n",
-                 obj->name());
+        // This works despite name() returning a fully qualified name
+        // since we are at the top level.
+        obj->serializeSection(cp, obj->name());
    }
 }
 
 
-
 #ifdef DEBUG
 //
 // static function: flag which objects should have the debugger break
@@ -168,38 +167,6 @@ debugObjectBreak(const char *objs)
 }
 #endif
 
-unsigned int
-SimObject::drain(Event *drain_event)
-{
-    state = Drained;
-    return 0;
-}
-
-void
-SimObject::resume()
-{
-    state = Running;
-}
-
-void
-SimObject::setMemoryMode(State new_mode)
-{
-    panic("setMemoryMode() should only be called on systems");
-}
-
-void
-SimObject::switchOut()
-{
-    panic("Unimplemented!");
-}
-
-void
-SimObject::takeOverFrom(BaseCPU *cpu)
-{
-    panic("Unimplemented!");
-}
-
-
 SimObject *
 SimObject::find(const char *name)
 {