MachIntr: Add two methods to find IRQ
[dragonfly.git] / sys / platform / pc32 / isa / clock.c
index 6fde329..838bf56 100644 (file)
 #include <machine/smp.h>
 #include <machine/specialreg.h>
 
-#ifdef SMP
 #include <machine_base/apic/ioapic.h>
 #include <machine_base/apic/ioapic_abi.h>
-#endif
 #include <machine_base/icu/icu.h>
 #include <bus/isa/isa.h>
 #include <bus/isa/rtc.h>
@@ -1001,8 +999,6 @@ resettodr(void)
        crit_exit();
 }
 
-#ifdef SMP
-
 static int
 i8254_ioapic_trial(int irq, struct cputimer_intr *cti)
 {
@@ -1016,7 +1012,7 @@ i8254_ioapic_trial(int irq, struct cputimer_intr *cti)
        KKASSERT(sys_cputimer == &i8254_cputimer);
        KKASSERT(cti == &i8254_cputimer_intr);
 
-       lastcnt = get_interrupt_counter(irq);
+       lastcnt = get_interrupt_counter(irq, mycpuid);
 
        /*
         * Force an 8254 Timer0 interrupt and wait 1/100s for
@@ -1029,13 +1025,11 @@ i8254_ioapic_trial(int irq, struct cputimer_intr *cti)
        while (sys_cputimer->count() - base < sys_cputimer->freq / 100)
                ; /* nothing */
 
-       if (get_interrupt_counter(irq) - lastcnt == 0)
+       if (get_interrupt_counter(irq, mycpuid) - lastcnt == 0)
                return ENOENT;
        return 0;
 }
 
-#endif /* SMP */
-
 /*
  * Start both clocks running.  DragonFly note: the stat clock is no longer
  * used.  Instead, 8254 based systimers are used for all major clock
@@ -1044,11 +1038,10 @@ i8254_ioapic_trial(int irq, struct cputimer_intr *cti)
 static void
 i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
 {
-#ifdef SMP /* APIC-IO */
        void *clkdesc = NULL;
        int irq = 0, mixed_mode = 0, error;
-#endif
 
+       KKASSERT(mycpuid == 0);
        callout_init(&sysbeepstop_ch);
 
        if (!selected && i8254_intr_disable)
@@ -1063,16 +1056,15 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
        rtc_statusb = RTCSB_24HR;
 
        /* Finish initializing 8253 timer 0. */
-#ifdef SMP
        if (ioapic_enable) {
-               irq = ioapic_abi_find_irq(0, INTR_TRIGGER_EDGE,
+               irq = machintr_legacy_intr_find(0, INTR_TRIGGER_EDGE,
                        INTR_POLARITY_HIGH);
                if (irq < 0) {
 mixed_mode_setup:
-                       error = ioapic_abi_extint_irqmap(0);
+                       error = ioapic_conf_legacy_extint(0);
                        if (!error) {
-                               irq = ioapic_abi_find_irq(0, INTR_TRIGGER_EDGE,
-                                       INTR_POLARITY_HIGH);
+                               irq = machintr_legacy_intr_find(0,
+                                   INTR_TRIGGER_EDGE, INTR_POLARITY_HIGH);
                                if (irq < 0)
                                        error = ENOENT;
                        }
@@ -1093,24 +1085,18 @@ mixed_mode_setup:
                                       NULL,
                                       INTR_EXCL | INTR_CLOCK |
                                       INTR_NOPOLL | INTR_MPSAFE |
-                                      INTR_NOENTROPY);
-               machintr_intren(irq);
+                                      INTR_NOENTROPY, 0);
        } else {
-#endif
-       register_int(0, clkintr, NULL, "clk", NULL,
-                    INTR_EXCL | INTR_CLOCK |
-                    INTR_NOPOLL | INTR_MPSAFE |
-                    INTR_NOENTROPY);
-       machintr_intren(0);
-#ifdef SMP
+               register_int(0, clkintr, NULL, "clk", NULL,
+                            INTR_EXCL | INTR_CLOCK |
+                            INTR_NOPOLL | INTR_MPSAFE |
+                            INTR_NOENTROPY, 0);
        }
-#endif
 
        /* Initialize RTC. */
        writertc(RTC_STATUSA, rtc_statusa);
        writertc(RTC_STATUSB, RTCSB_24HR);
 
-#ifdef SMP
        if (ioapic_enable) {
                error = i8254_ioapic_trial(irq, cti);
                if (error) {
@@ -1127,13 +1113,11 @@ mixed_mode_setup:
                        } else {
                                kprintf("IOAPIC: warning 8254 is not connected "
                                        "to the correct pin, try mixed mode\n");
-                               machintr_intrdis(irq);
-                               unregister_int(clkdesc);
+                               unregister_int(clkdesc, 0);
                                goto mixed_mode_setup;
                        }
                }
        }
-#endif
        return;
 
 nointr: