+ rval = 1;
+ (void) ml_set_interrupts_enabled(FALSE);
+ break;
+
+ case dgPowerStat:
+ {
+ uint32_t c2l = 0, c2h = 0, c3l = 0, c3h = 0, c6l = 0, c6h = 0, c7l = 0, c7h = 0;
+ uint32_t pkg_unit_l = 0, pkg_unit_h = 0, pkg_ecl = 0, pkg_ech = 0;
+
+ pkg_energy_statistics_t pkes;
+ core_energy_stat_t cest;
+
+ bzero(&pkes, sizeof(pkes));
+ bzero(&cest, sizeof(cest));
+
+ pkes.pkes_version = 1ULL;
+ rdmsr_carefully(MSR_IA32_PKG_C2_RESIDENCY, &c2l, &c2h);
+ rdmsr_carefully(MSR_IA32_PKG_C3_RESIDENCY, &c3l, &c3h);
+ rdmsr_carefully(MSR_IA32_PKG_C6_RESIDENCY, &c6l, &c6h);
+ rdmsr_carefully(MSR_IA32_PKG_C7_RESIDENCY, &c7l, &c7h);
+
+ pkes.pkg_cres[0][0] = ((uint64_t)c2h << 32) | c2l;
+ pkes.pkg_cres[0][1] = ((uint64_t)c3h << 32) | c3l;
+ pkes.pkg_cres[0][2] = ((uint64_t)c6h << 32) | c6l;
+ pkes.pkg_cres[0][3] = ((uint64_t)c7h << 32) | c7l;
+
+ uint64_t c8r = ~0ULL, c9r = ~0ULL, c10r = ~0ULL;
+
+ rdmsr64_carefully(MSR_IA32_PKG_C8_RESIDENCY, &c8r);
+ rdmsr64_carefully(MSR_IA32_PKG_C9_RESIDENCY, &c9r);
+ rdmsr64_carefully(MSR_IA32_PKG_C10_RESIDENCY, &c10r);
+
+ pkes.pkg_cres[0][4] = c8r;
+ pkes.pkg_cres[0][5] = c9r;
+ pkes.pkg_cres[0][6] = c10r;
+
+ pkes.ddr_energy = ~0ULL;
+ rdmsr64_carefully(MSR_IA32_DDR_ENERGY_STATUS, &pkes.ddr_energy);
+ pkes.llc_flushed_cycles = ~0ULL;
+ rdmsr64_carefully(MSR_IA32_LLC_FLUSHED_RESIDENCY_TIMER, &pkes.llc_flushed_cycles);
+
+ pkes.ring_ratio_instantaneous = ~0ULL;
+ rdmsr64_carefully(MSR_IA32_RING_PERF_STATUS, &pkes.ring_ratio_instantaneous);
+
+ pkes.IA_frequency_clipping_cause = ~0ULL;
+
+ uint32_t ia_perf_limits = MSR_IA32_IA_PERF_LIMIT_REASONS;
+ /* Should perhaps be a generic register map module for these
+ * registers with identical functionality that were renumbered.
+ */
+ switch (cpuid_cpufamily()) {
+ case CPUFAMILY_INTEL_SKYLAKE:
+ case CPUFAMILY_INTEL_KABYLAKE:
+ ia_perf_limits = MSR_IA32_IA_PERF_LIMIT_REASONS_SKL;
+ break;
+ default:
+ break;
+ }
+
+ rdmsr64_carefully(ia_perf_limits, &pkes.IA_frequency_clipping_cause);
+
+ pkes.GT_frequency_clipping_cause = ~0ULL;
+ rdmsr64_carefully(MSR_IA32_GT_PERF_LIMIT_REASONS, &pkes.GT_frequency_clipping_cause);