Finish migrating the cpl into the thread structure.
authorMatthew Dillon <dillon@dragonflybsd.org>
Sun, 22 Jun 2003 08:54:22 +0000 (08:54 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Sun, 22 Jun 2003 08:54:22 +0000 (08:54 +0000)
38 files changed:
sys/i386/apic/apic_ipl.s
sys/i386/apic/apic_vector.s
sys/i386/i386/autoconf.c
sys/i386/i386/exception.s
sys/i386/i386/machdep.c
sys/i386/i386/swtch.s
sys/i386/i386/trap.c
sys/i386/i386/vm86bios.s
sys/i386/icu/icu_ipl.s
sys/i386/icu/icu_vector.s
sys/i386/include/asnames.h
sys/i386/include/ipl.h
sys/i386/include/thread.h
sys/i386/isa/apic_ipl.s
sys/i386/isa/apic_vector.s
sys/i386/isa/icu_ipl.s
sys/i386/isa/icu_vector.s
sys/i386/isa/ipl.s
sys/i386/isa/ipl_funcs.c
sys/platform/pc32/apic/apic_ipl.s
sys/platform/pc32/apic/apic_vector.s
sys/platform/pc32/i386/autoconf.c
sys/platform/pc32/i386/exception.s
sys/platform/pc32/i386/machdep.c
sys/platform/pc32/i386/swtch.s
sys/platform/pc32/i386/trap.c
sys/platform/pc32/i386/vm86bios.s
sys/platform/pc32/icu/icu_ipl.s
sys/platform/pc32/icu/icu_vector.s
sys/platform/pc32/include/asnames.h
sys/platform/pc32/include/ipl.h
sys/platform/pc32/include/thread.h
sys/platform/pc32/isa/apic_ipl.s
sys/platform/pc32/isa/apic_vector.s
sys/platform/pc32/isa/icu_ipl.s
sys/platform/pc32/isa/icu_vector.s
sys/platform/pc32/isa/ipl.s
sys/platform/pc32/isa/ipl_funcs.c

index b5d2c56..b7b8704 100644 (file)
@@ -23,7 +23,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/apic_ipl.s,v 1.27.2.2 2000/09/30 02:49:35 ps Exp $
- * $DragonFly: src/sys/i386/apic/Attic/apic_ipl.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/apic/Attic/apic_ipl.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -99,7 +99,9 @@ ENTRY(splz)
         * NOTE: "bsfl %ecx,%ecx" is undefined when %ecx is 0 so we can't
         * rely on the secondary btrl tests.
         */
-       movl    _cpl,%eax
+       pushl   %ebx
+       movl    _curthread,%ebx
+       movl    TD_MACH+MTD_CPL(%ebx),%eax
 splz_next:
        /*
         * We don't need any locking here.  (ipending & ~cpl) cannot grow 
@@ -110,6 +112,7 @@ splz_next:
        notl    %ecx                    /* set bit = unmasked level */
        andl    _ipending,%ecx          /* set bit = unmasked pending INT */
        jne     splz_unpend
+       popl    %ebx
        ret
 
        ALIGN_TEXT
@@ -127,19 +130,21 @@ splz_unpend:
         * We should change the interface so that the unit number is not
         * determined at config time.
         *
-        * The vec[] routines build the proper frame on the stack,
-        * then call one of _Xintr0 thru _XintrNN.
+        * The vec[] routines build the proper frame on the stack so
+        * the interrupt will eventually return to the caller or splz,
+        * then calls one of _Xintr0 thru _XintrNN.
         */
+       popl    %ebx
        jmp     *_vec(,%ecx,4)
 
        ALIGN_TEXT
 splz_swi:
-       pushl   %eax
+       pushl   %eax                    /* save cpl across call */
        orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* set cpl for SWI */
        call    *_ihandlers(,%ecx,4)
        popl    %eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* restore cpl and loop */
        jmp     splz_next
 
 /*
index bd2dc8e..b66cd21 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     from: vector.s, 386BSD 0.1 unknown origin
  * $FreeBSD: src/sys/i386/isa/apic_vector.s,v 1.47.2.5 2001/09/01 22:33:38 tegge Exp $
- * $DragonFly: src/sys/i386/apic/Attic/apic_vector.s,v 1.4 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/apic/Attic/apic_vector.s,v 1.5 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -230,10 +230,10 @@ IDTVEC(vec_name) ;                                                        \
        jz      3f ;                            /* no */                \
 ;                                                                      \
        APIC_ITRACE(apic_itrace_gotisrlock, irq_num, APIC_ITRACE_GOTISRLOCK) ;\
-       testl   $IRQ_BIT(irq_num), _cpl ;                               \
+       movl    _curthread,%ebx ;                                       \
+       testl   $IRQ_BIT(irq_num), TD_MACH+MTD_CPL(%eax) ;              \
        jne     2f ;                            /* this INT masked */   \
-       movl    _curthread,%eax ;                                       \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;                              \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ebx) ;                              \
        jge     2f ;                            /* in critical sec */   \
 ;                                                                      \
        incb    _intr_nesting_level ;                                   \
@@ -245,10 +245,11 @@ __CONCAT(Xresume,irq_num): ;                                              \
        movl    _intr_countp + (irq_num) * 4, %eax ;                    \
        lock ;  incl    (%eax) ;                                        \
 ;                                                                      \
-       movl    _cpl, %eax ;                                            \
-       pushl   %eax ;                                                  \
+       movl    _curthread, %ebx ;                                      \
+       movl    TD_MACH+MTD_CPL(%ebx), %eax ;                           \
+       pushl   %eax ;   /* cpl restored by doreti */                   \
        orl     _intr_mask + (irq_num) * 4, %eax ;                      \
-       movl    %eax, _cpl ;                                            \
+       movl    %eax, TD_MACH+MTD_CPL(%ebx) ;                           \
        lock ;                                                          \
        andl    $~IRQ_BIT(irq_num), _ipending ;                         \
 ;                                                                      \
@@ -294,7 +295,7 @@ __CONCAT(Xresume,irq_num): ;                                                \
        lock ;                                                          \
        orl     $IRQ_BIT(irq_num), _ipending ;                          \
        movl    $TDPRI_CRIT,_reqpri ;                                   \
-       testl   $IRQ_BIT(irq_num), _cpl ;                               \
+       testl   $IRQ_BIT(irq_num), TD_MACH+MTD_CPL(%ebx) ;              \
        jne     4f ;                            /* this INT masked */   \
        call    forward_irq ;    /* forward irq to lock holder */       \
        POP_FRAME ;                             /* and return */        \
@@ -448,8 +449,9 @@ _Xcpuast:
         */
        call    _get_mplock
 
-       movl    _cpl, %eax
-       pushl   %eax
+       movl    _curthread, %eax
+       pushl   TD_MACH+MTD_CPL(%eax)           /* cpl restored by doreti */
+
        orl     $AST_PENDING, _astpending       /* XXX */
        incb    _intr_nesting_level
        sti
@@ -504,8 +506,9 @@ _Xforward_irq:
        cmpb    $4, _intr_nesting_level
        jae     2f
        
-       movl    _cpl, %eax
-       pushl   %eax
+       movl    _curthread, %eax
+       pushl   TD_MACH+MTD_CPL(%eax)           /* cpl restored by doreti */
+
        incb    _intr_nesting_level
        sti
        
index e2759ca..a55a8df 100644 (file)
@@ -35,7 +35,7 @@
  *
  *     from: @(#)autoconf.c    7.1 (Berkeley) 5/9/91
  * $FreeBSD: src/sys/i386/i386/autoconf.c,v 1.146.2.2 2001/06/07 06:05:58 dd Exp $
- * $DragonFly: src/sys/i386/i386/Attic/autoconf.c,v 1.2 2003/06/17 04:28:35 dillon Exp $
+ * $DragonFly: src/sys/i386/i386/Attic/autoconf.c,v 1.3 2003/06/22 08:54:18 dillon Exp $
  */
 
 /*
@@ -67,6 +67,7 @@
 #include <sys/malloc.h>
 #include <sys/mount.h>
 #include <sys/cons.h>
+#include <sys/thread.h>
 
 #include <machine/bootinfo.h>
 #include <machine/ipl.h>
 #include <i386/isa/icu.h>
 #endif /* APIC_IO */
 
+#include <machine/pcb.h>
+#include <machine/pcb_ext.h>
+#include <machine/vm86.h>
+#include <machine/globaldata.h>
+#include <machine/globals.h>
+
 #if NISA > 0
 #include <isa/isavar.h>
 
@@ -171,7 +178,7 @@ configure(dummy)
         * completely safe (since a panic may occur in a critical region
         * at splhigh()), but we want at least bio interrupts to work.
         */
-       safepri = cpl;
+       safepri = curthread->td_cpl;
 }
 
 static void
index 24ae742..a02f853 100644 (file)
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $
- * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.3 2003/06/20 02:09:50 dillon Exp $
+ * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.4 2003/06/22 08:54:18 dillon Exp $
  */
 
 #include "npx.h"
@@ -179,12 +179,12 @@ IDTVEC(fpu)
 #ifdef SMP
        MPLOCKED incl _cnt+V_TRAP
        MP_LOCK
-       movl    _cpl,%eax
-       pushl   %eax                    /* save original cpl */
+       movl    _curthread,%eax         /* save original cpl */
+       pushl   TD_MACH+MTD_CPL(%eax)
        pushl   $0                      /* dummy unit to finish intr frame */
 #else /* SMP */
-       movl    _cpl,%eax
-       pushl   %eax
+       movl    _curthread,%eax         /* save original cpl */
+       pushl   TD_MACH+MTD_CPL(%eax)
        pushl   $0                      /* dummy unit to finish intr frame */
        incl    _cnt+V_TRAP
 #endif /* SMP */
