X-Git-Url: https://gitweb.dragonflybsd.org/~mneumann/dragonfly.git/blobdiff_plain/0658a929038b8748f5ef610ee5364a8995d60f66..79b62055301f75e30e625e64f13564a1145fe853:/sys/platform/pc32/isa/clock.c diff --git a/sys/platform/pc32/isa/clock.c b/sys/platform/pc32/isa/clock.c index c608039c43..99ca676156 100644 --- a/sys/platform/pc32/isa/clock.c +++ b/sys/platform/pc32/isa/clock.c @@ -35,7 +35,6 @@ * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/isa/clock.c,v 1.149.2.6 2002/11/02 04:41:50 iwasaki Exp $ - * $DragonFly: src/sys/platform/pc32/isa/clock.c,v 1.55 2008/08/02 01:14:43 dillon Exp $ */ /* @@ -89,7 +88,7 @@ #include -#ifdef APIC_IO +#ifdef SMP /* APIC-IO */ /* The interrupt triggered by the 8254 (timer) chip */ int apic_8254_intr; static void setup_8254_mixed_mode (void); @@ -443,6 +442,7 @@ DODELAY(int n, int doswitch) ticks_left -= delta; if (doswitch && ticks_left > 0) lwkt_switch(); + cpu_pause(); } #ifdef DELAYDEBUG if (state == 1) @@ -451,20 +451,25 @@ DODELAY(int n, int doswitch) #endif } +/* + * DELAY() never switches + */ void DELAY(int n) { DODELAY(n, 0); } +/* + * DRIVERSLEEP() does not switch if called with a spinlock held or + * from a hard interrupt. + */ void DRIVERSLEEP(int usec) { globaldata_t gd = mycpu; - if (gd->gd_intr_nesting_level || - gd->gd_spinlock_rd || - gd->gd_spinlocks_wr) { + if (gd->gd_intr_nesting_level || gd->gd_spinlocks_wr) { DODELAY(usec, 0); } else { DODELAY(usec, 1); @@ -875,7 +880,6 @@ void inittodr(time_t base) { unsigned long sec, days; - int yd; int year, month; int y, m; struct timespec ts; @@ -916,7 +920,6 @@ inittodr(time_t base) if ((month > 2) && LEAPYEAR(year)) days ++; days += readrtc(RTC_DAY) - 1; - yd = days; for (y = 1970; y < year; y++) days += DAYSPERYEAR + LEAPYEAR(y); sec = ((( days * 24 + @@ -1014,10 +1017,10 @@ static void i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected) { int diag; -#ifdef APIC_IO +#ifdef SMP /* APIC-IO */ int apic_8254_trial; void *clkdesc; -#endif /* APIC_IO */ +#endif callout_init(&sysbeepstop_ch); @@ -1042,8 +1045,8 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected) } /* Finish initializing 8253 timer 0. */ -#ifdef APIC_IO - +#ifdef SMP /* APIC-IO */ +if (apic_io_enable) { apic_8254_intr = isa_apic_irq(0); apic_8254_trial = 0; if (apic_8254_intr >= 0 ) { @@ -1060,20 +1063,20 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected) clkdesc = register_int(apic_8254_intr, clkintr, NULL, "clk", NULL, - INTR_EXCL | INTR_FAST | + INTR_EXCL | INTR_CLOCK | INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY); machintr_intren(apic_8254_intr); - -#else /* APIC_IO */ - +} else { +#endif register_int(0, clkintr, NULL, "clk", NULL, - INTR_EXCL | INTR_FAST | + INTR_EXCL | INTR_CLOCK | INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY); machintr_intren(ICU_IRQ0); - -#endif /* APIC_IO */ +#ifdef SMP /* APIC-IO */ +} +#endif /* Initialize RTC. */ writertc(RTC_STATUSA, rtc_statusa); @@ -1084,20 +1087,23 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected) if (diag != 0) kprintf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS); -#ifdef APIC_IO +#ifdef SMP /* APIC-IO */ +if (apic_io_enable) { if (isa_apic_irq(8) != 8) panic("APIC RTC != 8"); -#endif /* APIC_IO */ +} +#endif register_int(8, (inthand2_t *)rtcintr, NULL, "rtc", NULL, - INTR_EXCL | INTR_FAST | INTR_NOPOLL | + INTR_EXCL | INTR_CLOCK | INTR_NOPOLL | INTR_NOENTROPY); machintr_intren(8); writertc(RTC_STATUSB, rtc_statusb); } -#ifdef APIC_IO +#ifdef SMP /* APIC-IO */ +if (apic_io_enable) { if (apic_8254_trial) { sysclock_t base; long lastcnt; @@ -1149,7 +1155,7 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected) setup_8254_mixed_mode(); register_int(apic_8254_intr, clkintr, NULL, "clk", NULL, - INTR_EXCL | INTR_FAST | + INTR_EXCL | INTR_CLOCK | INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY); machintr_intren(apic_8254_intr); @@ -1165,10 +1171,11 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected) kprintf("APIC_IO: " "routing 8254 via 8259 and IOAPIC #0 intpin 0\n"); } +} #endif } -#ifdef APIC_IO +#ifdef SMP /* APIC-IO */ static void setup_8254_mixed_mode(void)