]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/hpet.c
xnu-1228.7.58.tar.gz
[apple/xnu.git] / osfmk / i386 / hpet.c
index 52c70d903079b8131928214473641bca8a339ba7..940a7c649fd62944bbf8641acc86a3968470b768 100644 (file)
@@ -133,6 +133,26 @@ hpet_request(uint32_t cpu)
        return(-1);
     }
 
+    /*
+     * Deal with the case where the CPU # passed in is past the
+     * value specified in cpus=n in boot-args.
+     */
+    if (cpu >= real_ncpus) {
+       enabled = ml_set_interrupts_enabled(FALSE);
+       lcpu = cpu_to_lcpu(cpu);
+       if (lcpu != NULL) {
+           core = lcpu->core;
+           pkg  = core->package;
+
+           if (lcpu->primary) {
+               pkg->flags |= X86PKG_FL_HAS_HPET;
+           }
+       }
+
+       ml_set_interrupts_enabled(enabled);
+       return(0);
+    }
+
     rc = (*hpet_req)(ml_get_apicid(cpu), hpet_arg, &hpetReq);
     if (rc != 0) {
        return(rc);
@@ -280,24 +300,6 @@ hpet_init(void)
        DBG(" CVT: HPET to BUS = %08X.%08X\n",
            (uint32_t)(hpet2bus >> 32), (uint32_t)hpet2bus);
 
-       /* Make sure the counter is off in the HPET configuration flags */
-       uint64_t hpetcon = ((hpetReg_t *)hpetArea)->GEN_CONF;
-       hpetcon = hpetcon & ~1;
-       ((hpetReg_t *)hpetArea)->GEN_CONF = hpetcon;
-
-       /*
-        * Convert current TSC to HPET value,
-        * set it, and start it ticking.
-        */
-       uint64_t currtsc = rdtsc64();
-       uint64_t tscInHPET = tmrCvt(currtsc, tsc2hpet);
-       ((hpetReg_t *)hpetArea)->MAIN_CNT = tscInHPET;
-       hpetcon = hpetcon | 1;
-       ((hpetReg_t *)hpetArea)->GEN_CONF = hpetcon;
-       kprintf("HPET started: TSC = %08X.%08X, HPET = %08X.%08X\n", 
-               (uint32_t)(currtsc >> 32), (uint32_t)currtsc,
-               (uint32_t)(tscInHPET >> 32), (uint32_t)tscInHPET);
-
 #if MACH_KDB
        db_display_hpet((hpetReg_t *)hpetArea); /* (BRINGUP) */
 #endif
@@ -317,8 +319,13 @@ hpet_get_info(hpetInfo_t *info)
     info->hpet2tsc   = hpet2tsc;
     info->bus2hpet   = bus2hpet;
     info->hpet2bus   = hpet2bus;
-    info->rcbaArea   = rcbaArea;
-    info->rcbaAreap  = rcbaAreap;
+    /*
+     * XXX
+     * We're repurposing the rcbaArea so we can use the HPET.
+     * Eventually we'll rename this correctly.
+     */
+    info->rcbaArea   = hpetArea;
+    info->rcbaAreap  = hpetAreap;
 }