@@ -233,7 +233,8 @@ calltrap:
        FAKE_MCOUNT(_btrap)             /* init "from" _btrap -> calltrap */
        MPLOCKED incl _cnt+V_TRAP
        MP_LOCK
-       movl    _cpl,%ebx               /* keep orig. cpl here during trap() */
+       movl    _curthread,%eax         /* keep orig cpl here during call */
+       movl    TD_MACH+MTD_CPL(%eax),%ebx
        call    _trap
 
        /*
index 1207add..69fafe9 100644 (file)
@@ -36,7 +36,7 @@
  *
  *     from: @(#)machdep.c     7.4 (Berkeley) 6/3/91
  * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $
- * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.9 2003/06/22 04:30:39 dillon Exp $
+ * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.10 2003/06/22 08:54:18 dillon Exp $
  */
 
 #include "apm.h"
@@ -1865,11 +1865,11 @@ init386(first)
        /*
         * Prevent lowering of the ipl if we call tsleep() early.
         */
-       safepri = cpl;
        gd = &CPU_prvspace[0].globaldata;
 
        lwkt_init_thread(&thread0, proc0paddr);
        gd->gd_curthread = &thread0;
+       safepri = thread0.td_cpl = SWI_MASK | HWI_MASK;
        thread0.td_switch = cpu_heavy_switch;   /* YYY eventually LWKT */
        proc0.p_addr = (void *)thread0.td_kstack;
        proc0.p_thread = &thread0;
index 51136ad..fa0881d 100644 (file)
@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/i386/swtch.s,v 1.89.2.10 2003/01/23 03:36:24 ps Exp $
- * $DragonFly: src/sys/i386/i386/Attic/swtch.s,v 1.10 2003/06/22 04:30:39 dillon Exp $
+ * $DragonFly: src/sys/i386/i386/Attic/swtch.s,v 1.11 2003/06/22 08:54:18 dillon Exp $
  */
 
 #include "npx.h"
@@ -79,8 +79,6 @@ _tlb_flush_count:     .long   0
  */
 ENTRY(cpu_heavy_switch)
        movl    _curthread,%ecx
-       movl    _cpl,%edx                       /* YYY temporary */
-       movl    %edx,TD_MACH+MTD_CPL(%ecx)      /* YYY temporary */
        movl    TD_PROC(%ecx),%ecx
 
        cli
@@ -255,9 +253,7 @@ ENTRY(cpu_exit_switch)
  */
 ENTRY(cpu_heavy_restore)
        /* interrupts are disabled */
-       movl    TD_MACH+MTD_CPL(%eax),%edx
-       movl    %edx,_cpl                       /* YYY temporary */
-       movl    TD_PCB(%eax),%edx               /* YYY temporary */
+       movl    TD_PCB(%eax),%edx
        movl    TD_PROC(%eax),%ecx
 #ifdef DIAGNOSTIC
        cmpb    $SRUN,P_STAT(%ecx)
@@ -560,8 +556,6 @@ ENTRY(cpu_lwkt_switch)
        pushl   %edi
        pushfl
        movl    _curthread,%ecx
-       movl    _cpl,%edx                       /* YYY temporary */
-       movl    %edx,TD_MACH+MTD_CPL(%ecx)      /* YYY temporary */
        pushl   $cpu_lwkt_restore
        cli
        movl    %esp,TD_SP(%ecx)
@@ -572,8 +566,6 @@ ENTRY(cpu_lwkt_switch)
 /*
  * cpu_idle_restore()  (current thread in %eax on entry)
  *
- *     Don't bother setting up any regs other then %ebp so backtraces
- *     don't die.
  */
 ENTRY(cpu_lwkt_restore)
        popfl
@@ -581,13 +573,11 @@ ENTRY(cpu_lwkt_restore)
        popl    %esi
        popl    %ebx
        popl    %ebp
-       movl    TD_MACH+MTD_CPL(%eax),%ecx      /* YYY temporary */
-       movl    %ecx,_cpl                       /* YYY temporary */
-       andl    _ipending,%ecx                  /* YYY temporary */
+       movl    TD_MACH+MTD_CPL(%eax),%ecx      /* unmasked cpl? */
+       xorl    $-1,%ecx
+       andl    _ipending,%ecx
        je      1f
-       pushl   %ecx
-       call    splx                            /* YYY set gd_reqpri instead? */
-       addl    $4,%esp
+       call    splz                            /* execute unmasked ints */
 1:
        ret
 
index d2eb911..7dbb2f5 100644 (file)
@@ -36,7 +36,7 @@
  *
  *     from: @(#)trap.c        7.4 (Berkeley) 5/13/91
  * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $
- * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.4 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.5 2003/06/22 08:54:18 dillon Exp $
  */
 
 /*
@@ -946,15 +946,15 @@ trap_fatal(frame, eva)
                printf("(CRIT)");
        printf("\n");
        printf("interrupt mask          = ");
-       if ((cpl & net_imask) == net_imask)
+       if ((curthread->td_cpl & net_imask) == net_imask)
                printf("net ");
-       if ((cpl & tty_imask) == tty_imask)
+       if ((curthread->td_cpl & tty_imask) == tty_imask)
                printf("tty ");
-       if ((cpl & bio_imask) == bio_imask)
+       if ((curthread->td_cpl & bio_imask) == bio_imask)
                printf("bio ");
-       if ((cpl & cam_imask) == cam_imask)
+       if ((curthread->td_cpl & cam_imask) == cam_imask)
                printf("cam ");
-       if (cpl == 0)
+       if (curthread->td_cpl == 0)
                printf("none");
 #ifdef SMP
 /**
index ca873db..db92fc7 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/i386/vm86bios.s,v 1.15.2.1 2000/05/16 06:58:07 dillon Exp $
- * $DragonFly: src/sys/i386/i386/Attic/vm86bios.s,v 1.5 2003/06/18 18:29:55 dillon Exp $
+ * $DragonFly: src/sys/i386/i386/Attic/vm86bios.s,v 1.6 2003/06/22 08:54:18 dillon Exp $
  */
 
 #include <machine/asmacros.h>          /* miscellaneous asm macros */
@@ -140,15 +140,12 @@ ENTRY(vm86_bioscall)
        movl    $1,_in_vm86call         /* set flag for trap() */
 
        /*
-        * Return via _doreti
+        * Return via _doreti, restore the same cpl as our current cpl
         */
-#ifdef SMP
-       pushl   _cpl                    /* cpl to restore */
-#else
-       pushl   _cpl                    /* cpl to restore */
-#endif
+       movl    _curthread,%eax
+       pushl   TD_MACH+MTD_CPL(%eax)
        subl    $4,%esp                 /* dummy unit */
-       incb    _intr_nesting_level
+       incb    _intr_nesting_level     /* dummy to match doreti */
        MEXITCOUNT
        jmp     _doreti
 
index 67fdb3c..dee21ca 100644 (file)
@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/icu_ipl.s,v 1.6 1999/08/28 00:44:42 peter Exp $
- * $DragonFly: src/sys/i386/icu/Attic/icu_ipl.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/icu/Attic/icu_ipl.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
        .data
@@ -76,7 +76,9 @@ ENTRY(splz)
         * is undefined when %ecx is 0 so we can't rely on the secondary
         * btrl tests.
         */
-       movl    _cpl,%eax
+       pushl   %ebx
+       movl    _curthread,%ebx
+       movl    TD_MACH+MTD_CPL(%ebx),%eax
 splz_next:
        /*
         * We don't need any locking here.  (ipending & ~cpl) cannot grow 
@@ -87,6 +89,7 @@ splz_next:
        notl    %ecx
        andl    _ipending,%ecx
        jne     splz_unpend
+       popl    %ebx
        ret
 
        ALIGN_TEXT
@@ -103,16 +106,17 @@ splz_unpend:
         * We should change the interface so that the unit number is not
         * determined at config time.
         */
+       popl    %ebx
        jmp     *vec(,%ecx,4)
 
        ALIGN_TEXT
 splz_swi:
        pushl   %eax
        orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        call    *_ihandlers(,%ecx,4)
        popl    %eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        jmp     splz_next
 
 /*
index 1f1c6fd..49d5c21 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     from: vector.s, 386BSD 0.1 unknown origin
  * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $
- * $DragonFly: src/sys/i386/icu/Attic/icu_vector.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/icu/Attic/icu_vector.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 /*
@@ -66,10 +66,10 @@ IDTVEC(vec_name) ; \
        incl    _cnt+V_INTR ;   /* book-keeping can wait */ \
        movl    _intr_countp + (irq_num) * 4,%eax ; \
        incl    (%eax) ; \
-       movl    _curthread, %eax ; /* are we in a critical section? */  \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;      \
+       movl    _curthread, %ecx ; /* are we in a critical section? */  \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ecx) ;      \
        jge     1f ;    \
-       movl    _cpl,%eax ;     /* are we unmasking pending HWIs or SWIs? */ \
+       movl    TD_MACH+MTD_CPL(%ecx),%eax ; /* unmasking pending ints? */ \
        notl    %eax ; \
        andl    _ipending,%eax ; \
        jne     2f ;            /* yes, maybe handle them */ \
@@ -86,9 +86,9 @@ IDTVEC(vec_name) ; \
 2: ; \
        cmpb    $3,_intr_nesting_level ;        /* is there enough stack? */ \
        jae     1b ;            /* no, return */ \
-       movl    _cpl,%eax ; \
+       movl    TD_MACH+MTD_CPL(%ecx),%eax ;    \
        /* XXX next line is probably unnecessary now. */ \
