]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/pmCPU.c
xnu-1504.3.12.tar.gz
[apple/xnu.git] / osfmk / i386 / pmCPU.c
index e3142fe4caec7f99044b42fc1985a212f0f68fc4..0efbb917c4609c40fa58e420d71e24afee2cda19 100644 (file)
@@ -41,6 +41,7 @@
 #include <kern/machine.h>
 #include <kern/pms.h>
 #include <kern/processor.h>
+#include <kern/etimer.h>
 #include <i386/cpu_threads.h>
 #include <i386/pmCPU.h>
 #include <i386/cpuid.h>
@@ -112,8 +113,8 @@ machine_idle(void)
 
     if (pmInitDone
        && pmDispatch != NULL
-       && pmDispatch->cstateMachineIdle != NULL)
-       (*pmDispatch->cstateMachineIdle)(0x7FFFFFFFFFFFFFFFULL);
+       && pmDispatch->MachineIdle != NULL)
+       (*pmDispatch->MachineIdle)(0x7FFFFFFFFFFFFFFFULL);
     else {
        /*
         * If no power management, re-enable interrupts and halt.
@@ -561,8 +562,10 @@ machine_run_count(uint32_t count)
 }
 
 boolean_t
-machine_cpu_is_inactive(int cpu)
+machine_processor_is_inactive(processor_t processor)
 {
+    int                cpu = processor->cpu_id;
+
     if (pmDispatch != NULL
        && pmDispatch->pmIsCPUUnAvailable != NULL)
        return(pmDispatch->pmIsCPUUnAvailable(cpu_to_lcpu(cpu)));
@@ -570,6 +573,43 @@ machine_cpu_is_inactive(int cpu)
        return(FALSE);
 }
 
+processor_t
+machine_choose_processor(processor_set_t pset,
+                        processor_t preferred)
+{
+    int                startCPU;
+    int                endCPU;
+    int                preferredCPU;
+    int                chosenCPU;
+
+    if (!pmInitDone)
+       return(preferred);
+
+    if (pset == NULL) {
+       startCPU = -1;
+       endCPU = -1;
+    } else {
+       startCPU = pset->cpu_set_low;
+       endCPU = pset->cpu_set_hi;
+    }
+
+    if (preferred == NULL)
+       preferredCPU = -1;
+    else
+       preferredCPU = preferred->cpu_id;
+
+    if (pmDispatch != NULL
+       && pmDispatch->pmChooseCPU != NULL) {
+       chosenCPU = pmDispatch->pmChooseCPU(startCPU, endCPU, preferredCPU);
+
+       if (chosenCPU == -1)
+           return(NULL);
+       return(cpu_datap(chosenCPU)->cpu_processor);
+    }
+
+    return(preferred);
+}
+
 static uint32_t
 pmGetSavedRunCount(void)
 {
@@ -619,6 +659,12 @@ pmSendIPI(int cpu)
     lapic_send_ipi(cpu, LAPIC_PM_INTERRUPT);
 }
 
+static rtc_nanotime_t *
+pmGetNanotimeInfo(void)
+{
+    return(&rtc_nanotime_info);
+}
+
 /*
  * Called by the power management kext to register itself and to get the
  * callbacks it might need into other kernel functions.  This interface
@@ -648,6 +694,7 @@ pmKextRegister(uint32_t version, pmDispatch_t *cpuFuncs,
        callbacks->ThreadBind           = thread_bind;
        callbacks->GetSavedRunCount     = pmGetSavedRunCount;
        callbacks->pmSendIPI            = pmSendIPI;
+       callbacks->GetNanotimeInfo      = pmGetNanotimeInfo;
        callbacks->topoParms            = &topoParms;
     } else {
        panic("Version mis-match between Kernel and CPU PM");