Use genassym to replace magic numbers in pc32/apic_{vector,ipl}.s
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 8 Jul 2009 08:30:00 +0000 (16:30 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 11 Jul 2009 02:27:14 +0000 (10:27 +0800)
sys/platform/pc32/apic/apic_ipl.s
sys/platform/pc32/apic/apic_vector.s
sys/platform/pc32/i386/genassym.c
sys/platform/pc32/include/smp.h

index 96565d1..0e3daf7 100644 (file)
@@ -97,9 +97,9 @@ ENTRY(APIC_INTRDIS)
        movl    4(%esp),%eax
 1:
        btsl    %eax, apic_imen
-       shll    $4, %eax
-       movl    CNAME(int_to_apicintpin) + 8(%eax), %edx
-       movl    CNAME(int_to_apicintpin) + 12(%eax), %ecx
+       shll    $IOAPIC_IM_SZSHIFT, %eax
+       movl    CNAME(int_to_apicintpin) + IOAPIC_IM_ADDR(%eax), %edx
+       movl    CNAME(int_to_apicintpin) + IOAPIC_IM_ENTIDX(%eax), %ecx
        testl   %edx, %edx
        jz      2f
        movl    %ecx, (%edx)            /* target register index */
@@ -114,9 +114,9 @@ ENTRY(APIC_INTREN)
        movl    4(%esp), %eax           /* mask into %eax */
 1:
        btrl    %eax, apic_imen         /* update apic_imen */
-       shll    $4, %eax
-       movl    CNAME(int_to_apicintpin) + 8(%eax), %edx
-       movl    CNAME(int_to_apicintpin) + 12(%eax), %ecx
+       shll    $IOAPIC_IM_SZSHIFT, %eax
+       movl    CNAME(int_to_apicintpin) + IOAPIC_IM_ADDR(%eax), %edx
+       movl    CNAME(int_to_apicintpin) + IOAPIC_IM_ENTIDX(%eax), %ecx
        testl   %edx, %edx
        jz      2f
        movl    %ecx, (%edx)            /* write the target register index */
index 2574ad3..166a6e1 100644 (file)
 #define POP_DUMMY                                                      \
        addl    $19*4,%esp ;                                            \
 
-#define IOAPICADDR(irq_num) CNAME(int_to_apicintpin) + 16 * (irq_num) + 8
-#define REDIRIDX(irq_num) CNAME(int_to_apicintpin) + 16 * (irq_num) + 12
+#define IOAPICADDR(irq_num) \
+       CNAME(int_to_apicintpin) + IOAPIC_IM_SIZE * (irq_num) + IOAPIC_IM_ADDR
+#define REDIRIDX(irq_num) \
+       CNAME(int_to_apicintpin) + IOAPIC_IM_SIZE * (irq_num) + IOAPIC_IM_ENTIDX
 
 #define MASK_IRQ(irq_num)                                              \
        APIC_IMASK_LOCK ;                       /* into critical reg */ \
index 5e73826..1be88fe 100644 (file)
@@ -67,6 +67,7 @@
 #include <vfs/nfs/nfsdiskless.h>
 #ifdef SMP
 #include <machine_base/apic/apicreg.h>
+#include <machine/smp.h>
 #endif
 #include <machine/segments.h>
 #include <machine/sigframe.h>
@@ -232,3 +233,10 @@ ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL));
 
 ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL));
 ASSYM(VM86_FRAMESIZE, sizeof(struct vm86frame));
+
+#ifdef SMP
+ASSYM(IOAPIC_IM_ADDR, offsetof(struct apic_intmapinfo, apic_address));
+ASSYM(IOAPIC_IM_ENTIDX, offsetof(struct apic_intmapinfo, redirindex));
+ASSYM(IOAPIC_IM_SZSHIFT, IOAPIC_IM_SZSHIFT);
+ASSYM(IOAPIC_IM_SIZE, sizeof(struct apic_intmapinfo));
+#endif
index 98f4874..57cf287 100644 (file)
@@ -66,12 +66,18 @@ extern int                  cpu_num_to_apic_id[];
 extern int                     io_num_to_apic_id[];
 extern int                     apic_id_to_logical[];
 #define APIC_INTMAPSIZE 24
+/*
+ * NOTE:
+ * - Keep size of apic_intmapinfo power of 2
+ * - Update IOAPIC_IM_SZSHIFT after changing apic_intmapinfo size
+ */
 struct apic_intmapinfo {
        int ioapic;
        int int_pin;
        volatile void *apic_address;
        int redirindex;
 };
+#define IOAPIC_IM_SZSHIFT      4
 extern struct apic_intmapinfo  int_to_apicintpin[];
 extern struct pcb              stoppcbs[];