-       movl    $HWI_MASK|SWI_MASK,_cpl ;       /* limit nesting ... */ \
+       movl    $HWI_MASK|SWI_MASK,TD_MACH+MTD_CPL(%ecx) ; /* limit nesting ... */ \
        incb    _intr_nesting_level ;   /* ... really limit it ... */ \
        sti ;                   /* ... to do this as early as possible */ \
        MAYBE_POPL_ES ;         /* discard most of thin frame ... */ \
@@ -130,10 +130,10 @@ IDTVEC(vec_name) ; \
        movb    %al,_imen + IRQ_BYTE(irq_num) ; \
        outb    %al,$icu+ICU_IMR_OFFSET ; \
        enable_icus ; \
-       movl    _curthread, %eax ; /* are we in a critical section? */  \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;      \
+       movl    _curthread, %ebx ; /* are we in a critical section? */  \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ebx) ;      \
        jge     2f ;    \
-       movl    _cpl,%eax ; /* is this interrupt masked by the cpl? */ \
+       movl    TD_MACH+MTD_CPL(%ebx),%eax ; /* is this interrupt masked by the cpl? */ \
        testb   $IRQ_BIT(irq_num),%reg ; \
        jne     2f ; \
        incb    _intr_nesting_level ; \
@@ -142,11 +142,11 @@ __CONCAT(Xresume,irq_num): ; \
        incl    _cnt+V_INTR ;   /* tally interrupts */ \
        movl    _intr_countp + (irq_num) * 4,%eax ; \
        incl    (%eax) ; \
-       movl    _cpl,%eax ; \
+       movl    TD_MACH+MTD_CPL(%ebx),%eax ; \
        pushl   %eax ; \
        pushl   _intr_unit + (irq_num) * 4 ; \
        orl     _intr_mask + (irq_num) * 4,%eax ; \
-       movl    %eax,_cpl ; \
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) ; \
        sti ; \
        call    *_intr_handler + (irq_num) * 4 ; \
        cli ;                   /* must unmask _imen and icu atomically */ \
index a8c9fde..87f1cd6 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/include/asnames.h,v 1.44.2.8 2003/01/22 20:14:53 jhb Exp $
- * $DragonFly: src/sys/i386/include/Attic/asnames.h,v 1.7 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/include/Attic/asnames.h,v 1.8 2003/06/22 08:54:20 dillon Exp $
  */
 
 #ifndef _MACHINE_ASNAMES_H_
 #define _cnt                           cnt
 #define _copyin_vector                 copyin_vector
 #define _copyout_vector                        copyout_vector
-#define _cpl                           cpl
 #define _cpl_lock                      cpl_lock
 #define _cpu                           cpu
 #define _cpu0prvpage                   cpu0prvpage
index 5601890..cfbdc13 100644 (file)
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/include/ipl.h,v 1.17.2.3 2002/12/17 18:04:02 sam Exp $
- * $DragonFly: src/sys/i386/include/Attic/ipl.h,v 1.2 2003/06/17 04:28:35 dillon Exp $
+ * $DragonFly: src/sys/i386/include/Attic/ipl.h,v 1.3 2003/06/22 08:54:20 dillon Exp $
  */
 
 #ifndef _MACHINE_IPL_H_
 #ifdef notyet /* in <sys/interrupt.h> until pci drivers stop hacking on them */
 extern unsigned bio_imask;     /* group of interrupts masked with splbio() */
 #endif
-extern unsigned cpl;           /* current priority level mask */
 #ifdef SMP
 extern unsigned cil;           /* current INTerrupt level mask */
 #endif
index 7a192ba..9302a1d 100644 (file)
@@ -1,10 +1,12 @@
 /*
  * i386/include/thread.h
  *
- * $DragonFly: src/sys/i386/include/Attic/thread.h,v 1.1 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/include/Attic/thread.h,v 1.2 2003/06/22 08:54:20 dillon Exp $
  */
 
 struct mi_thread {
     unsigned int       mtd_cpl;
 };
 
+#define td_cpl td_mach.mtd_cpl
+
index 21cb271..a8e41d5 100644 (file)
@@ -23,7 +23,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/apic_ipl.s,v 1.27.2.2 2000/09/30 02:49:35 ps Exp $
- * $DragonFly: src/sys/i386/isa/Attic/apic_ipl.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/isa/Attic/apic_ipl.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -99,7 +99,9 @@ ENTRY(splz)
         * NOTE: "bsfl %ecx,%ecx" is undefined when %ecx is 0 so we can't
         * rely on the secondary btrl tests.
         */
-       movl    _cpl,%eax
+       pushl   %ebx
+       movl    _curthread,%ebx
+       movl    TD_MACH+MTD_CPL(%ebx),%eax
 splz_next:
        /*
         * We don't need any locking here.  (ipending & ~cpl) cannot grow 
@@ -110,6 +112,7 @@ splz_next:
        notl    %ecx                    /* set bit = unmasked level */
        andl    _ipending,%ecx          /* set bit = unmasked pending INT */
        jne     splz_unpend
+       popl    %ebx
        ret
 
        ALIGN_TEXT
@@ -127,19 +130,21 @@ splz_unpend:
         * We should change the interface so that the unit number is not
         * determined at config time.
         *
-        * The vec[] routines build the proper frame on the stack,
-        * then call one of _Xintr0 thru _XintrNN.
+        * The vec[] routines build the proper frame on the stack so
+        * the interrupt will eventually return to the caller or splz,
+        * then calls one of _Xintr0 thru _XintrNN.
         */
+       popl    %ebx
        jmp     *_vec(,%ecx,4)
 
        ALIGN_TEXT
 splz_swi:
-       pushl   %eax
+       pushl   %eax                    /* save cpl across call */
        orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* set cpl for SWI */
        call    *_ihandlers(,%ecx,4)
        popl    %eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* restore cpl and loop */
        jmp     splz_next
 
 /*
index c9a7174..aa2267d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     from: vector.s, 386BSD 0.1 unknown origin
  * $FreeBSD: src/sys/i386/isa/apic_vector.s,v 1.47.2.5 2001/09/01 22:33:38 tegge Exp $
- * $DragonFly: src/sys/i386/isa/Attic/apic_vector.s,v 1.4 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/isa/Attic/apic_vector.s,v 1.5 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -230,10 +230,10 @@ IDTVEC(vec_name) ;                                                        \
        jz      3f ;                            /* no */                \
 ;                                                                      \
        APIC_ITRACE(apic_itrace_gotisrlock, irq_num, APIC_ITRACE_GOTISRLOCK) ;\
-       testl   $IRQ_BIT(irq_num), _cpl ;                               \
+       movl    _curthread,%ebx ;                                       \
+       testl   $IRQ_BIT(irq_num), TD_MACH+MTD_CPL(%eax) ;              \
        jne     2f ;                            /* this INT masked */   \
-       movl    _curthread,%eax ;                                       \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;                              \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ebx) ;                              \
        jge     2f ;                            /* in critical sec */   \
 ;                                                                      \
        incb    _intr_nesting_level ;                                   \
@@ -245,10 +245,11 @@ __CONCAT(Xresume,irq_num): ;                                              \
        movl    _intr_countp + (irq_num) * 4, %eax ;                    \
        lock ;  incl    (%eax) ;                                        \
 ;                                                                      \
-       movl    _cpl, %eax ;                                            \
-       pushl   %eax ;                                                  \
+       movl    _curthread, %ebx ;                                      \
+       movl    TD_MACH+MTD_CPL(%ebx), %eax ;                           \
+       pushl   %eax ;   /* cpl restored by doreti */                   \
        orl     _intr_mask + (irq_num) * 4, %eax ;                      \
-       movl    %eax, _cpl ;                                            \
+       movl    %eax, TD_MACH+MTD_CPL(%ebx) ;                           \
        lock ;                                                          \
        andl    $~IRQ_BIT(irq_num), _ipending ;                         \
 ;                                                                      \
@@ -294,7 +295,7 @@ __CONCAT(Xresume,irq_num): ;                                                \
        lock ;                                                          \
        orl     $IRQ_BIT(irq_num), _ipending ;                          \
        movl    $TDPRI_CRIT,_reqpri ;                                   \
-       testl   $IRQ_BIT(irq_num), _cpl ;                               \
+       testl   $IRQ_BIT(irq_num), TD_MACH+MTD_CPL(%ebx) ;              \
        jne     4f ;                            /* this INT masked */   \
        call    forward_irq ;    /* forward irq to lock holder */       \
        POP_FRAME ;                             /* and return */        \
@@ -448,8 +449,9 @@ _Xcpuast:
         */
        call    _get_mplock
 
-       movl    _cpl, %eax
-       pushl   %eax
+       movl    _curthread, %eax
+       pushl   TD_MACH+MTD_CPL(%eax)           /* cpl restored by doreti */
+
        orl     $AST_PENDING, _astpending       /* XXX */
        incb    _intr_nesting_level
        sti
@@ -504,8 +506,9 @@ _Xforward_irq:
        cmpb    $4, _intr_nesting_level
        jae     2f
        
-       movl    _cpl, %eax
-       pushl   %eax
+       movl    _curthread, %eax
+       pushl   TD_MACH+MTD_CPL(%eax)           /* cpl restored by doreti */
+
        incb    _intr_nesting_level
        sti
        
index e5cc4f7..c315f5c 100644 (file)
@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/icu_ipl.s,v 1.6 1999/08/28 00:44:42 peter Exp $
- * $DragonFly: src/sys/i386/isa/Attic/icu_ipl.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/isa/Attic/icu_ipl.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
        .data
@@ -76,7 +76,9 @@ ENTRY(splz)
         * is undefined when %ecx is 0 so we can't rely on the secondary
         * btrl tests.
         */
