}
}
-
-void
-InOrderThreadContext::serialize(std::ostream &os)
-{
- panic("serialize unimplemented");
-}
-
-
-void
-InOrderThreadContext::unserialize(Checkpoint *cp, const std::string §ion)
-{
- panic("unserialize unimplemented");
-}
-
-
void
InOrderThreadContext::copyArchRegs(ThreadContext *src_tc)
{
/** Registers statistics associated with this TC. */
void regStats(const std::string &name);
- /** Serializes state. */
- void serialize(std::ostream &os);
-
- /** Unserializes state. */
- void unserialize(Checkpoint *cp, const std::string §ion);
-
/** Returns this thread's ID number. */
int getThreadNum() { return thread->threadId(); }
nameOut(os, csprintf("%s.tickEvent", name()));
tickEvent.serialize(os);
- // Use SimpleThread's ability to checkpoint to make it easier to
- // write out the registers. Also make this static so it doesn't
- // get instantiated multiple times (causes a panic in statistics).
- static SimpleThread temp;
-
- ThreadID size = thread.size();
- for (ThreadID i = 0; i < size; i++) {
+ for (ThreadID i = 0; i < thread.size(); i++) {
nameOut(os, csprintf("%s.xc.%i", name(), i));
- temp.copyTC(thread[i]->getTC());
- temp.serialize(os);
+ thread[i]->serialize(os);
}
}
BaseCPU::unserialize(cp, section);
tickEvent.unserialize(cp, csprintf("%s.tickEvent", section));
- // Use SimpleThread's ability to checkpoint to make it easier to
- // read in the registers. Also make this static so it doesn't
- // get instantiated multiple times (causes a panic in statistics).
- static SimpleThread temp;
-
- ThreadID size = thread.size();
- for (ThreadID i = 0; i < size; i++) {
- temp.copyTC(thread[i]->getTC());
- temp.unserialize(cp, csprintf("%s.xc.%i", section, i));
- thread[i]->getTC()->copyArchRegs(temp.getTC());
+ for (ThreadID i = 0; i < thread.size(); i++) {
+ thread[i]->unserialize(cp,
+ csprintf("%s.xc.%i", section, i));
+ if (thread[i]->status() == ThreadContext::Active)
+ activateThread(i);
}
}
/** Registers statistics associated with this TC. */
virtual void regStats(const std::string &name);
- /** Serializes state. */
- virtual void serialize(std::ostream &os);
- /** Unserializes state. */
- virtual void unserialize(Checkpoint *cp, const std::string §ion);
-
/** Reads the last tick that this thread was activated on. */
virtual Tick readLastActivate();
/** Reads the last tick that this thread was suspended on. */
}
}
-template <class Impl>
-void
-O3ThreadContext<Impl>::serialize(std::ostream &os)
-{
- if (FullSystem && thread->kernelStats)
- thread->kernelStats->serialize(os);
-}
-
-template <class Impl>
-void
-O3ThreadContext<Impl>::unserialize(Checkpoint *cp, const std::string §ion)
-{
- if (FullSystem && thread->kernelStats)
- thread->kernelStats->unserialize(cp, section);
-}
-
template <class Impl>
Tick
O3ThreadContext<Impl>::readLastActivate()
/*
+ * Copyright (c) 2012 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
profilePC = 3;
}
+ void serialize(std::ostream &os)
+ {
+ ThreadState::serialize(os);
+ // Use the ThreadContext serialization helper to serialize the
+ // TC.
+ ::serialize(*tc, os);
+ }
+
+ void unserialize(Checkpoint *cp, const std::string §ion)
+ {
+ // Prevent squashing - we don't have any instructions in
+ // flight that we need to squash since we just instantiated a
+ // clean system.
+ noSquashFromTC = true;
+ ThreadState::unserialize(cp, section);
+ // Use the ThreadContext serialization helper to unserialize
+ // the TC.
+ ::unserialize(*tc, cp, section);
+ noSquashFromTC = false;
+ }
+
/** Pointer to the ThreadContext of this thread. */
ThreadContext *tc;
kernelStats = new TheISA::Kernel::Statistics(system);
}
-SimpleThread::SimpleThread()
- : ThreadState(NULL, -1, NULL), isa(NULL)
-{
- tc = new ProxyThreadContext<SimpleThread>(this);
-}
-
SimpleThread::~SimpleThread()
{
delete tc;
SimpleThread::serialize(ostream &os)
{
ThreadState::serialize(os);
- SERIALIZE_ARRAY(floatRegs.i, TheISA::NumFloatRegs);
- SERIALIZE_ARRAY(intRegs, TheISA::NumIntRegs);
- _pcState.serialize(os);
- // thread_num and cpu_id are deterministic from the config
+ ::serialize(*tc, os);
}
SimpleThread::unserialize(Checkpoint *cp, const std::string §ion)
{
ThreadState::unserialize(cp, section);
- UNSERIALIZE_ARRAY(floatRegs.i, TheISA::NumFloatRegs);
- UNSERIALIZE_ARRAY(intRegs, TheISA::NumIntRegs);
- _pcState.unserialize(cp, section);
- // thread_num and cpu_id are deterministic from the config
+ ::unserialize(*tc, cp, section);
}
void
Process *_process, TheISA::TLB *_itb, TheISA::TLB *_dtb,
TheISA::ISA *_isa);
- SimpleThread();
-
virtual ~SimpleThread();
virtual void takeOverFrom(ThreadContext *oldContext);
/*
+ * Copyright (c) 2012 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
}
+
+void
+serialize(ThreadContext &tc, std::ostream &os)
+{
+ using namespace TheISA;
+
+ FloatRegBits floatRegs[NumFloatRegs];
+ for (int i = 0; i < NumFloatRegs; ++i)
+ floatRegs[i] = tc.readFloatRegBitsFlat(i);
+ // This is a bit ugly, but needed to maintain backwards
+ // compatibility.
+ arrayParamOut(os, "floatRegs.i", floatRegs, NumFloatRegs);
+
+ IntReg intRegs[NumIntRegs];
+ for (int i = 0; i < NumIntRegs; ++i)
+ intRegs[i] = tc.readIntRegFlat(i);
+ SERIALIZE_ARRAY(intRegs, NumIntRegs);
+
+ tc.pcState().serialize(os);
+
+ // thread_num and cpu_id are deterministic from the config
+}
+
+void
+unserialize(ThreadContext &tc, Checkpoint *cp, const std::string §ion)
+{
+ using namespace TheISA;
+
+ FloatRegBits floatRegs[NumFloatRegs];
+ // This is a bit ugly, but needed to maintain backwards
+ // compatibility.
+ arrayParamIn(cp, section, "floatRegs.i", floatRegs, NumFloatRegs);
+ for (int i = 0; i < NumFloatRegs; ++i)
+ tc.setFloatRegBitsFlat(i, floatRegs[i]);
+
+ IntReg intRegs[NumIntRegs];
+ UNSERIALIZE_ARRAY(intRegs, NumIntRegs);
+ for (int i = 0; i < NumIntRegs; ++i)
+ tc.setIntRegFlat(i, intRegs[i]);
+
+ PCState pcState;
+ pcState.unserialize(cp, section);
+ tc.pcState(pcState);
+
+ // thread_num and cpu_id are deterministic from the config
+}
/*
- * Copyright (c) 2011 ARM Limited
+ * Copyright (c) 2011-2012 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
virtual void regStats(const std::string &name) = 0;
- virtual void serialize(std::ostream &os) = 0;
- virtual void unserialize(Checkpoint *cp, const std::string §ion) = 0;
-
virtual EndQuiesceEvent *getQuiesceEvent() = 0;
// Not necessarily the best location for these...
void regStats(const std::string &name) { actualTC->regStats(name); }
- void serialize(std::ostream &os) { actualTC->serialize(os); }
- void unserialize(Checkpoint *cp, const std::string §ion)
- { actualTC->unserialize(cp, section); }
-
EndQuiesceEvent *getQuiesceEvent() { return actualTC->getQuiesceEvent(); }
Tick readLastActivate() { return actualTC->readLastActivate(); }
{ actualTC->setFloatRegBitsFlat(idx, val); }
};
+/** @{ */
+/**
+ * Thread context serialization helpers
+ *
+ * These helper functions provide a way to the data in a
+ * ThreadContext. They are provided as separate helper function since
+ * implementing them as members of the ThreadContext interface would
+ * be confusing when the ThreadContext is exported via a proxy.
+ */
+
+void serialize(ThreadContext &tc, std::ostream &os);
+void unserialize(ThreadContext &tc, Checkpoint *cp, const std::string §ion);
+
+/** @} */
+
#endif