IO APIC: Get rid of apic_imen
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 9 Jul 2009 02:15:34 +0000 (10:15 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 11 Jul 2009 02:27:15 +0000 (10:27 +0800)
Add IOAPIC_IM_FLAG_MASKED to apic_intmapinfo, which indicates the
IRQ is currently masked.  Use it instead of apic_imen.

sys/platform/pc32/apic/apic_ipl.s
sys/platform/pc32/apic/apic_vector.s
sys/platform/pc32/apic/mpapic.c
sys/platform/pc32/i386/genassym.c
sys/platform/pc32/i386/mp_machdep.c
sys/platform/pc32/include/smp.h

index 0e3daf7..f71d02c 100644 (file)
 
 #ifdef APIC_IO
 
-       .data
-       ALIGN_DATA
-
-       /*
-        * Interrupt mask for APIC interrupts, defaults to all hardware
-        * interrupts turned off.
-        */
-
-       .p2align 2                              /* MUST be 32bit aligned */
-
-       .globl apic_imen
-apic_imen:
-       .long   APIC_HWI_MASK
-
        .text
        SUPERALIGN_TEXT
 
@@ -96,8 +82,8 @@ ENTRY(APIC_INTRDIS)
        APIC_IMASK_LOCK                 /* enter critical reg */
        movl    4(%esp),%eax
 1:
-       btsl    %eax, apic_imen
        shll    $IOAPIC_IM_SZSHIFT, %eax
+       orl     $IOAPIC_IM_FLAG_MASKED, CNAME(int_to_apicintpin) + IOAPIC_IM_FLAGS(%eax)
        movl    CNAME(int_to_apicintpin) + IOAPIC_IM_ADDR(%eax), %edx
        movl    CNAME(int_to_apicintpin) + IOAPIC_IM_ENTIDX(%eax), %ecx
        testl   %edx, %edx
@@ -113,8 +99,8 @@ ENTRY(APIC_INTREN)
        APIC_IMASK_LOCK                 /* enter critical reg */
        movl    4(%esp), %eax           /* mask into %eax */
 1:
-       btrl    %eax, apic_imen         /* update apic_imen */
        shll    $IOAPIC_IM_SZSHIFT, %eax
+       andl    $~IOAPIC_IM_FLAG_MASKED, CNAME(int_to_apicintpin) + IOAPIC_IM_FLAGS(%eax)
        movl    CNAME(int_to_apicintpin) + IOAPIC_IM_ADDR(%eax), %edx
        movl    CNAME(int_to_apicintpin) + IOAPIC_IM_ENTIDX(%eax), %ecx
        testl   %edx, %edx
index d04d3b1..9bfccea 100644 (file)
 
 #define MASK_IRQ(irq_num)                                              \
        APIC_IMASK_LOCK ;                       /* into critical reg */ \
-       testl   $IRQ_LBIT(irq_num), apic_imen ;                         \
+       testl   $IOAPIC_IM_FLAG_MASKED, IOAPICFLAGS(irq_num) ;          \
        jne     7f ;                    /* masked, don't mask */        \
-       orl     $IRQ_LBIT(irq_num), apic_imen ; /* set the mask bit */  \
+       orl     $IOAPIC_IM_FLAG_MASKED, IOAPICFLAGS(irq_num) ;          \
+                                               /* set the mask bit */  \
        movl    IOAPICADDR(irq_num), %ecx ;     /* ioapic addr */       \
        movl    REDIRIDX(irq_num), %eax ;       /* get the index */     \
        movl    %eax, (%ecx) ;                  /* write the index */   \
 /*
  * Test to see if the source is currntly masked, clear if so.
  */
-#define UNMASK_IRQ(irq_num)                                    \
+#define UNMASK_IRQ(irq_num)                                            \
        cmpl    $0,%eax ;                                               \
        jnz     8f ;                                                    \
        APIC_IMASK_LOCK ;                       /* into critical reg */ \
-       testl   $IRQ_LBIT(irq_num), apic_imen ;                         \
+       testl   $IOAPIC_IM_FLAG_MASKED, IOAPICFLAGS(irq_num) ;          \
        je      7f ;                    /* bit clear, not masked */     \
-       andl    $~IRQ_LBIT(irq_num), apic_imen ;/* clear mask bit */    \
+       andl    $~IOAPIC_IM_FLAG_MASKED, IOAPICFLAGS(irq_num) ;         \
+                                               /* clear mask bit */    \
        movl    IOAPICADDR(irq_num),%ecx ;      /* ioapic addr */       \
        movl    REDIRIDX(irq_num), %eax ;       /* get the index */     \
        movl    %eax,(%ecx) ;                   /* write the index */   \
index 1c0f7ec..0801791 100644 (file)
@@ -792,19 +792,19 @@ bad:
 
 
 /*
- * Print contents of apic_imen.
+ * Print contents of unmasked IRQs.
  */
-extern u_int apic_imen;                /* keep apic_imen 'opaque' */
 void
 imen_dump(void)
 {
        int x;
 
        kprintf("SMP: enabled INTs: ");
-       for (x = 0; x < 24; ++x)
-               if ((apic_imen & (1 << x)) == 0)
-                       kprintf("%d, ", x);
-       kprintf("apic_imen: 0x%08x\n", apic_imen);
+       for (x = 0; x < APIC_INTMAPSIZE; ++x) {
+               if ((int_to_apicintpin[x].flags & IOAPIC_IM_FLAG_MASKED) == 0)
+                       kprintf("%d ", x);
+       }
+       kprintf("\n");
 }
 
 
index e43d5f3..f0b7d35 100644 (file)
@@ -241,4 +241,5 @@ ASSYM(IOAPIC_IM_FLAGS, offsetof(struct apic_intmapinfo, flags));
 ASSYM(IOAPIC_IM_SIZE, sizeof(struct apic_intmapinfo));
 ASSYM(IOAPIC_IM_SZSHIFT, IOAPIC_IM_SZSHIFT);
 ASSYM(IOAPIC_IM_FLAG_LEVEL, IOAPIC_IM_FLAG_LEVEL);
+ASSYM(IOAPIC_IM_FLAG_MASKED, IOAPIC_IM_FLAG_MASKED);
 #endif
index c98f778..fb3bb96 100644 (file)
@@ -1529,6 +1529,9 @@ setup_apic_irq_mapping(void)
                int_to_apicintpin[x].int_pin = 0;
                int_to_apicintpin[x].apic_address = NULL;
                int_to_apicintpin[x].redirindex = 0;
+
+               /* Default to masked */
+               int_to_apicintpin[x].flags = IOAPIC_IM_FLAG_MASKED;
        }
 
        /* First assign ISA/EISA interrupts */
index 4a42d02..7c0aa57 100644 (file)
@@ -82,6 +82,7 @@ struct apic_intmapinfo {
 #define IOAPIC_IM_SZSHIFT      5
 
 #define IOAPIC_IM_FLAG_LEVEL   0x1     /* default to edge trigger */
+#define IOAPIC_IM_FLAG_MASKED  0x2
 
 extern struct apic_intmapinfo  int_to_apicintpin[];
 extern struct pcb              stoppcbs[];