-       movl    _cpl,%eax
+       pushl   %ebx
+       movl    _curthread,%ebx
+       movl    TD_MACH+MTD_CPL(%ebx),%eax
 splz_next:
        /*
         * We don't need any locking here.  (ipending & ~cpl) cannot grow 
@@ -87,6 +89,7 @@ splz_next:
        notl    %ecx
        andl    _ipending,%ecx
        jne     splz_unpend
+       popl    %ebx
        ret
 
        ALIGN_TEXT
@@ -103,16 +106,17 @@ splz_unpend:
         * We should change the interface so that the unit number is not
         * determined at config time.
         */
+       popl    %ebx
        jmp     *vec(,%ecx,4)
 
        ALIGN_TEXT
 splz_swi:
        pushl   %eax
        orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        call    *_ihandlers(,%ecx,4)
        popl    %eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        jmp     splz_next
 
 /*
index 023bfe9..e05c47c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     from: vector.s, 386BSD 0.1 unknown origin
  * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $
- * $DragonFly: src/sys/i386/isa/Attic/icu_vector.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/isa/Attic/icu_vector.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 /*
@@ -66,10 +66,10 @@ IDTVEC(vec_name) ; \
        incl    _cnt+V_INTR ;   /* book-keeping can wait */ \
        movl    _intr_countp + (irq_num) * 4,%eax ; \
        incl    (%eax) ; \
-       movl    _curthread, %eax ; /* are we in a critical section? */  \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;      \
+       movl    _curthread, %ecx ; /* are we in a critical section? */  \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ecx) ;      \
        jge     1f ;    \
-       movl    _cpl,%eax ;     /* are we unmasking pending HWIs or SWIs? */ \
+       movl    TD_MACH+MTD_CPL(%ecx),%eax ; /* unmasking pending ints? */ \
        notl    %eax ; \
        andl    _ipending,%eax ; \
        jne     2f ;            /* yes, maybe handle them */ \
@@ -86,9 +86,9 @@ IDTVEC(vec_name) ; \
 2: ; \
        cmpb    $3,_intr_nesting_level ;        /* is there enough stack? */ \
        jae     1b ;            /* no, return */ \
-       movl    _cpl,%eax ; \
+       movl    TD_MACH+MTD_CPL(%ecx),%eax ;    \
        /* XXX next line is probably unnecessary now. */ \
-       movl    $HWI_MASK|SWI_MASK,_cpl ;       /* limit nesting ... */ \
+       movl    $HWI_MASK|SWI_MASK,TD_MACH+MTD_CPL(%ecx) ; /* limit nesting ... */ \
        incb    _intr_nesting_level ;   /* ... really limit it ... */ \
        sti ;                   /* ... to do this as early as possible */ \
        MAYBE_POPL_ES ;         /* discard most of thin frame ... */ \
@@ -130,10 +130,10 @@ IDTVEC(vec_name) ; \
        movb    %al,_imen + IRQ_BYTE(irq_num) ; \
        outb    %al,$icu+ICU_IMR_OFFSET ; \
        enable_icus ; \
-       movl    _curthread, %eax ; /* are we in a critical section? */  \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;      \
+       movl    _curthread, %ebx ; /* are we in a critical section? */  \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ebx) ;      \
        jge     2f ;    \
-       movl    _cpl,%eax ; /* is this interrupt masked by the cpl? */ \
+       movl    TD_MACH+MTD_CPL(%ebx),%eax ; /* is this interrupt masked by the cpl? */ \
        testb   $IRQ_BIT(irq_num),%reg ; \
        jne     2f ; \
        incb    _intr_nesting_level ; \
@@ -142,11 +142,11 @@ __CONCAT(Xresume,irq_num): ; \
        incl    _cnt+V_INTR ;   /* tally interrupts */ \
        movl    _intr_countp + (irq_num) * 4,%eax ; \
        incl    (%eax) ; \
-       movl    _cpl,%eax ; \
+       movl    TD_MACH+MTD_CPL(%ebx),%eax ; \
        pushl   %eax ; \
        pushl   _intr_unit + (irq_num) * 4 ; \
        orl     _intr_mask + (irq_num) * 4,%eax ; \
-       movl    %eax,_cpl ; \
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) ; \
        sti ; \
        call    *_intr_handler + (irq_num) * 4 ; \
        cli ;                   /* must unmask _imen and icu atomically */ \
index 6892e0c..44b5c53 100644 (file)
@@ -37,7 +37,7 @@
  *     @(#)ipl.s
  *
  * $FreeBSD: src/sys/i386/isa/ipl.s,v 1.32.2.3 2002/05/16 16:03:56 bde Exp $
- * $DragonFly: src/sys/i386/isa/Attic/ipl.s,v 1.2 2003/06/17 04:28:37 dillon Exp $
+ * $DragonFly: src/sys/i386/isa/Attic/ipl.s,v 1.3 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -45,7 +45,6 @@
  * AT/386
  * Vector interrupt control section
  *
- *  cpl                - Current interrupt disable mask
  *  *_imask    - Interrupt masks for various spl*() functions
  *  ipending   - Pending interrupts (set when a masked interrupt occurs)
  */
@@ -54,8 +53,6 @@
        ALIGN_DATA
 
 /* current priority (all off) */
-       .globl  _cpl
-_cpl:  .long   HWI_MASK | SWI_MASK
 
        .globl  _tty_imask
 _tty_imask:    .long   SWI_TTY_MASK
@@ -102,6 +99,7 @@ _doreti:
        FAKE_MCOUNT(_bintr)             /* init "from" _bintr -> _doreti */
        addl    $4,%esp                 /* discard unit number */
        popl    %eax                    /* cpl or cml to restore */
+       movl    _curthread,%ebx 
 doreti_next:
        /*
         * Check for pending HWIs and SWIs atomically with restoring cpl
@@ -123,7 +121,7 @@ doreti_next2:
 #endif
        andl    _ipending,%ecx          /* set bit = unmasked pending INT */
        jne     doreti_unpend
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        decb    _intr_nesting_level
 
        /* Check for ASTs that can be handled now. */
@@ -222,11 +220,7 @@ doreti_unpend:
        cmpl    $NHWI,%ecx
        jae     doreti_swi              /* software interrupt handling */
        cli                             /* else hardware int handling */
-#ifdef SMP
-       movl    %eax,_cpl               /* same as non-smp case right now */
-#else
-       movl    %eax,_cpl
-#endif
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* same as non-smp case right now */
        MEXITCOUNT
 #ifdef APIC_INTR_DIAGNOSTIC
        lock
@@ -262,13 +256,9 @@ doreti_swi:
         *
         * The SMP case is currently the same as the non-SMP case.
         */
-#ifdef SMP
        orl     imasks(,%ecx,4), %eax   /* or in imasks */
-       movl    %eax,_cpl               /* set cpl for call */
-#else
-       orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
-#endif
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)      /* set cpl for call */
+
        call    *%edx
        popl    %eax                    /* cpl to restore */
        jmp     doreti_next
index 2d3bbe1..eddd001 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/ipl_funcs.c,v 1.32.2.5 2002/12/17 18:04:02 sam Exp $
- * $DragonFly: src/sys/i386/isa/Attic/ipl_funcs.c,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/i386/isa/Attic/ipl_funcs.c,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -110,9 +110,9 @@ splassertfail(char *str, const char *msg, char *name, int level)
 void                                                   \
 NAME##assert(const char *msg)                          \
 {                                                      \
-       if ((cpl & (MODIFIER)) != (MODIFIER))           \
-               splassertfail("%s: not %s, cpl == %#x", \
-                   msg, __XSTRING(NAME) + 3, cpl);     \
+       if ((curthread->td_cpl & (MODIFIER)) != (MODIFIER)) \
+               splassertfail("%s: not %s, curthread->td_cpl == %#x",   \
+                   msg, __XSTRING(NAME) + 3, curthread->td_cpl);       \
 }
 #else
 #define        GENSPLASSERT(NAME, MODIFIER)
@@ -160,15 +160,15 @@ unsigned NAME(void)                               \
 {                                              \
        unsigned x;                             \
                                                \
-       x = cpl;                                \
-       cpl OP MODIFIER;                        \
+       x = curthread->td_cpl;                  \
+       curthread->td_cpl OP MODIFIER;          \
        return (x);                             \
 }
 
 void
 spl0(void)
 {
-       cpl = 0;
+       curthread->td_cpl = 0;
        if (ipending && curthread->td_pri < TDPRI_CRIT)
                splz();
 }
@@ -176,7 +176,7 @@ spl0(void)
 void
 splx(unsigned ipl)
 {
-       cpl = ipl;
+       curthread->td_cpl = ipl;
        if ((ipending & ~ipl) && curthread->td_pri < TDPRI_CRIT)
                splz();
 }
@@ -184,8 +184,8 @@ splx(unsigned ipl)
 intrmask_t
 splq(intrmask_t mask)
 { 
-       intrmask_t tmp = cpl;
-       cpl |= mask;
+       intrmask_t tmp = curthread->td_cpl;
+       curthread->td_cpl |= mask;
        return (tmp);
 }       
 
@@ -207,8 +207,8 @@ unsigned NAME(void)                         \
 {                                              \
        unsigned x;                             \
                                                \
-       x = cpl;                                \
-       cpl OP MODIFIER;                        \
+       x = curthread->td_cpl;                  \
+       curthread->td_cpl OP MODIFIER;          \
                                                \
        return (x);                             \
 }
@@ -223,7 +223,7 @@ void
 spl0(void)
 {
        KASSERT(inside_intr == 0, ("spl0: called from interrupt"));
-       cpl = 0;
+       curthread->td_cpl = 0;
        if (ipending && curthread->td_pri < TDPRI_CRIT)
                splz();
 }
