8254: apic_8254_intr does not need to be global variable
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 21 Mar 2011 14:39:16 +0000 (22:39 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 21 Mar 2011 14:39:16 +0000 (22:39 +0800)
sys/platform/pc32/include/clock.h
sys/platform/pc32/isa/clock.c
sys/platform/pc64/include/clock.h
sys/platform/pc64/isa/clock.c

index 93fa531..e3d4586 100644 (file)
@@ -37,9 +37,6 @@ extern int    tsc_present;
 extern int64_t tsc_frequency;
 extern int     tsc_is_broken;
 extern int     wall_cmos_clock;
-#ifdef SMP /* APIC-IO */
-extern int     apic_8254_intr;
-#endif
 
 /*
  * Driver to clock driver interface.
index 11ca556..606df1f 100644 (file)
@@ -91,7 +91,6 @@
 
 #ifdef SMP /* APIC-IO */
 /* The interrupt triggered by the 8254 (timer) chip */
-int apic_8254_intr;
 static void setup_8254_mixed_mode (void);
 #endif
 static void i8254_restore(void);
@@ -1014,6 +1013,7 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
 #ifdef SMP /* APIC-IO */
        int apic_8254_trial = 0;
        void *clkdesc = NULL;
+       int irq = 0;
 #endif
 
        callout_init(&sysbeepstop_ch);
@@ -1036,14 +1036,14 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
 #ifdef SMP /* APIC-IO */
 if (apic_io_enable) {
        if (ioapic_use_old) {
-               apic_8254_intr = isa_apic_irq(0);
-               if (apic_8254_intr >= 0 ) {
+               irq = isa_apic_irq(0);
+               if (irq >= 0 ) {
                        if (apic_int_type(0, 0) == 3)
                                apic_8254_trial = 1;
                } else {
                        /* look for ExtInt on pin 0 */
                        if (apic_int_type(0, 0) == 3) {
-                               apic_8254_intr = apic_irq(0, 0);
+                               irq = apic_irq(0, 0);
                                setup_8254_mixed_mode();
                        } else {
                                panic("APIC_IO: Cannot route 8254 "
@@ -1051,12 +1051,12 @@ if (apic_io_enable) {
                        }
                }
 
-               clkdesc = register_int(apic_8254_intr, clkintr, NULL, "clk",
+               clkdesc = register_int(irq, clkintr, NULL, "clk",
                                       NULL,
                                       INTR_EXCL | INTR_CLOCK |
                                       INTR_NOPOLL | INTR_MPSAFE | 
                                       INTR_NOENTROPY);
-               machintr_intren(apic_8254_intr);
+               machintr_intren(irq);
        }
 } else {
 #endif
@@ -1086,7 +1086,7 @@ if (apic_io_enable && ioapic_use_old) {
                KKASSERT(sys_cputimer == &i8254_cputimer);
                KKASSERT(cti == &i8254_cputimer_intr);
 
-               lastcnt = get_interrupt_counter(apic_8254_intr);
+               lastcnt = get_interrupt_counter(irq);
 
                /*
                 * Force an 8254 Timer0 interrupt and wait 1/100s for
@@ -1097,20 +1097,20 @@ if (apic_io_enable && ioapic_use_old) {
                base = sys_cputimer->count();
                while (sys_cputimer->count() - base < sys_cputimer->freq / 100)
                        ;       /* nothing */
-               if (get_interrupt_counter(apic_8254_intr) - lastcnt == 0) {
+               if (get_interrupt_counter(irq) - lastcnt == 0) {
                        /* 
                         * The MP table is broken.
                         * The 8254 was not connected to the specified pin
                         * on the IO APIC.
                         * Workaround: Limited variant of mixed mode.
                         */
-                       machintr_intrdis(apic_8254_intr);
+                       machintr_intrdis(irq);
                        unregister_int(clkdesc);
                        kprintf("APIC_IO: Broken MP table detected: "
                               "8254 is not connected to "
                               "IOAPIC #%d intpin %d\n",
-                              int_to_apicintpin[apic_8254_intr].ioapic,
-                              int_to_apicintpin[apic_8254_intr].int_pin);
+                              int_to_apicintpin[irq].ioapic,
+                              int_to_apicintpin[irq].int_pin);
                        /* 
                         * Revoke current ISA IRQ 0 assignment and 
                         * configure a fallback interrupt routing from
@@ -1119,25 +1119,25 @@ if (apic_io_enable && ioapic_use_old) {
                         * We reuse the low level interrupt handler number.
                         */
                        if (apic_irq(0, 0) < 0) {
-                               revoke_apic_irq(apic_8254_intr);
-                               assign_apic_irq(0, 0, apic_8254_intr);
+                               revoke_apic_irq(irq);
+                               assign_apic_irq(0, 0, irq);
                        }
-                       apic_8254_intr = apic_irq(0, 0);
+                       irq = apic_irq(0, 0);
                        setup_8254_mixed_mode();
-                       register_int(apic_8254_intr, clkintr, NULL, "clk",
+                       register_int(irq, clkintr, NULL, "clk",
                                     NULL,
                                     INTR_EXCL | INTR_CLOCK |
                                     INTR_NOPOLL | INTR_MPSAFE |
                                     INTR_NOENTROPY);
-                       machintr_intren(apic_8254_intr);
+                       machintr_intren(irq);
                }
        }
        if (apic_int_type(0, 0) != 3 ||
-           int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
-           int_to_apicintpin[apic_8254_intr].int_pin != 0) {
+           int_to_apicintpin[irq].ioapic != 0 ||
+           int_to_apicintpin[irq].int_pin != 0) {
                kprintf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
-                      int_to_apicintpin[apic_8254_intr].ioapic,
-                      int_to_apicintpin[apic_8254_intr].int_pin);
+                      int_to_apicintpin[irq].ioapic,
+                      int_to_apicintpin[irq].int_pin);
        } else {
                kprintf("APIC_IO: "
                       "routing 8254 via 8259 and IOAPIC #0 intpin 0\n");
index 93fa531..e3d4586 100644 (file)
@@ -37,9 +37,6 @@ extern int    tsc_present;
 extern int64_t tsc_frequency;
 extern int     tsc_is_broken;
 extern int     wall_cmos_clock;
-#ifdef SMP /* APIC-IO */
-extern int     apic_8254_intr;
-#endif
 
 /*
  * Driver to clock driver interface.
index 468598c..c45267a 100644 (file)
@@ -93,7 +93,6 @@
 
 #ifdef SMP /* APIC-IO */
 /* The interrupt triggered by the 8254 (timer) chip */
-int apic_8254_intr;
 static void setup_8254_mixed_mode (void);
 #endif
 static void i8254_restore(void);
@@ -1021,6 +1020,7 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
 #ifdef SMP /* APIC-IO */
        int apic_8254_trial = 0;
        void *clkdesc = NULL;
+       int irq = 0;
 #endif
 
        callout_init(&sysbeepstop_ch);
@@ -1043,14 +1043,14 @@ i8254_intr_initclock(struct cputimer_intr *cti, boolean_t selected)
 #ifdef SMP /* APIC-IO */
 if (apic_io_enable) {
        if (ioapic_use_old) {
-               apic_8254_intr = isa_apic_irq(0);
-               if (apic_8254_intr >= 0 ) {
+               irq = isa_apic_irq(0);
+               if (irq >= 0 ) {
                        if (apic_int_type(0, 0) == 3)
                                apic_8254_trial = 1;
                } else {
                        /* look for ExtInt on pin 0 */
                        if (apic_int_type(0, 0) == 3) {
-                               apic_8254_intr = apic_irq(0, 0);
+                               irq = apic_irq(0, 0);
                                setup_8254_mixed_mode();
                        } else {
                                panic("APIC_IO: Cannot route 8254 "
@@ -1058,12 +1058,12 @@ if (apic_io_enable) {
                        }
                }
 
-               clkdesc = register_int(apic_8254_intr, clkintr, NULL, "clk",
+               clkdesc = register_int(irq, clkintr, NULL, "clk",
                                       NULL,
                                       INTR_EXCL | INTR_CLOCK |
                                       INTR_NOPOLL | INTR_MPSAFE | 
                                       INTR_NOENTROPY);
-               machintr_intren(apic_8254_intr);
+               machintr_intren(irq);
        }
 } else {
 #endif
@@ -1093,7 +1093,7 @@ if (apic_io_enable && ioapic_use_old) {
                KKASSERT(sys_cputimer == &i8254_cputimer);
                KKASSERT(cti == &i8254_cputimer_intr);
 
-               lastcnt = get_interrupt_counter(apic_8254_intr);
+               lastcnt = get_interrupt_counter(irq);
 
                /*
                 * Force an 8254 Timer0 interrupt and wait 1/100s for
@@ -1104,20 +1104,20 @@ if (apic_io_enable && ioapic_use_old) {
                base = sys_cputimer->count();
                while (sys_cputimer->count() - base < sys_cputimer->freq / 100)
                        ;       /* nothing */
-               if (get_interrupt_counter(apic_8254_intr) - lastcnt == 0) {
+               if (get_interrupt_counter(irq) - lastcnt == 0) {
                        /* 
                         * The MP table is broken.
                         * The 8254 was not connected to the specified pin
                         * on the IO APIC.
                         * Workaround: Limited variant of mixed mode.
                         */
-                       machintr_intrdis(apic_8254_intr);
+                       machintr_intrdis(irq);
                        unregister_int(clkdesc);
                        kprintf("APIC_IO: Broken MP table detected: "
                               "8254 is not connected to "
                               "IOAPIC #%d intpin %d\n",
-                              int_to_apicintpin[apic_8254_intr].ioapic,
-                              int_to_apicintpin[apic_8254_intr].int_pin);
+                              int_to_apicintpin[irq].ioapic,
+                              int_to_apicintpin[irq].int_pin);
                        /* 
                         * Revoke current ISA IRQ 0 assignment and 
                         * configure a fallback interrupt routing from
@@ -1126,25 +1126,25 @@ if (apic_io_enable && ioapic_use_old) {
                         * We reuse the low level interrupt handler number.
                         */
                        if (apic_irq(0, 0) < 0) {
-                               revoke_apic_irq(apic_8254_intr);
-                               assign_apic_irq(0, 0, apic_8254_intr);
+                               revoke_apic_irq(irq);
+                               assign_apic_irq(0, 0, irq);
                        }
-                       apic_8254_intr = apic_irq(0, 0);
+                       irq = apic_irq(0, 0);
                        setup_8254_mixed_mode();
-                       register_int(apic_8254_intr, clkintr, NULL, "clk",
+                       register_int(irq, clkintr, NULL, "clk",
                                     NULL,
                                     INTR_EXCL | INTR_CLOCK |
                                     INTR_NOPOLL | INTR_MPSAFE |
                                     INTR_NOENTROPY);
-                       machintr_intren(apic_8254_intr);
+                       machintr_intren(irq);
                }
        }
        if (apic_int_type(0, 0) != 3 ||
-           int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
-           int_to_apicintpin[apic_8254_intr].int_pin != 0) {
+           int_to_apicintpin[irq].ioapic != 0 ||
+           int_to_apicintpin[irq].int_pin != 0) {
                kprintf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
-                      int_to_apicintpin[apic_8254_intr].ioapic,
-                      int_to_apicintpin[apic_8254_intr].int_pin);
+                      int_to_apicintpin[irq].ioapic,
+                      int_to_apicintpin[irq].int_pin);
        } else {
                kprintf("APIC_IO: "
                       "routing 8254 via 8259 and IOAPIC #0 intpin 0\n");