From 4ae02295d59036fa2f9d272ee288e0321bb8257a Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Mon, 7 Jan 2013 13:05:44 -0500 Subject: cpu: Unify SimpleCPU and O3 CPU serialization code The O3 CPU used to copy its thread context to a SimpleThread in order to do serialization. This was a bit of a hack involving two static SimpleThread instances and a magic constructor that was only used by the O3 CPU. This patch moves the ThreadContext serialization code into two global procedures that, in addition to the normal serialization parameters, take a ThreadContext reference as a parameter. This allows us to reuse the serialization code in all ThreadContext implementations. --- src/cpu/o3/thread_state.hh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/cpu/o3/thread_state.hh') diff --git a/src/cpu/o3/thread_state.hh b/src/cpu/o3/thread_state.hh index 96ccfc95c..406c798f0 100644 --- a/src/cpu/o3/thread_state.hh +++ b/src/cpu/o3/thread_state.hh @@ -1,4 +1,16 @@ /* + * 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. * @@ -99,6 +111,27 @@ struct O3ThreadState : public ThreadState { 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; -- cgit v1.2.3