@@ -237,8 +237,8 @@ spl0(void)
 void
 splx(unsigned ipl)
 {
-       cpl = ipl;
-       if (inside_intr == 0 && (ipending & ~cpl) != 0 &&
+       curthread->td_cpl = ipl;
+       if (inside_intr == 0 && (ipending & ~curthread->td_cpl) != 0 &&
            curthread->td_pri < TDPRI_CRIT) {
                splz();
        }
@@ -253,8 +253,8 @@ splx(unsigned ipl)
 intrmask_t
 splq(intrmask_t mask)
 {
-       intrmask_t tmp = cpl;
-       cpl |= mask;
+       intrmask_t tmp = curthread->td_cpl;
+       curthread->td_cpl |= mask;
        return (tmp);
 }
 
index adb2063..55c880f 100644 (file)
@@ -23,7 +23,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/apic_ipl.s,v 1.27.2.2 2000/09/30 02:49:35 ps Exp $
- * $DragonFly: src/sys/platform/pc32/apic/apic_ipl.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/apic/apic_ipl.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -99,7 +99,9 @@ ENTRY(splz)
         * NOTE: "bsfl %ecx,%ecx" is undefined when %ecx is 0 so we can't
         * rely on the secondary btrl tests.
         */
-       movl    _cpl,%eax
+       pushl   %ebx
+       movl    _curthread,%ebx
+       movl    TD_MACH+MTD_CPL(%ebx),%eax
 splz_next:
        /*
         * We don't need any locking here.  (ipending & ~cpl) cannot grow 
@@ -110,6 +112,7 @@ splz_next:
        notl    %ecx                    /* set bit = unmasked level */
        andl    _ipending,%ecx          /* set bit = unmasked pending INT */
        jne     splz_unpend
+       popl    %ebx
        ret
 
        ALIGN_TEXT
@@ -127,19 +130,21 @@ splz_unpend:
         * We should change the interface so that the unit number is not
         * determined at config time.
         *
-        * The vec[] routines build the proper frame on the stack,
-        * then call one of _Xintr0 thru _XintrNN.
+        * The vec[] routines build the proper frame on the stack so
+        * the interrupt will eventually return to the caller or splz,
+        * then calls one of _Xintr0 thru _XintrNN.
         */
+       popl    %ebx
        jmp     *_vec(,%ecx,4)
 
        ALIGN_TEXT
 splz_swi:
-       pushl   %eax
+       pushl   %eax                    /* save cpl across call */
        orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* set cpl for SWI */
        call    *_ihandlers(,%ecx,4)
        popl    %eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* restore cpl and loop */
        jmp     splz_next
 
 /*
index 6e81b41..09fefb9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     from: vector.s, 386BSD 0.1 unknown origin
  * $FreeBSD: src/sys/i386/isa/apic_vector.s,v 1.47.2.5 2001/09/01 22:33:38 tegge Exp $
- * $DragonFly: src/sys/platform/pc32/apic/apic_vector.s,v 1.4 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/apic/apic_vector.s,v 1.5 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -230,10 +230,10 @@ IDTVEC(vec_name) ;                                                        \
        jz      3f ;                            /* no */                \
 ;                                                                      \
        APIC_ITRACE(apic_itrace_gotisrlock, irq_num, APIC_ITRACE_GOTISRLOCK) ;\
-       testl   $IRQ_BIT(irq_num), _cpl ;                               \
+       movl    _curthread,%ebx ;                                       \
+       testl   $IRQ_BIT(irq_num), TD_MACH+MTD_CPL(%eax) ;              \
        jne     2f ;                            /* this INT masked */   \
-       movl    _curthread,%eax ;                                       \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;                              \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ebx) ;                              \
        jge     2f ;                            /* in critical sec */   \
 ;                                                                      \
        incb    _intr_nesting_level ;                                   \
@@ -245,10 +245,11 @@ __CONCAT(Xresume,irq_num): ;                                              \
        movl    _intr_countp + (irq_num) * 4, %eax ;                    \
        lock ;  incl    (%eax) ;                                        \
 ;                                                                      \
-       movl    _cpl, %eax ;                                            \
-       pushl   %eax ;                                                  \
+       movl    _curthread, %ebx ;                                      \
+       movl    TD_MACH+MTD_CPL(%ebx), %eax ;                           \
+       pushl   %eax ;   /* cpl restored by doreti */                   \
        orl     _intr_mask + (irq_num) * 4, %eax ;                      \
-       movl    %eax, _cpl ;                                            \
+       movl    %eax, TD_MACH+MTD_CPL(%ebx) ;                           \
        lock ;                                                          \
        andl    $~IRQ_BIT(irq_num), _ipending ;                         \
 ;                                                                      \
@@ -294,7 +295,7 @@ __CONCAT(Xresume,irq_num): ;                                                \
        lock ;                                                          \
        orl     $IRQ_BIT(irq_num), _ipending ;                          \
        movl    $TDPRI_CRIT,_reqpri ;                                   \
-       testl   $IRQ_BIT(irq_num), _cpl ;                               \
+       testl   $IRQ_BIT(irq_num), TD_MACH+MTD_CPL(%ebx) ;              \
        jne     4f ;                            /* this INT masked */   \
        call    forward_irq ;    /* forward irq to lock holder */       \
        POP_FRAME ;                             /* and return */        \
@@ -448,8 +449,9 @@ _Xcpuast:
         */
        call    _get_mplock
 
-       movl    _cpl, %eax
-       pushl   %eax
+       movl    _curthread, %eax
+       pushl   TD_MACH+MTD_CPL(%eax)           /* cpl restored by doreti */
+
        orl     $AST_PENDING, _astpending       /* XXX */
        incb    _intr_nesting_level
        sti
@@ -504,8 +506,9 @@ _Xforward_irq:
        cmpb    $4, _intr_nesting_level
        jae     2f
        
-       movl    _cpl, %eax
-       pushl   %eax
+       movl    _curthread, %eax
+       pushl   TD_MACH+MTD_CPL(%eax)           /* cpl restored by doreti */
+
        incb    _intr_nesting_level
        sti
        
index d470eda..5605f3d 100644 (file)
@@ -35,7 +35,7 @@
  *
  *     from: @(#)autoconf.c    7.1 (Berkeley) 5/9/91
  * $FreeBSD: src/sys/i386/i386/autoconf.c,v 1.146.2.2 2001/06/07 06:05:58 dd Exp $
- * $DragonFly: src/sys/platform/pc32/i386/autoconf.c,v 1.2 2003/06/17 04:28:35 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/i386/autoconf.c,v 1.3 2003/06/22 08:54:18 dillon Exp $
  */
 
 /*
@@ -67,6 +67,7 @@
 #include <sys/malloc.h>
 #include <sys/mount.h>
 #include <sys/cons.h>
+#include <sys/thread.h>
 
 #include <machine/bootinfo.h>
 #include <machine/ipl.h>
 #include <i386/isa/icu.h>
 #endif /* APIC_IO */
 
+#include <machine/pcb.h>
+#include <machine/pcb_ext.h>
+#include <machine/vm86.h>
+#include <machine/globaldata.h>
+#include <machine/globals.h>
+
 #if NISA > 0
 #include <isa/isavar.h>
 
@@ -171,7 +178,7 @@ configure(dummy)
         * completely safe (since a panic may occur in a critical region
         * at splhigh()), but we want at least bio interrupts to work.
         */
-       safepri = cpl;
+       safepri = curthread->td_cpl;
 }
 
 static void
index 0d64616..356d003 100644 (file)
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $
- * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.3 2003/06/20 02:09:50 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.4 2003/06/22 08:54:18 dillon Exp $
  */
 
 #include "npx.h"
@@ -179,12 +179,12 @@ IDTVEC(fpu)
 #ifdef SMP
        MPLOCKED incl _cnt+V_TRAP
        MP_LOCK
-       movl    _cpl,%eax
-       pushl   %eax                    /* save original cpl */
+       movl    _curthread,%eax         /* save original cpl */
+       pushl   TD_MACH+MTD_CPL(%eax)
        pushl   $0                      /* dummy unit to finish intr frame */
 #else /* SMP */
-       movl    _cpl,%eax
-       pushl   %eax
+       movl    _curthread,%eax         /* save original cpl */
+       pushl   TD_MACH+MTD_CPL(%eax)
        pushl   $0                      /* dummy unit to finish intr frame */
        incl    _cnt+V_TRAP
 #endif /* SMP */
@@ -233,7 +233,8 @@ calltrap:
        FAKE_MCOUNT(_btrap)             /* init "from" _btrap -> calltrap */
        MPLOCKED incl _cnt+V_TRAP
        MP_LOCK
-       movl    _cpl,%ebx               /* keep orig. cpl here during trap() */
+       movl    _curthread,%eax         /* keep orig cpl here during call */
+       movl    TD_MACH+MTD_CPL(%eax),%ebx
        call    _trap
 
        /*
index 3b885b0..3347bbf 100644 (file)
@@ -36,7 +36,7 @@
  *
  *     from: @(#)machdep.c     7.4 (Berkeley) 6/3/91
  * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $
- * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.9 2003/06/22 04:30:39 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.10 2003/06/22 08:54:18 dillon Exp $
  */
 
 #include "apm.h"
@@ -1865,11 +1865,11 @@ init386(first)
        /*
         * Prevent lowering of the ipl if we call tsleep() early.
         */
-       safepri = cpl;
        gd = &CPU_prvspace[0].globaldata;
 
        lwkt_init_thread(&thread0, proc0paddr);
        gd->gd_curthread = &thread0;
+       safepri = thread0.td_cpl = SWI_MASK | HWI_MASK;
        thread0.td_switch = cpu_heavy_switch;   /* YYY eventually LWKT */
        proc0.p_addr = (void *)thread0.td_kstack;
        proc0.p_thread = &thread0;
index b9604e4..4820bf6 100644 (file)
@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/i386/swtch.s,v 1.89.2.10 2003/01/23 03:36:24 ps Exp $
- * $DragonFly: src/sys/platform/pc32/i386/swtch.s,v 1.10 2003/06/22 04:30:39 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/i386/swtch.s,v 1.11 2003/06/22 08:54:18 dillon Exp $
  */
 
 #include "npx.h"
@@ -79,8 +79,6 @@ _tlb_flush_count:     .long   0
  */
 ENTRY(cpu_heavy_switch)
        movl    _curthread,%ecx
-       movl    _cpl,%edx                       /* YYY temporary */
-       movl    %edx,TD_MACH+MTD_CPL(%ecx)      /* YYY temporary */
        movl    TD_PROC(%ecx),%ecx
 
        cli
@@ -255,9 +253,7 @@ ENTRY(cpu_exit_switch)
  */
 ENTRY(cpu_heavy_restore)
        /* interrupts are disabled */
-       movl    TD_MACH+MTD_CPL(%eax),%edx
-       movl    %edx,_cpl                       /* YYY temporary */
-       movl    TD_PCB(%eax),%edx               /* YYY temporary */
+       movl    TD_PCB(%eax),%edx
        movl    TD_PROC(%eax),%ecx
 #ifdef DIAGNOSTIC
        cmpb    $SRUN,P_STAT(%ecx)
@@ -560,8 +556,6 @@ ENTRY(cpu_lwkt_switch)
        pushl   %edi
        pushfl
        movl    _curthread,%ecx
-       movl    _cpl,%edx                       /* YYY temporary */
-       movl    %edx,TD_MACH+MTD_CPL(%ecx)      /* YYY temporary */
        pushl   $cpu_lwkt_restore
        cli
        movl    %esp,TD_SP(%ecx)
@@ -572,8 +566,6 @@ ENTRY(cpu_lwkt_switch)
 /*
  * cpu_idle_restore()  (current thread in %eax on entry)
  *
- *     Don't bother setting up any regs other then %ebp so backtraces
- *     don't die.
  */
 ENTRY(cpu_lwkt_restore)
        popfl
@@ -581,13 +573,11 @@ ENTRY(cpu_lwkt_restore)
        popl    %esi
        popl    %ebx
        popl    %ebp
-       movl    TD_MACH+MTD_CPL(%eax),%ecx      /* YYY temporary */
-       movl    %ecx,_cpl                       /* YYY temporary */
-       andl    _ipending,%ecx                  /* YYY temporary */
+       movl    TD_MACH+MTD_CPL(%eax),%ecx      /* unmasked cpl? */
+       xorl    $-1,%ecx
+       andl    _ipending,%ecx
        je      1f
-       pushl   %ecx
-       call    splx                            /* YYY set gd_reqpri instead? */
-       addl    $4,%esp
+       call    splz                            /* execute unmasked ints */
 1:
        ret
 
index 8c5f16a..b8875fd 100644 (file)
@@ -36,7 +36,7 @@
  *
  *     from: @(#)trap.c        7.4 (Berkeley) 5/13/91
  * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $
- * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.4 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.5 2003/06/22 08:54:18 dillon Exp $
  */
 
 /*
@@ -946,15 +946,15 @@ trap_fatal(frame, eva)
                printf("(CRIT)");
        printf("\n");
        printf("interrupt mask          = ");
-       if ((cpl & net_imask) == net_imask)
+       if ((curthread->td_cpl & net_imask) == net_imask)
                printf("net ");
-       if ((cpl & tty_imask) == tty_imask)
+       if ((curthread->td_cpl & tty_imask) == tty_imask)
                printf("tty ");
-       if ((cpl & bio_imask) == bio_imask)
+       if ((curthread->td_cpl & bio_imask) == bio_imask)
                printf("bio ");
-       if ((cpl & cam_imask) == cam_imask)
+       if ((curthread->td_cpl & cam_imask) == cam_imask)
                printf("cam ");
-       if (cpl == 0)
+       if (curthread->td_cpl == 0)
                printf("none");
 #ifdef SMP
 /**
index 4483bfd..230f157 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/i386/vm86bios.s,v 1.15.2.1 2000/05/16 06:58:07 dillon Exp $
- * $DragonFly: src/sys/platform/pc32/i386/vm86bios.s,v 1.5 2003/06/18 18:29:55 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/i386/vm86bios.s,v 1.6 2003/06/22 08:54:18 dillon Exp $
  */
 
 #include <machine/asmacros.h>          /* miscellaneous asm macros */
@@ -140,15 +140,12 @@ ENTRY(vm86_bioscall)
        movl    $1,_in_vm86call         /* set flag for trap() */
 
        /*
-        * Return via _doreti
+        * Return via _doreti, restore the same cpl as our current cpl
         */
-#ifdef SMP
-       pushl   _cpl                    /* cpl to restore */
-#else
-       pushl   _cpl                    /* cpl to restore */
-#endif
+       movl    _curthread,%eax
+       pushl   TD_MACH+MTD_CPL(%eax)
        subl    $4,%esp                 /* dummy unit */
-       incb    _intr_nesting_level
+       incb    _intr_nesting_level     /* dummy to match doreti */
        MEXITCOUNT
        jmp     _doreti
 
index 3d4824e..ae2f90d 100644 (file)
@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/icu_ipl.s,v 1.6 1999/08/28 00:44:42 peter Exp $
- * $DragonFly: src/sys/platform/pc32/icu/icu_ipl.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/icu/icu_ipl.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
        .data
@@ -76,7 +76,9 @@ ENTRY(splz)
         * is undefined when %ecx is 0 so we can't rely on the secondary
         * btrl tests.
         */
-       movl    _cpl,%eax
+       pushl   %ebx
+       movl    _curthread,%ebx
+       movl    TD_MACH+MTD_CPL(%ebx),%eax
 splz_next:
        /*
         * We don't need any locking here.  (ipending & ~cpl) cannot grow 
@@ -87,6 +89,7 @@ splz_next:
        notl    %ecx
        andl    _ipending,%ecx
        jne     splz_unpend
+       popl    %ebx
        ret
 
        ALIGN_TEXT
@@ -103,16 +106,17 @@ splz_unpend:
         * We should change the interface so that the unit number is not
         * determined at config time.
         */
+       popl    %ebx
        jmp     *vec(,%ecx,4)
 
        ALIGN_TEXT
 splz_swi:
        pushl   %eax
        orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        call    *_ihandlers(,%ecx,4)
        popl    %eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        jmp     splz_next
 
 /*
index 960b6d4..c6b8a54 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     from: vector.s, 386BSD 0.1 unknown origin
  * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $
- * $DragonFly: src/sys/platform/pc32/icu/icu_vector.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/icu/icu_vector.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 /*
@@ -66,10 +66,10 @@ IDTVEC(vec_name) ; \
        incl    _cnt+V_INTR ;   /* book-keeping can wait */ \
        movl    _intr_countp + (irq_num) * 4,%eax ; \
        incl    (%eax) ; \
-       movl    _curthread, %eax ; /* are we in a critical section? */  \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;      \
+       movl    _curthread, %ecx ; /* are we in a critical section? */  \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ecx) ;      \
        jge     1f ;    \
-       movl    _cpl,%eax ;     /* are we unmasking pending HWIs or SWIs? */ \
+       movl    TD_MACH+MTD_CPL(%ecx),%eax ; /* unmasking pending ints? */ \
        notl    %eax ; \
        andl    _ipending,%eax ; \
        jne     2f ;            /* yes, maybe handle them */ \
@@ -86,9 +86,9 @@ IDTVEC(vec_name) ; \
 2: ; \
        cmpb    $3,_intr_nesting_level ;        /* is there enough stack? */ \
        jae     1b ;            /* no, return */ \
-       movl    _cpl,%eax ; \
+       movl    TD_MACH+MTD_CPL(%ecx),%eax ;    \
        /* XXX next line is probably unnecessary now. */ \
-       movl    $HWI_MASK|SWI_MASK,_cpl ;       /* limit nesting ... */ \
+       movl    $HWI_MASK|SWI_MASK,TD_MACH+MTD_CPL(%ecx) ; /* limit nesting ... */ \
        incb    _intr_nesting_level ;   /* ... really limit it ... */ \
        sti ;                   /* ... to do this as early as possible */ \
        MAYBE_POPL_ES ;         /* discard most of thin frame ... */ \
@@ -130,10 +130,10 @@ IDTVEC(vec_name) ; \
        movb    %al,_imen + IRQ_BYTE(irq_num) ; \
        outb    %al,$icu+ICU_IMR_OFFSET ; \
        enable_icus ; \
-       movl    _curthread, %eax ; /* are we in a critical section? */  \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;      \
+       movl    _curthread, %ebx ; /* are we in a critical section? */  \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ebx) ;      \
        jge     2f ;    \
