From e2dad8236a95b5d7b1c1470385d0b543d3c7af4a Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Mon, 7 Jan 2013 13:05:44 -0500 Subject: cpu: Implement a flat register interface in thread contexts Some architectures map registers differently depending on their mode of operations. There is currently no architecture independent way of accessing all registers. This patch introduces a flat register interface to the ThreadContext class. This interface is useful, for example, when serializing or copying thread contexts. --- src/cpu/thread_context.hh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/cpu/thread_context.hh') diff --git a/src/cpu/thread_context.hh b/src/cpu/thread_context.hh index e16bc3b39..611924371 100644 --- a/src/cpu/thread_context.hh +++ b/src/cpu/thread_context.hh @@ -264,6 +264,30 @@ class ThreadContext /** function to compare two thread contexts (for debugging) */ static void compare(ThreadContext *one, ThreadContext *two); + + /** @{ */ + /** + * Flat register interfaces + * + * Some architectures have different registers visible in + * different modes. Such architectures "flatten" a register (see + * flattenIntIndex() and flattenFloatIndex()) to map it into the + * gem5 register file. This interface provides a flat interface to + * the underlying register file, which allows for example + * serialization code to access all registers. + */ + + virtual uint64_t readIntRegFlat(int idx) = 0; + virtual void setIntRegFlat(int idx, uint64_t val) = 0; + + virtual FloatReg readFloatRegFlat(int idx) = 0; + virtual void setFloatRegFlat(int idx, FloatReg val) = 0; + + virtual FloatRegBits readFloatRegBitsFlat(int idx) = 0; + virtual void setFloatRegBitsFlat(int idx, FloatRegBits val) = 0; + + /** @} */ + }; /** @@ -429,6 +453,24 @@ class ProxyThreadContext : public ThreadContext { actualTC->syscall(callnum); } Counter readFuncExeInst() { return actualTC->readFuncExeInst(); } + + uint64_t readIntRegFlat(int idx) + { return actualTC->readIntRegFlat(idx); } + + void setIntRegFlat(int idx, uint64_t val) + { actualTC->setIntRegFlat(idx, val); } + + FloatReg readFloatRegFlat(int idx) + { return actualTC->readFloatRegFlat(idx); } + + void setFloatRegFlat(int idx, FloatReg val) + { actualTC->setFloatRegFlat(idx, val); } + + FloatRegBits readFloatRegBitsFlat(int idx) + { return actualTC->readFloatRegBitsFlat(idx); } + + void setFloatRegBitsFlat(int idx, FloatRegBits val) + { actualTC->setFloatRegBitsFlat(idx, val); } }; #endif -- cgit v1.2.3