From 009970f59b86eac6c9a35eeb175dd9e3a3079d13 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Mon, 7 Jan 2013 13:05:52 -0500 Subject: cpu: Unify the serialization code for all of the CPU models Cleanup the serialization code for the simple CPUs and the O3 CPU. The CPU-specific code has been replaced with a (un)serializeThread that serializes the thread state / context of a specific thread. Assuming that the thread state class uses the CPU-specific thread state uses the base thread state serialization code, this allows us to restore a checkpoint with any of the CPU models. --- src/cpu/o3/cpu.cc | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'src/cpu/o3/cpu.cc') diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc index cb17581e5..18c536090 100644 --- a/src/cpu/o3/cpu.cc +++ b/src/cpu/o3/cpu.cc @@ -1094,35 +1094,17 @@ FullO3CPU::syscall(int64_t callnum, ThreadID tid) template void -FullO3CPU::serialize(std::ostream &os) +FullO3CPU::serializeThread(std::ostream &os, ThreadID tid) { - Drainable::State so_state(getDrainState()); - SERIALIZE_ENUM(so_state); - BaseCPU::serialize(os); - nameOut(os, csprintf("%s.tickEvent", name())); - tickEvent.serialize(os); - - for (ThreadID i = 0; i < thread.size(); i++) { - nameOut(os, csprintf("%s.xc.%i", name(), i)); - thread[i]->serialize(os); - } + thread[tid]->serialize(os); } template void -FullO3CPU::unserialize(Checkpoint *cp, const std::string §ion) +FullO3CPU::unserializeThread(Checkpoint *cp, const std::string §ion, + ThreadID tid) { - Drainable::State so_state; - UNSERIALIZE_ENUM(so_state); - BaseCPU::unserialize(cp, section); - tickEvent.unserialize(cp, csprintf("%s.tickEvent", section)); - - 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); - } + thread[tid]->unserialize(cp, section); } template -- cgit v1.2.3