-       movl    _cpl,%eax ; /* is this interrupt masked by the cpl? */ \
+       movl    TD_MACH+MTD_CPL(%ebx),%eax ; /* is this interrupt masked by the cpl? */ \
        testb   $IRQ_BIT(irq_num),%reg ; \
        jne     2f ; \
        incb    _intr_nesting_level ; \
@@ -142,11 +142,11 @@ __CONCAT(Xresume,irq_num): ; \
        incl    _cnt+V_INTR ;   /* tally interrupts */ \
        movl    _intr_countp + (irq_num) * 4,%eax ; \
        incl    (%eax) ; \
-       movl    _cpl,%eax ; \
+       movl    TD_MACH+MTD_CPL(%ebx),%eax ; \
        pushl   %eax ; \
        pushl   _intr_unit + (irq_num) * 4 ; \
        orl     _intr_mask + (irq_num) * 4,%eax ; \
-       movl    %eax,_cpl ; \
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) ; \
        sti ; \
        call    *_intr_handler + (irq_num) * 4 ; \
        cli ;                   /* must unmask _imen and icu atomically */ \
index 5afb9a1..0a8c8fb 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/include/asnames.h,v 1.44.2.8 2003/01/22 20:14:53 jhb Exp $
- * $DragonFly: src/sys/platform/pc32/include/Attic/asnames.h,v 1.7 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/include/Attic/asnames.h,v 1.8 2003/06/22 08:54:20 dillon Exp $
  */
 
 #ifndef _MACHINE_ASNAMES_H_
 #define _cnt                           cnt
 #define _copyin_vector                 copyin_vector
 #define _copyout_vector                        copyout_vector
