From 38015462281442a16102242b1194e9dd789ac194 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Tue, 19 May 2009 20:56:17 +0800 Subject: [PATCH] Revert "More clock cleanup:" This reverts commit 50b53814fb840b70162a846420b75c5bb9432931. Reordering RTC and i8254 initialization does not work on some boxes Reported-by: Johannes Hofmann --- sys/platform/pc32/isa/clock.c | 107 +++++++++++------------ sys/platform/vkernel/platform/systimer.c | 5 +- sys/sys/systm.h | 1 + 3 files changed, 55 insertions(+), 58 deletions(-) diff --git a/sys/platform/pc32/isa/clock.c b/sys/platform/pc32/isa/clock.c index 446e3f82a6..c608039c43 100644 --- a/sys/platform/pc32/isa/clock.c +++ b/sys/platform/pc32/isa/clock.c @@ -1004,52 +1004,6 @@ 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 @@ -1059,19 +1013,37 @@ SYSINIT(clockinit, SI_BOOT2_CLOCKREG, SI_ORDER_FIRST, cpu_initclocks, NULL) 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 ) { @@ -1092,7 +1064,40 @@ 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; @@ -1160,15 +1165,7 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected) kprintf("APIC_IO: " "routing 8254 via 8259 and IOAPIC #0 intpin 0\n"); } -#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 */ +#endif } #ifdef APIC_IO diff --git a/sys/platform/vkernel/platform/systimer.c b/sys/platform/vkernel/platform/systimer.c index b5a30e7acd..b61f18b24e 100644 --- a/sys/platform/vkernel/platform/systimer.c +++ b/sys/platform/vkernel/platform/systimer.c @@ -113,11 +113,10 @@ static struct cputimer_intr vkernel_cputimer_intr = { /* * Initialize the systimer subsystem, called from MI code in early boot. */ -static void -cpu_initclocks(void) +void +cpu_initclocks(void *arg __unused) { int len; - kprintf("initclocks\n"); len = sizeof(vkernel_cputimer.freq); if (sysctlbyname("kern.cputimer.freq", &vkernel_cputimer.freq, &len, diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 43c72b5783..508b0b234e 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -262,6 +262,7 @@ 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. */ -- 2.41.0