mem-cache: Add multiple eviction stats
[gem5.git] / src / arch / x86 / cpuid.cc
index f06ba04d87deda6d95cc1cde5b1d49d26bf1f324..e6a898a08c270654d64fec9065531da56ef5a89c 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include "arch/x86/cpuid.hh"
+
 #include "base/bitfield.hh"
 #include "cpu/thread_context.hh"
 
@@ -36,6 +37,12 @@ namespace X86ISA {
     enum StandardCpuidFunction {
         VendorAndLargestStdFunc,
         FamilyModelStepping,
+        CacheAndTLB,
+        SerialNumber,
+        CacheParams,
+        MonitorMwait,
+        ThermalPowerMgmt,
+        ExtendedFeatures,
         NumStandardCpuidFuncs
     };
 
@@ -48,12 +55,12 @@ namespace X86ISA {
         L1CacheAndTLB,
         L2L3CacheAndL2TLB,
         APMInfo,
+        LongModeAddressSize,
+
         /*
          * The following are defined by the spec but not yet implemented
          */
-/*      LongModeAddressSize,
-        // Function 9 is reserved
+/*      // Function 9 is reserved
         SVMInfo = 10,
         // Functions 11-24 are reserved
         TLB1GBPageInfo = 25,
@@ -79,7 +86,8 @@ namespace X86ISA {
     }
 
     bool
-    doCpuid(ThreadContext * tc, uint32_t function, CpuidResult &result)
+    doCpuid(ThreadContext * tc, uint32_t function,
+            uint32_t index, CpuidResult &result)
     {
         uint16_t family = bits(function, 31, 16);
         uint16_t funcNum = bits(function, 15, 0);
@@ -89,7 +97,7 @@ namespace X86ISA {
               case VendorAndLargestExtFunc:
                 assert(vendorStringSize >= 12);
                 result = CpuidResult(
-                        NumExtendedCpuidFuncs - 1,
+                        0x80000000 + NumExtendedCpuidFuncs - 1,
                         stringToRegister(vendorString),
                         stringToRegister(vendorString + 4),
                         stringToRegister(vendorString + 8));
@@ -113,8 +121,8 @@ namespace X86ISA {
                     result = CpuidResult(
                             stringToRegister(cleanName + offset + 0),
                             stringToRegister(cleanName + offset + 4),
-                            stringToRegister(cleanName + offset + 8),
-                            stringToRegister(cleanName + offset + 12));
+                            stringToRegister(cleanName + offset + 12),
+                            stringToRegister(cleanName + offset + 8));
                 }
                 break;
               case L1CacheAndTLB:
@@ -129,14 +137,19 @@ namespace X86ISA {
                 result = CpuidResult(0x80000018, 0x68747541,
                                      0x69746e65, 0x444d4163);
                 break;
-/*            case LongModeAddressSize:
-              case SVMInfo:
+              case LongModeAddressSize:
+                result = CpuidResult(0x00003030, 0x00000000,
+                                     0x00000000, 0x00000000);
+                break;
+/*            case SVMInfo:
               case TLB1GBPageInfo:
               case PerformanceInfo:*/
               default:
+                warn("x86 cpuid family 0x8000: unimplemented function %u",
+                    funcNum);
                 return false;
             }
-        } else if(family == 0x0000) {
+        } else if (family == 0x0000) {
             // The standard functions
             switch (funcNum) {
               case VendorAndLargestStdFunc:
@@ -148,13 +161,23 @@ namespace X86ISA {
                         stringToRegister(vendorString + 8));
                 break;
               case FamilyModelStepping:
-                result = CpuidResult(0x00020f51, 0000000405,
-                                     0xe3d3fbff, 0x00000001);
+                result = CpuidResult(0x00020f51, 0x00000805,
+                                     0xe7dbfbff, 0x00000209);
+                break;
+              case ExtendedFeatures:
+                result = CpuidResult(0x00000000, 0x01800000,
+                                     0x00000000, 0x00000000);
                 break;
               default:
+                warn("x86 cpuid family 0x0000: unimplemented function %u",
+                    funcNum);
                 return false;
             }
+        } else {
+            warn("x86 cpuid: unknown family %#x", family);
+            return false;
         }
+
         return true;
     }
-} //namespace X86ISA
+} // namespace X86ISA