summaryrefslogtreecommitdiff
path: root/src/arch/x86/utility.hh
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas@sandberg.pp.se>2013-06-18 16:10:22 +0200
committerAndreas Sandberg <andreas@sandberg.pp.se>2013-06-18 16:10:22 +0200
commit46a8cbbb7f55e92943cc26266edd98c774edadac (patch)
treeb43adf8ac01539ffbae37748f298e638ee6fe1b8 /src/arch/x86/utility.hh
parentde89e133d8a3f92d9f2f99d0d8bcca50e9da6cb4 (diff)
downloadgem5-46a8cbbb7f55e92943cc26266edd98c774edadac.tar.xz
x86: Add helper functions to access rflags
The rflags register is spread across several different registers. Most of the flags are stored in MISCREG_RFLAGS, but some are stored in microcode registers. When accessing RFLAGS, we need to reconstruct it from these registers. This changeset adds two functions, X86ISA::getRFlags() and X86ISA::setRFlags(), that take care of this magic.
Diffstat (limited to 'src/arch/x86/utility.hh')
-rw-r--r--src/arch/x86/utility.hh29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/arch/x86/utility.hh b/src/arch/x86/utility.hh
index f3b0d3fa1..6fc802f2f 100644
--- a/src/arch/x86/utility.hh
+++ b/src/arch/x86/utility.hh
@@ -105,6 +105,35 @@ namespace X86ISA
return 0;
}
+
+ /**
+ * Reconstruct the rflags register from the internal gem5 register
+ * state.
+ *
+ * gem5 stores rflags in several different registers to avoid
+ * pipeline dependencies. In order to get the true rflags value,
+ * we can't simply read the value of MISCREG_RFLAGS. Instead, we
+ * need to read out various state from microcode registers and
+ * merge that with MISCREG_RFLAGS.
+ *
+ * @param tc Thread context to read rflags from.
+ * @return rflags as seen by the guest.
+ */
+ uint64_t getRFlags(ThreadContext *tc);
+
+ /**
+ * Set update the rflags register and internal gem5 state.
+ *
+ * @note This function does not update MISCREG_M5_REG. You might
+ * need to update this register by writing anything to
+ * MISCREG_M5_REG with side-effects.
+ *
+ * @see X86ISA::getRFlags()
+ *
+ * @param tc Thread context to update
+ * @param val New rflags value to store in TC
+ */
+ void setRFlags(ThreadContext *tc, uint64_t val);
}
#endif // __ARCH_X86_UTILITY_HH__