-#define _cpl                           cpl
 #define _cpl_lock                      cpl_lock
 #define _cpu                           cpu
 #define _cpu0prvpage                   cpu0prvpage
index ecdc179..d256b22 100644 (file)
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/include/ipl.h,v 1.17.2.3 2002/12/17 18:04:02 sam Exp $
- * $DragonFly: src/sys/platform/pc32/include/ipl.h,v 1.2 2003/06/17 04:28:35 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/include/ipl.h,v 1.3 2003/06/22 08:54:20 dillon Exp $
  */
 
 #ifndef _MACHINE_IPL_H_
 #ifdef notyet /* in <sys/interrupt.h> until pci drivers stop hacking on them */
 extern unsigned bio_imask;     /* group of interrupts masked with splbio() */
 #endif
-extern unsigned cpl;           /* current priority level mask */
 #ifdef SMP
 extern unsigned cil;           /* current INTerrupt level mask */
 #endif
index 0faf770..7cb60ac 100644 (file)
@@ -1,10 +1,12 @@
 /*
  * i386/include/thread.h
  *
- * $DragonFly: src/sys/platform/pc32/include/thread.h,v 1.1 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/include/thread.h,v 1.2 2003/06/22 08:54:20 dillon Exp $
  */
 
 struct mi_thread {
     unsigned int       mtd_cpl;
 };
 
+#define td_cpl td_mach.mtd_cpl
+
index b49e3a9..5f07964 100644 (file)
@@ -23,7 +23,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/apic_ipl.s,v 1.27.2.2 2000/09/30 02:49:35 ps Exp $
- * $DragonFly: src/sys/platform/pc32/isa/Attic/apic_ipl.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/isa/Attic/apic_ipl.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -99,7 +99,9 @@ ENTRY(splz)
         * NOTE: "bsfl %ecx,%ecx" is undefined when %ecx is 0 so we can't
         * rely on the secondary btrl tests.
         */
-       movl    _cpl,%eax
+       pushl   %ebx
+       movl    _curthread,%ebx
+       movl    TD_MACH+MTD_CPL(%ebx),%eax
 splz_next:
        /*
         * We don't need any locking here.  (ipending & ~cpl) cannot grow 
@@ -110,6 +112,7 @@ splz_next:
        notl    %ecx                    /* set bit = unmasked level */
        andl    _ipending,%ecx          /* set bit = unmasked pending INT */
        jne     splz_unpend
+       popl    %ebx
        ret
 
        ALIGN_TEXT
@@ -127,19 +130,21 @@ splz_unpend:
         * We should change the interface so that the unit number is not
         * determined at config time.
         *
-        * The vec[] routines build the proper frame on the stack,
-        * then call one of _Xintr0 thru _XintrNN.
+        * The vec[] routines build the proper frame on the stack so
+        * the interrupt will eventually return to the caller or splz,
+        * then calls one of _Xintr0 thru _XintrNN.
         */
+       popl    %ebx
        jmp     *_vec(,%ecx,4)
 
        ALIGN_TEXT
 splz_swi:
-       pushl   %eax
+       pushl   %eax                    /* save cpl across call */
        orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* set cpl for SWI */
        call    *_ihandlers(,%ecx,4)
        popl    %eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* restore cpl and loop */
        jmp     splz_next
 
 /*
index a6a6164..e4b27a5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     from: vector.s, 386BSD 0.1 unknown origin
  * $FreeBSD: src/sys/i386/isa/apic_vector.s,v 1.47.2.5 2001/09/01 22:33:38 tegge Exp $
- * $DragonFly: src/sys/platform/pc32/isa/Attic/apic_vector.s,v 1.4 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/isa/Attic/apic_vector.s,v 1.5 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -230,10 +230,10 @@ IDTVEC(vec_name) ;                                                        \
        jz      3f ;                            /* no */                \
 ;                                                                      \
        APIC_ITRACE(apic_itrace_gotisrlock, irq_num, APIC_ITRACE_GOTISRLOCK) ;\
-       testl   $IRQ_BIT(irq_num), _cpl ;                               \
+       movl    _curthread,%ebx ;                                       \
+       testl   $IRQ_BIT(irq_num), TD_MACH+MTD_CPL(%eax) ;              \
        jne     2f ;                            /* this INT masked */   \
-       movl    _curthread,%eax ;                                       \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;                              \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ebx) ;                              \
        jge     2f ;                            /* in critical sec */   \
 ;                                                                      \
        incb    _intr_nesting_level ;                                   \
@@ -245,10 +245,11 @@ __CONCAT(Xresume,irq_num): ;                                              \
        movl    _intr_countp + (irq_num) * 4, %eax ;                    \
        lock ;  incl    (%eax) ;                                        \
 ;                                                                      \
-       movl    _cpl, %eax ;                                            \
-       pushl   %eax ;                                                  \
+       movl    _curthread, %ebx ;                                      \
+       movl    TD_MACH+MTD_CPL(%ebx), %eax ;                           \
+       pushl   %eax ;   /* cpl restored by doreti */                   \
        orl     _intr_mask + (irq_num) * 4, %eax ;                      \
-       movl    %eax, _cpl ;                                            \
+       movl    %eax, TD_MACH+MTD_CPL(%ebx) ;                           \
        lock ;                                                          \
        andl    $~IRQ_BIT(irq_num), _ipending ;                         \
 ;                                                                      \
@@ -294,7 +295,7 @@ __CONCAT(Xresume,irq_num): ;                                                \
        lock ;                                                          \
        orl     $IRQ_BIT(irq_num), _ipending ;                          \
        movl    $TDPRI_CRIT,_reqpri ;                                   \
-       testl   $IRQ_BIT(irq_num), _cpl ;                               \
+       testl   $IRQ_BIT(irq_num), TD_MACH+MTD_CPL(%ebx) ;              \
        jne     4f ;                            /* this INT masked */   \
        call    forward_irq ;    /* forward irq to lock holder */       \
        POP_FRAME ;                             /* and return */        \
@@ -448,8 +449,9 @@ _Xcpuast:
         */
        call    _get_mplock
 
-       movl    _cpl, %eax
-       pushl   %eax
+       movl    _curthread, %eax
+       pushl   TD_MACH+MTD_CPL(%eax)           /* cpl restored by doreti */
+
        orl     $AST_PENDING, _astpending       /* XXX */
        incb    _intr_nesting_level
        sti
@@ -504,8 +506,9 @@ _Xforward_irq:
        cmpb    $4, _intr_nesting_level
        jae     2f
        
-       movl    _cpl, %eax
-       pushl   %eax
+       movl    _curthread, %eax
+       pushl   TD_MACH+MTD_CPL(%eax)           /* cpl restored by doreti */
+
        incb    _intr_nesting_level
        sti
        
index ce975aa..c511743 100644 (file)
@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/icu_ipl.s,v 1.6 1999/08/28 00:44:42 peter Exp $
- * $DragonFly: src/sys/platform/pc32/isa/Attic/icu_ipl.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/isa/Attic/icu_ipl.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
        .data
@@ -76,7 +76,9 @@ ENTRY(splz)
         * is undefined when %ecx is 0 so we can't rely on the secondary
         * btrl tests.
         */
-       movl    _cpl,%eax
+       pushl   %ebx
+       movl    _curthread,%ebx
+       movl    TD_MACH+MTD_CPL(%ebx),%eax
 splz_next:
        /*
         * We don't need any locking here.  (ipending & ~cpl) cannot grow 
@@ -87,6 +89,7 @@ splz_next:
        notl    %ecx
        andl    _ipending,%ecx
        jne     splz_unpend
+       popl    %ebx
        ret
 
        ALIGN_TEXT
@@ -103,16 +106,17 @@ splz_unpend:
         * We should change the interface so that the unit number is not
         * determined at config time.
         */
+       popl    %ebx
        jmp     *vec(,%ecx,4)
 
        ALIGN_TEXT
 splz_swi:
        pushl   %eax
        orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        call    *_ihandlers(,%ecx,4)
        popl    %eax
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        jmp     splz_next
 
 /*
index c7dd0a2..5bab186 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     from: vector.s, 386BSD 0.1 unknown origin
  * $FreeBSD: src/sys/i386/isa/icu_vector.s,v 1.14.2.2 2000/07/18 21:12:42 dfr Exp $
- * $DragonFly: src/sys/platform/pc32/isa/Attic/icu_vector.s,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/isa/Attic/icu_vector.s,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 /*
@@ -66,10 +66,10 @@ IDTVEC(vec_name) ; \
        incl    _cnt+V_INTR ;   /* book-keeping can wait */ \
        movl    _intr_countp + (irq_num) * 4,%eax ; \
        incl    (%eax) ; \
