summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas@sandberg.pp.se>2013-09-18 11:28:28 +0200
committerAndreas Sandberg <andreas@sandberg.pp.se>2013-09-18 11:28:28 +0200
commite93e12a62b1ddadb91214f0a0134e75735194716 (patch)
tree4a220bb67cd01642fdb9a6ad53311784d69b094c
parent4b840b8322f4536a4e0c49c43f999c00fa66a1e9 (diff)
downloadgem5-e93e12a62b1ddadb91214f0a0134e75735194716.tar.xz
x86: Expose the raw hash map of MSRs
This patch allows the KVM CPU module to initialize it's MSRs by enumerating the MSRs in the gem5 x86 implementation.
-rw-r--r--src/arch/x86/regs/msr.cc7
-rw-r--r--src/arch/x86/regs/msr.hh23
2 files changed, 25 insertions, 5 deletions
diff --git a/src/arch/x86/regs/msr.cc b/src/arch/x86/regs/msr.cc
index aeb283aff..462d87e8c 100644
--- a/src/arch/x86/regs/msr.cc
+++ b/src/arch/x86/regs/msr.cc
@@ -29,13 +29,10 @@
*/
#include "arch/x86/regs/msr.hh"
-#include "base/hashmap.hh"
namespace X86ISA
{
-typedef m5::hash_map<Addr, MiscRegIndex> MsrMap;
-
typedef MsrMap::value_type MsrVal;
const MsrMap::value_type msrMapData[] = {
@@ -146,12 +143,12 @@ const MsrMap::value_type msrMapData[] = {
static const unsigned msrMapSize = sizeof(msrMapData) / sizeof(msrMapData[0]);
-static MsrMap msrMap(msrMapData, msrMapData + msrMapSize);
+const MsrMap msrMap(msrMapData, msrMapData + msrMapSize);
bool
msrAddrToIndex(MiscRegIndex &regNum, Addr addr)
{
- MsrMap::iterator it = msrMap.find(addr);
+ MsrMap::const_iterator it(msrMap.find(addr));
if (it == msrMap.end()) {
return false;
} else {
diff --git a/src/arch/x86/regs/msr.hh b/src/arch/x86/regs/msr.hh
index c10c5c203..a2ae5c69a 100644
--- a/src/arch/x86/regs/msr.hh
+++ b/src/arch/x86/regs/msr.hh
@@ -32,11 +32,34 @@
#define __ARCH_X86_REG_MSR_HH__
#include "arch/x86/regs/misc.hh"
+#include "base/hashmap.hh"
#include "base/types.hh"
namespace X86ISA
{
+typedef m5::hash_map<Addr, MiscRegIndex> MsrMap;
+
+/**
+ * Map between MSR addresses and their corresponding misc registers.
+ *
+ * @note This map is usually only used when enumeration of supported
+ * MSRs is needed (e.g., in virtualized CPUs). Code that needs to
+ * look-up specific MSRs should use msrAddrToIndex().
+ */
+extern const MsrMap msrMap;
+
+/**
+ * Find and return the misc reg corresponding to an MSR address.
+ *
+ * Look for an MSR (addr) in #msrMap and return the
+ * corresponding misc reg in regNum. The value of regNum is undefined
+ * if the MSR was not found.
+ *
+ * @param regNum misc reg index (out).
+ * @param addr MSR address
+ * @return True if the MSR was found, false otherwise.
+ */
bool msrAddrToIndex(MiscRegIndex &regNum, Addr addr);
} // namespace X86ISA