More clock cleanup:
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 17 May 2009 05:11:50 +0000 (13:11 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 17 May 2009 08:20:54 +0000 (16:20 +0800)
- Move rtc initialization to SI_BOOT2_CLOCKREG, SI_ORDER_FIRST
- Staticize cpu_initclocks()

sys/platform/pc32/isa/clock.c
sys/platform/vkernel/platform/systimer.c
sys/sys/systm.h

index c608039..446e3f8 100644 (file)
@@ -1004,6 +1004,52 @@ resettodr(void)
        crit_exit();
 }
 
+static void
+cpu_initclocks(void)
+{
+       callout_init(&sysbeepstop_ch);
+
+       if (statclock_disable) {
+               /*
+                * The stat interrupt mask is different without the
+                * statistics clock.  Also, don't set the interrupt
+                * flag which would normally cause the RTC to generate
+                * interrupts.
+                */
+               rtc_statusb = RTCSB_24HR;
+       } else {
+               /* Setting stathz to nonzero early helps avoid races. */
+               stathz = RTC_NOPROFRATE;
+               profhz = RTC_PROFRATE;
+       }
+
+       /* Initialize RTC. */
+       writertc(RTC_STATUSA, rtc_statusa);
+       writertc(RTC_STATUSB, RTCSB_24HR);
+
+       if (statclock_disable == 0) {
+               int diag;
+
+               diag = rtcin(RTC_DIAG);
+               if (diag != 0) {
+                       kprintf("RTC BIOS diagnostic error %b\n",
+                               diag, RTCDG_BITS);
+               }
+
+#ifdef APIC_IO
+               if (isa_apic_irq(8) != 8)
+                       panic("APIC RTC != 8");
+#endif /* APIC_IO */
+
+               register_int(8, (inthand2_t *)rtcintr, NULL, "rtc", NULL,
+                            INTR_EXCL | INTR_FAST | INTR_NOPOLL |
+                            INTR_NOENTROPY);
+               machintr_intren(8);
+
+               writertc(RTC_STATUSB, rtc_statusb);
+       }
+}
+SYSINIT(clockinit, SI_BOOT2_CLOCKREG, SI_ORDER_FIRST, cpu_initclocks, NULL)
 
 /*
  * Start both clocks running.  DragonFly note: the stat clock is no longer
@@ -1013,37 +1059,19 @@ resettodr(void)
 static void
 i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
 {
-       int diag;
 #ifdef APIC_IO
        int apic_8254_trial;
        void *clkdesc;
 #endif /* APIC_IO */
 
-       callout_init(&sysbeepstop_ch);
-
        if (!selected && i8254_intr_disable) {
                i8254_nointr = 1; /* don't try to register again */
                cputimer_intr_deregister(cti);
                return;
        }
 
-       if (statclock_disable) {
-               /*
-                * The stat interrupt mask is different without the
-                * statistics clock.  Also, don't set the interrupt
-                * flag which would normally cause the RTC to generate
-                * interrupts.
-                */
-               rtc_statusb = RTCSB_24HR;
-       } else {
-               /* Setting stathz to nonzero early helps avoid races. */
-               stathz = RTC_NOPROFRATE;
-               profhz = RTC_PROFRATE;
-        }
-
        /* Finish initializing 8253 timer 0. */
 #ifdef APIC_IO
-
        apic_8254_intr = isa_apic_irq(0);
        apic_8254_trial = 0;
        if (apic_8254_intr >= 0 ) {
@@ -1064,40 +1092,7 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
                               INTR_NOPOLL | INTR_MPSAFE | 
                               INTR_NOENTROPY);
        machintr_intren(apic_8254_intr);
-       
-#else /* APIC_IO */
-
-       register_int(0, clkintr, NULL, "clk", NULL,
-                    INTR_EXCL | INTR_FAST | 
-                    INTR_NOPOLL | INTR_MPSAFE |
-                    INTR_NOENTROPY);
-       machintr_intren(ICU_IRQ0);
-
-#endif /* APIC_IO */
-
-       /* Initialize RTC. */
-       writertc(RTC_STATUSA, rtc_statusa);
-       writertc(RTC_STATUSB, RTCSB_24HR);
-
-       if (statclock_disable == 0) {
-               diag = rtcin(RTC_DIAG);
-               if (diag != 0)
-                       kprintf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
-
-#ifdef APIC_IO
-               if (isa_apic_irq(8) != 8)
-                       panic("APIC RTC != 8");
-#endif /* APIC_IO */
 
-               register_int(8, (inthand2_t *)rtcintr, NULL, "rtc", NULL,
-                            INTR_EXCL | INTR_FAST | INTR_NOPOLL |
-                            INTR_NOENTROPY);
-               machintr_intren(8);
-
-               writertc(RTC_STATUSB, rtc_statusb);
-       }
-
-#ifdef APIC_IO
        if (apic_8254_trial) {
                sysclock_t base;
                long lastcnt;
@@ -1165,7 +1160,15 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
                kprintf("APIC_IO: "
                       "routing 8254 via 8259 and IOAPIC #0 intpin 0\n");
        }
-#endif
+#else  /* !APIC_IO */
+
+       register_int(0, clkintr, NULL, "clk", NULL,
+                    INTR_EXCL | INTR_FAST | 
+                    INTR_NOPOLL | INTR_MPSAFE |
+                    INTR_NOENTROPY);
+       machintr_intren(ICU_IRQ0);
+
+#endif /* APIC_IO */
 }
 
 #ifdef APIC_IO
index b61f18b..b5a30e7 100644 (file)
@@ -113,10 +113,11 @@ static struct cputimer_intr vkernel_cputimer_intr = {
 /*
  * Initialize the systimer subsystem, called from MI code in early boot.
  */
-void
-cpu_initclocks(void *arg __unused)
+static void
+cpu_initclocks(void)
 {
        int len;
+
        kprintf("initclocks\n");
        len = sizeof(vkernel_cputimer.freq);
        if (sysctlbyname("kern.cputimer.freq", &vkernel_cputimer.freq, &len,
index 508b0b2..43c72b5 100644 (file)
@@ -262,7 +262,6 @@ void        adjust_timeout_calltodo (struct timeval *time_change);
 
 /* Initialize the world */
 void   mi_startup (void);
-void   cpu_initclocks (void *arg __unused);
 void   nchinit (void);
 
 /* Finalize the world. */