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/thread_context.hh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/cpu/thread_context.hh') diff --git a/src/cpu/thread_context.hh b/src/cpu/thread_context.hh index 611924371..c54076c8a 100644 --- a/src/cpu/thread_context.hh +++ b/src/cpu/thread_context.hh @@ -1,5 +1,5 @@ /* - * 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 @@ -177,9 +177,6 @@ class ThreadContext 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... @@ -369,10 +366,6 @@ class ProxyThreadContext : public ThreadContext 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(); } @@ -473,4 +466,19 @@ class ProxyThreadContext : public ThreadContext { 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 -- cgit v1.2.3