-       movl    _curthread, %eax ; /* are we in a critical section? */  \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;      \
+       movl    _curthread, %ecx ; /* are we in a critical section? */  \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ecx) ;      \
        jge     1f ;    \
-       movl    _cpl,%eax ;     /* are we unmasking pending HWIs or SWIs? */ \
+       movl    TD_MACH+MTD_CPL(%ecx),%eax ; /* unmasking pending ints? */ \
        notl    %eax ; \
        andl    _ipending,%eax ; \
        jne     2f ;            /* yes, maybe handle them */ \
@@ -86,9 +86,9 @@ IDTVEC(vec_name) ; \
 2: ; \
        cmpb    $3,_intr_nesting_level ;        /* is there enough stack? */ \
        jae     1b ;            /* no, return */ \
-       movl    _cpl,%eax ; \
+       movl    TD_MACH+MTD_CPL(%ecx),%eax ;    \
        /* XXX next line is probably unnecessary now. */ \
-       movl    $HWI_MASK|SWI_MASK,_cpl ;       /* limit nesting ... */ \
+       movl    $HWI_MASK|SWI_MASK,TD_MACH+MTD_CPL(%ecx) ; /* limit nesting ... */ \
        incb    _intr_nesting_level ;   /* ... really limit it ... */ \
        sti ;                   /* ... to do this as early as possible */ \
        MAYBE_POPL_ES ;         /* discard most of thin frame ... */ \
@@ -130,10 +130,10 @@ IDTVEC(vec_name) ; \
        movb    %al,_imen + IRQ_BYTE(irq_num) ; \
        outb    %al,$icu+ICU_IMR_OFFSET ; \
        enable_icus ; \
-       movl    _curthread, %eax ; /* are we in a critical section? */  \
-       cmpl    $TDPRI_CRIT,TD_PRI(%eax) ;      \
+       movl    _curthread, %ebx ; /* are we in a critical section? */  \
+       cmpl    $TDPRI_CRIT,TD_PRI(%ebx) ;      \
        jge     2f ;    \
-       movl    _cpl,%eax ; /* is this interrupt masked by the cpl? */ \
+       movl    TD_MACH+MTD_CPL(%ebx),%eax ; /* is this interrupt masked by the cpl? */ \
        testb   $IRQ_BIT(irq_num),%reg ; \
        jne     2f ; \
        incb    _intr_nesting_level ; \
@@ -142,11 +142,11 @@ __CONCAT(Xresume,irq_num): ; \
        incl    _cnt+V_INTR ;   /* tally interrupts */ \
        movl    _intr_countp + (irq_num) * 4,%eax ; \
        incl    (%eax) ; \
-       movl    _cpl,%eax ; \
+       movl    TD_MACH+MTD_CPL(%ebx),%eax ; \
        pushl   %eax ; \
        pushl   _intr_unit + (irq_num) * 4 ; \
        orl     _intr_mask + (irq_num) * 4,%eax ; \
-       movl    %eax,_cpl ; \
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) ; \
        sti ; \
        call    *_intr_handler + (irq_num) * 4 ; \
        cli ;                   /* must unmask _imen and icu atomically */ \
index 46ca2f7..6b2baac 100644 (file)
@@ -37,7 +37,7 @@
  *     @(#)ipl.s
  *
  * $FreeBSD: src/sys/i386/isa/ipl.s,v 1.32.2.3 2002/05/16 16:03:56 bde Exp $
- * $DragonFly: src/sys/platform/pc32/isa/ipl.s,v 1.2 2003/06/17 04:28:37 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/isa/ipl.s,v 1.3 2003/06/22 08:54:22 dillon Exp $
  */
 
 
@@ -45,7 +45,6 @@
  * AT/386
  * Vector interrupt control section
  *
- *  cpl                - Current interrupt disable mask
  *  *_imask    - Interrupt masks for various spl*() functions
  *  ipending   - Pending interrupts (set when a masked interrupt occurs)
  */
@@ -54,8 +53,6 @@
        ALIGN_DATA
 
 /* current priority (all off) */
-       .globl  _cpl
-_cpl:  .long   HWI_MASK | SWI_MASK
 
        .globl  _tty_imask
 _tty_imask:    .long   SWI_TTY_MASK
@@ -102,6 +99,7 @@ _doreti:
        FAKE_MCOUNT(_bintr)             /* init "from" _bintr -> _doreti */
        addl    $4,%esp                 /* discard unit number */
        popl    %eax                    /* cpl or cml to restore */
+       movl    _curthread,%ebx 
 doreti_next:
        /*
         * Check for pending HWIs and SWIs atomically with restoring cpl
@@ -123,7 +121,7 @@ doreti_next2:
 #endif
        andl    _ipending,%ecx          /* set bit = unmasked pending INT */
        jne     doreti_unpend
-       movl    %eax,_cpl
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)
        decb    _intr_nesting_level
 
        /* Check for ASTs that can be handled now. */
@@ -222,11 +220,7 @@ doreti_unpend:
        cmpl    $NHWI,%ecx
        jae     doreti_swi              /* software interrupt handling */
        cli                             /* else hardware int handling */
-#ifdef SMP
-       movl    %eax,_cpl               /* same as non-smp case right now */
-#else
-       movl    %eax,_cpl
-#endif
+       movl    %eax,TD_MACH+MTD_CPL(%ebx) /* same as non-smp case right now */
        MEXITCOUNT
 #ifdef APIC_INTR_DIAGNOSTIC
        lock
@@ -262,13 +256,9 @@ doreti_swi:
         *
         * The SMP case is currently the same as the non-SMP case.
         */
-#ifdef SMP
        orl     imasks(,%ecx,4), %eax   /* or in imasks */
-       movl    %eax,_cpl               /* set cpl for call */
-#else
-       orl     imasks(,%ecx,4),%eax
-       movl    %eax,_cpl
-#endif
+       movl    %eax,TD_MACH+MTD_CPL(%ebx)      /* set cpl for call */
+
        call    *%edx
        popl    %eax                    /* cpl to restore */
        jmp     doreti_next
index d3b7f5a..7519b04 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/ipl_funcs.c,v 1.32.2.5 2002/12/17 18:04:02 sam Exp $
- * $DragonFly: src/sys/platform/pc32/isa/ipl_funcs.c,v 1.3 2003/06/21 07:54:56 dillon Exp $
+ * $DragonFly: src/sys/platform/pc32/isa/ipl_funcs.c,v 1.4 2003/06/22 08:54:22 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -110,9 +110,9 @@ splassertfail(char *str, const char *msg, char *name, int level)
 void                                                   \
 NAME##assert(const char *msg)                          \
 {                                                      \
-       if ((cpl & (MODIFIER)) != (MODIFIER))           \
-               splassertfail("%s: not %s, cpl == %#x", \
-                   msg, __XSTRING(NAME) + 3, cpl);     \
+       if ((curthread->td_cpl & (MODIFIER)) != (MODIFIER)) \
+               splassertfail("%s: not %s, curthread->td_cpl == %#x",   \
+                   msg, __XSTRING(NAME) + 3, curthread->td_cpl);       \
 }
 #else
 #define        GENSPLASSERT(NAME, MODIFIER)
@@ -160,15 +160,15 @@ unsigned NAME(void)                               \
 {                                              \
        unsigned x;                             \
                                                \
-       x = cpl;                                \
-       cpl OP MODIFIER;                        \
+       x = curthread->td_cpl;                  \
+       curthread->td_cpl OP MODIFIER;          \
        return (x);                             \
 }
 
 void
 spl0(void)
 {
-       cpl = 0;
+       curthread->td_cpl = 0;
        if (ipending && curthread->td_pri < TDPRI_CRIT)
                splz();
 }
@@ -176,7 +176,7 @@ spl0(void)
 void
 splx(unsigned ipl)
 {
-       cpl = ipl;
+       curthread->td_cpl = ipl;
        if ((ipending & ~ipl) && curthread->td_pri < TDPRI_CRIT)
                splz();
 }
@@ -184,8 +184,8 @@ splx(unsigned ipl)
 intrmask_t
 splq(intrmask_t mask)
 { 
-       intrmask_t tmp = cpl;
-       cpl |= mask;
+       intrmask_t tmp = curthread->td_cpl;
+       curthread->td_cpl |= mask;
        return (tmp);
 }       
 
@@ -207,8 +207,8 @@ unsigned NAME(void)                         \
 {                                              \
        unsigned x;                             \
                                                \
-       x = cpl;                                \
-       cpl OP MODIFIER;                        \
+       x = curthread->td_cpl;                  \
+       curthread->td_cpl OP MODIFIER;          \
                                                \
        return (x);                             \
 }
@@ -223,7 +223,7 @@ void
 spl0(void)
 {
        KASSERT(inside_intr == 0, ("spl0: called from interrupt"));
-       cpl = 0;
+       curthread->td_cpl = 0;
        if (ipending && curthread->td_pri < TDPRI_CRIT)
                splz();
 }
@@ -237,8 +237,8 @@ spl0(void)
 void
 splx(unsigned ipl)
 {
-       cpl = ipl;
-       if (inside_intr == 0 && (ipending & ~cpl) != 0 &&
+       curthread->td_cpl = ipl;
+       if (inside_intr == 0 && (ipending & ~curthread->td_cpl) != 0 &&
            curthread->td_pri < TDPRI_CRIT) {
                splz();
        }
@@ -253,8 +253,8 @@ splx(unsigned ipl)
 intrmask_t
 splq(intrmask_t mask)
 {
-       intrmask_t tmp = cpl;
-       cpl |= mask;
+       intrmask_t tmp = curthread->td_cpl;
+       curthread->td_cpl |= mask;
        return (tmp);
 }