From af0bff8476377d16487f9c9f43d9c4435ecbf803 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 18 Jun 2003 07:04:30 +0000 Subject: [PATCH] thread stage 2: convert npxproc to npxthread. --- sys/cpu/i386/include/npx.h | 6 ++--- sys/i386/i386/genassym.c | 4 ++-- sys/i386/i386/globals.s | 10 ++++---- sys/i386/i386/support.s | 33 +++++++++++++------------- sys/i386/i386/swtch.s | 15 +++++++----- sys/i386/i386/vm86bios.s | 9 +++---- sys/i386/i386/vm_machdep.c | 4 ++-- sys/i386/include/asnames.h | 4 ++-- sys/i386/include/globaldata.h | 4 ++-- sys/i386/include/globals.h | 6 ++--- sys/i386/include/npx.h | 6 ++--- sys/i386/isa/npx.c | 32 ++++++++++++------------- sys/platform/pc32/i386/genassym.c | 4 ++-- sys/platform/pc32/i386/globals.s | 10 ++++---- sys/platform/pc32/i386/support.s | 33 +++++++++++++------------- sys/platform/pc32/i386/swtch.s | 15 +++++++----- sys/platform/pc32/i386/vm86bios.s | 9 +++---- sys/platform/pc32/i386/vm_machdep.c | 4 ++-- sys/platform/pc32/include/asnames.h | 4 ++-- sys/platform/pc32/include/globaldata.h | 4 ++-- sys/platform/pc32/include/globals.h | 6 ++--- sys/platform/pc32/isa/npx.c | 32 ++++++++++++------------- sys/platform/vkernel/i386/genassym.c | 4 ++-- 23 files changed, 132 insertions(+), 126 deletions(-) diff --git a/sys/cpu/i386/include/npx.h b/sys/cpu/i386/include/npx.h index d40cba68cc..eb8c492c9c 100644 --- a/sys/cpu/i386/include/npx.h +++ b/sys/cpu/i386/include/npx.h @@ -35,7 +35,7 @@ * * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 * $FreeBSD: src/sys/i386/include/npx.h,v 1.18.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/cpu/i386/include/npx.h,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/npx.h,v 1.3 2003/06/18 07:04:28 dillon Exp $ */ /* @@ -144,8 +144,8 @@ union savefpu { #define __INITIAL_NPXCW__ 0x127F #ifdef _KERNEL -#ifndef npxproc -extern struct proc *npxproc; +#ifndef npxthread +extern struct thread *npxthread; #endif int npxdna __P((void)); diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 20b61de6b6..49fda8a638 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include "opt_user_ldt.h" @@ -175,7 +175,7 @@ ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab)); ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_SIZEOF, sizeof(struct globaldata)); ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); -ASSYM(GD_NPXPROC, offsetof(struct globaldata, gd_npxproc)); +ASSYM(GD_NPXTHREAD, offsetof(struct globaldata, gd_npxthread)); ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); diff --git a/sys/i386/i386/globals.s b/sys/i386/i386/globals.s index cf91f4aa0f..29cac9a239 100644 --- a/sys/i386/i386/globals.s +++ b/sys/i386/i386/globals.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/globals.s,v 1.13.2.1 2000/05/16 06:58:06 dillon Exp $ - * $DragonFly: src/sys/i386/i386/Attic/globals.s,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/globals.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include "opt_user_ldt.h" @@ -64,13 +64,13 @@ globaldata: #else .set globaldata,0 #endif - .globl gd_curthread, gd_curpcb, gd_npxproc, gd_astpending + .globl gd_curthread, gd_curpcb, gd_npxthread, gd_astpending .globl gd_common_tss, gd_switchtime, gd_switchticks, gd_idlethread .set gd_curthread,globaldata + GD_CURTHREAD .set gd_idlethread,globaldata + GD_IDLETHREAD .set gd_astpending,globaldata + GD_ASTPENDING .set gd_curpcb,globaldata + GD_CURPCB - .set gd_npxproc,globaldata + GD_NPXPROC + .set gd_npxthread,globaldata + GD_NPXTHREAD .set gd_common_tss,globaldata + GD_COMMON_TSS .set gd_switchtime,globaldata + GD_SWITCHTIME .set gd_switchticks,globaldata + GD_SWITCHTICKS @@ -85,13 +85,13 @@ globaldata: #endif #ifndef SMP - .globl _curthread, _curpcb, _npxproc, _astpending + .globl _curthread, _curpcb, _npxthread, _astpending .globl _common_tss, _switchtime, _switchticks, _idlethread .set _curthread,globaldata + GD_CURTHREAD .set _idlethread,globaldata + GD_IDLETHREAD .set _astpending,globaldata + GD_ASTPENDING .set _curpcb,globaldata + GD_CURPCB - .set _npxproc,globaldata + GD_NPXPROC + .set _npxthread,globaldata + GD_NPXTHREAD .set _common_tss,globaldata + GD_COMMON_TSS .set _switchtime,globaldata + GD_SWITCHTIME .set _switchticks,globaldata + GD_SWITCHTICKS diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 11b69c051d..152bc17a57 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/support.s,v 1.67.2.5 2001/08/15 01:23:50 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/support.s,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/support.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include "npx.h" @@ -217,8 +217,8 @@ ENTRY(i586_bzero) * complicated since we avoid it if possible at all levels. We * want to localize the complications even when that increases them. * Here the extra work involves preserving CR0_TS in TS. - * `npxproc != NULL' is supposed to be the condition that all the - * FPU resources belong to an application, but npxproc and CR0_TS + * `npxthread != NULL' is supposed to be the condition that all the + * FPU resources belong to an application, but npxthread and CR0_TS * aren't set atomically enough for this condition to work in * interrupt handlers. * @@ -242,7 +242,7 @@ ENTRY(i586_bzero) * method. CR0_TS must be preserved although it is very likely to * always end up as clear. */ - cmpl $0,_npxproc + cmpl $0,_npxthread je i586_bz1 cmpl $256+184,%ecx /* empirical; not quite 2*108 more */ jb intreg_i586_bzero @@ -294,7 +294,7 @@ fpureg_i586_bzero_loop: cmpl $8,%ecx jae fpureg_i586_bzero_loop - cmpl $0,_npxproc + cmpl $0,_npxthread je i586_bz3 frstor 0(%esp) addl $108,%esp @@ -502,7 +502,7 @@ ENTRY(i586_bcopy) sarb $1,kernel_fpu_lock jc small_i586_bcopy - cmpl $0,_npxproc + cmpl $0,_npxthread je i586_bc1 smsw %dx clts @@ -573,7 +573,7 @@ large_i586_bcopy_loop: cmpl $64,%ecx jae 4b - cmpl $0,_npxproc + cmpl $0,_npxthread je i586_bc2 frstor 0(%esp) addl $108,%esp @@ -967,14 +967,14 @@ ENTRY(fastmove) testl $7,%edi /* check if dst addr is multiple of 8 */ jnz fastmove_tail -/* if (npxproc != NULL) { */ - cmpl $0,_npxproc +/* if (npxthread != NULL) { */ + cmpl $0,_npxthread je 6f /* fnsave(&curpcb->pcb_savefpu); */ movl _curpcb,%eax fnsave PCB_SAVEFPU(%eax) -/* npxproc = NULL; */ - movl $0,_npxproc +/* npxthread = NULL; */ + movl $0,_npxthread /* } */ 6: /* now we own the FPU. */ @@ -1002,10 +1002,9 @@ ENTRY(fastmove) movl -4(%ebp),%edi /* stop_emulating(); */ clts -/* npxproc = curthread->td_proc; */ +/* npxthread = curthread; */ movl _curthread,%eax - movl TD_PROC(%eax),%eax - movl %eax,_npxproc + movl %eax,_npxthread movl _curpcb,%eax movl $fastmove_fault,PCB_ONFAULT(%eax) 4: @@ -1083,8 +1082,8 @@ fastmove_loop: smsw %ax orb $CR0_TS,%al lmsw %ax -/* npxproc = NULL; */ - movl $0,_npxproc +/* npxthread = NULL; */ + movl $0,_npxthread ALIGN_TEXT fastmove_tail: @@ -1118,7 +1117,7 @@ fastmove_fault: smsw %ax orb $CR0_TS,%al lmsw %ax - movl $0,_npxproc + movl $0,_npxthread fastmove_tail_fault: movl %ebp,%esp diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s index 087e9bbbe5..a3976bfbb7 100644 --- a/sys/i386/i386/swtch.s +++ b/sys/i386/i386/swtch.s @@ -34,7 +34,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.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/swtch.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include "npx.h" @@ -344,13 +344,15 @@ ENTRY(cpu_switch) #if NNPX > 0 /* have we used fp, and need a save? */ - cmpl %ecx,_npxproc + addl $P_THREAD,%ecx + cmpl %ecx,_npxthread jne 1f addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */ pushl %edx call _npxsave /* do it in a big C function */ popl %eax 1: + /* %ecx,%edx trashed */ #endif /* NNPX > 0 */ /* @@ -581,22 +583,23 @@ ENTRY(savectx) #if NNPX > 0 /* - * If npxproc == NULL, then the npx h/w state is irrelevant and the + * If npxthread == NULL, then the npx h/w state is irrelevant and the * state had better already be in the pcb. This is true for forks * but not for dumps (the old book-keeping with FP flags in the pcb * always lost for dumps because the dump pcb has 0 flags). * - * If npxproc != NULL, then we have to save the npx h/w state to - * npxproc's pcb and copy it to the requested pcb, or save to the + * If npxthread != NULL, then we have to save the npx h/w state to + * npxthread's pcb and copy it to the requested pcb, or save to the * requested pcb and reload. Copying is easier because we would * have to handle h/w bugs for reloading. We used to lose the * parent's npx state for forks by forgetting to reload. */ - movl _npxproc,%eax + movl _npxthread,%eax testl %eax,%eax je 1f pushl %ecx + movl TD_PROC(%eax),%eax movl P_ADDR(%eax),%eax leal PCB_SAVEFPU(%eax),%eax pushl %eax diff --git a/sys/i386/i386/vm86bios.s b/sys/i386/i386/vm86bios.s index b21d235f37..e0b8619be9 100644 --- a/sys/i386/i386/vm86bios.s +++ b/sys/i386/i386/vm86bios.s @@ -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.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/vm86bios.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include /* miscellaneous asm macros */ @@ -71,12 +71,12 @@ ENTRY(vm86_bioscall) #if NNPX > 0 movl _curthread,%ecx - movl TD_PROC(%ecx),%ecx - cmpl %ecx,_npxproc /* do we need to save fp? */ + cmpl %ecx,_npxthread /* do we need to save fp? */ jne 1f testl %ecx,%ecx - je 1f /* no curproc/npxproc */ + je 1f /* no curthread/npxthread */ pushl %edx + movl TD_PROC(%ecx),%ecx movl P_ADDR(%ecx),%ecx addl $PCB_SAVEFPU,%ecx pushl %ecx @@ -85,6 +85,7 @@ ENTRY(vm86_bioscall) popl %edx /* recover our pcb */ #endif + /* %ecx is garbage at this point */ 1: movl SCR_VMFRAME(%edx),%ebx /* target frame location */ movl %ebx,%edi /* destination */ diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index db862f6a3d..456392e599 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -39,7 +39,7 @@ * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.132.2.9 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/i386/i386/Attic/vm_machdep.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/vm_machdep.c,v 1.3 2003/06/18 07:04:25 dillon Exp $ */ #include "npx.h" @@ -142,7 +142,7 @@ cpu_fork(p1, p2, flags) #if NNPX > 0 /* Ensure that p1's pcb is up to date. */ - if (npxproc == p1) + if (npxthread == &p1->p_thread) npxsave(&p1->p_addr->u_pcb.pcb_save); #endif diff --git a/sys/i386/include/asnames.h b/sys/i386/include/asnames.h index 0901222319..cbd4cbb516 100644 --- a/sys/i386/include/asnames.h +++ b/sys/i386/include/asnames.h @@ -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.3 2003/06/18 06:33:29 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/asnames.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ */ #ifndef _MACHINE_ASNAMES_H_ @@ -348,7 +348,7 @@ #define _astpending FS(astpending) #define _currentldt FS(currentldt) #define _inside_intr FS(inside_intr) -#define _npxproc FS(npxproc) +#define _npxthread FS(npxthread) #define _other_cpus FS(other_cpus) #define _prv_CADDR1 FS(prv_CADDR1) #define _prv_CADDR2 FS(prv_CADDR2) diff --git a/sys/i386/include/globaldata.h b/sys/i386/include/globaldata.h index 9fee7625c8..bfb8b5c2f6 100644 --- a/sys/i386/include/globaldata.h +++ b/sys/i386/include/globaldata.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/i386/include/Attic/globaldata.h,v 1.3 2003/06/18 06:33:29 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/globaldata.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ */ /* @@ -42,7 +42,7 @@ struct globaldata { struct privatespace *gd_prvspace; /* self-reference */ struct thread *gd_curthread; - struct proc *gd_npxproc; + struct thread *gd_npxthread; struct pcb *gd_curpcb; struct timeval gd_switchtime; struct i386tss gd_common_tss; diff --git a/sys/i386/include/globals.h b/sys/i386/include/globals.h index 76d75b1223..6cc72adf32 100644 --- a/sys/i386/include/globals.h +++ b/sys/i386/include/globals.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globals.h,v 1.5.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/i386/include/Attic/globals.h,v 1.3 2003/06/18 06:33:29 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/globals.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ */ #ifndef _MACHINE_GLOBALS_H_ @@ -85,7 +85,7 @@ #define curthread GLOBAL_RVALUE_NV(curthread, struct thread *) #define idlethread GLOBAL_RVALUE_NV(idlethread, struct thread) #define curpcb GLOBAL_RVALUE_NV(curpcb, struct pcb *) -#define npxproc GLOBAL_LVALUE(npxproc, struct proc *) +#define npxthread GLOBAL_LVALUE(npxthread, struct thread *) #define common_tss GLOBAL_LVALUE(common_tss, struct i386tss) #define switchtime GLOBAL_LVALUE(switchtime, struct timeval) #define switchticks GLOBAL_LVALUE(switchticks, int) @@ -135,7 +135,7 @@ GLOBAL_FUNC(curthread) GLOBAL_FUNC(idlethread) GLOBAL_FUNC(astpending) GLOBAL_FUNC(curpcb) -GLOBAL_FUNC(npxproc) +GLOBAL_FUNC(npxthread) GLOBAL_FUNC(common_tss) GLOBAL_FUNC(switchtime) GLOBAL_FUNC(switchticks) diff --git a/sys/i386/include/npx.h b/sys/i386/include/npx.h index f45199843f..e53c579d08 100644 --- a/sys/i386/include/npx.h +++ b/sys/i386/include/npx.h @@ -35,7 +35,7 @@ * * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 * $FreeBSD: src/sys/i386/include/npx.h,v 1.18.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/npx.h,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/npx.h,v 1.3 2003/06/18 07:04:28 dillon Exp $ */ /* @@ -144,8 +144,8 @@ union savefpu { #define __INITIAL_NPXCW__ 0x127F #ifdef _KERNEL -#ifndef npxproc -extern struct proc *npxproc; +#ifndef npxthread +extern struct thread *npxthread; #endif int npxdna __P((void)); diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c index fb005a7f3c..a02c15b374 100644 --- a/sys/i386/isa/npx.c +++ b/sys/i386/isa/npx.c @@ -33,7 +33,7 @@ * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/isa/npx.c,v 1.80.2.3 2001/10/20 19:04:38 tegge Exp $ - * $DragonFly: src/sys/i386/isa/Attic/npx.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/i386/isa/Attic/npx.c,v 1.3 2003/06/18 07:04:30 dillon Exp $ */ #include "opt_cpu.h" @@ -503,7 +503,7 @@ npxinit(control) /* * fninit has the same h/w bugs as fnsave. Use the detoxified * fnsave to throw away any junk in the fpu. npxsave() initializes - * the fpu and sets npxproc = NULL as important side effects. + * the fpu and sets npxthread = NULL as important side effects. */ npxsave(&dummy); stop_emulating(); @@ -526,7 +526,7 @@ npxexit(p) struct proc *p; { - if (p == npxproc) + if (&p->p_thread == npxthread) npxsave(&curpcb->pcb_save); #ifdef NPX_DEBUG if (npx_exists) { @@ -743,14 +743,14 @@ npx_intr(dummy) struct intrframe *frame; u_long *exstat; - if (npxproc == NULL || !npx_exists) { - printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n", - npxproc, curproc, npx_exists); + if (npxthread == NULL || !npx_exists) { + printf("npxintr: npxthread = %p, curthread = %p, npx_exists = %d\n", + npxthread, curthread, npx_exists); panic("npxintr from nowhere"); } - if (npxproc != curproc) { - printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n", - npxproc, curproc, npx_exists); + if (npxthread != curthread) { + printf("npxintr: npxthread = %p, curthread = %p, npx_exists = %d\n", + npxthread, curthread, npx_exists); panic("npxintr from non-current process"); } @@ -806,7 +806,7 @@ npx_intr(dummy) /* * Implement device not available (DNA) exception * - * It would be better to switch FP context here (if curproc != npxproc) + * It would be better to switch FP context here (if curthread != npxthread) * and not necessarily for every context switch, but it is too hard to * access foreign pcb's. */ @@ -817,16 +817,16 @@ npxdna() if (!npx_exists) return (0); - if (npxproc != NULL) { - printf("npxdna: npxproc = %p, curproc = %p\n", - npxproc, curproc); + if (npxthread != NULL) { + printf("npxdna: npxthread = %p, curthread = %p\n", + npxthread, curthread); panic("npxdna"); } stop_emulating(); /* * Record new context early in case frstor causes an IRQ13. */ - npxproc = curproc; + npxthread = curthread; exstat = GET_FPU_EXSW_PTR(curpcb); *exstat = 0; /* @@ -865,7 +865,7 @@ npxsave(addr) /* fnop(); */ start_emulating(); - npxproc = NULL; + npxthread = NULL; #else /* SMP or CPU_ENABLE_SSE */ @@ -887,7 +887,7 @@ npxsave(addr) fnsave(addr); fnop(); start_emulating(); - npxproc = NULL; + npxthread = NULL; disable_intr(); icu1_mask = inb(IO_ICU1 + 1); /* masks may have changed */ icu2_mask = inb(IO_ICU2 + 1); diff --git a/sys/platform/pc32/i386/genassym.c b/sys/platform/pc32/i386/genassym.c index 944c705e87..5854c39457 100644 --- a/sys/platform/pc32/i386/genassym.c +++ b/sys/platform/pc32/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include "opt_user_ldt.h" @@ -175,7 +175,7 @@ ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab)); ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_SIZEOF, sizeof(struct globaldata)); ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); -ASSYM(GD_NPXPROC, offsetof(struct globaldata, gd_npxproc)); +ASSYM(GD_NPXTHREAD, offsetof(struct globaldata, gd_npxthread)); ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); diff --git a/sys/platform/pc32/i386/globals.s b/sys/platform/pc32/i386/globals.s index 65c75efff2..347a068aef 100644 --- a/sys/platform/pc32/i386/globals.s +++ b/sys/platform/pc32/i386/globals.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/globals.s,v 1.13.2.1 2000/05/16 06:58:06 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/i386/globals.s,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/globals.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include "opt_user_ldt.h" @@ -64,13 +64,13 @@ globaldata: #else .set globaldata,0 #endif - .globl gd_curthread, gd_curpcb, gd_npxproc, gd_astpending + .globl gd_curthread, gd_curpcb, gd_npxthread, gd_astpending .globl gd_common_tss, gd_switchtime, gd_switchticks, gd_idlethread .set gd_curthread,globaldata + GD_CURTHREAD .set gd_idlethread,globaldata + GD_IDLETHREAD .set gd_astpending,globaldata + GD_ASTPENDING .set gd_curpcb,globaldata + GD_CURPCB - .set gd_npxproc,globaldata + GD_NPXPROC + .set gd_npxthread,globaldata + GD_NPXTHREAD .set gd_common_tss,globaldata + GD_COMMON_TSS .set gd_switchtime,globaldata + GD_SWITCHTIME .set gd_switchticks,globaldata + GD_SWITCHTICKS @@ -85,13 +85,13 @@ globaldata: #endif #ifndef SMP - .globl _curthread, _curpcb, _npxproc, _astpending + .globl _curthread, _curpcb, _npxthread, _astpending .globl _common_tss, _switchtime, _switchticks, _idlethread .set _curthread,globaldata + GD_CURTHREAD .set _idlethread,globaldata + GD_IDLETHREAD .set _astpending,globaldata + GD_ASTPENDING .set _curpcb,globaldata + GD_CURPCB - .set _npxproc,globaldata + GD_NPXPROC + .set _npxthread,globaldata + GD_NPXTHREAD .set _common_tss,globaldata + GD_COMMON_TSS .set _switchtime,globaldata + GD_SWITCHTIME .set _switchticks,globaldata + GD_SWITCHTICKS diff --git a/sys/platform/pc32/i386/support.s b/sys/platform/pc32/i386/support.s index 15a481cbc2..33cfb3222c 100644 --- a/sys/platform/pc32/i386/support.s +++ b/sys/platform/pc32/i386/support.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/support.s,v 1.67.2.5 2001/08/15 01:23:50 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/support.s,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/support.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include "npx.h" @@ -217,8 +217,8 @@ ENTRY(i586_bzero) * complicated since we avoid it if possible at all levels. We * want to localize the complications even when that increases them. * Here the extra work involves preserving CR0_TS in TS. - * `npxproc != NULL' is supposed to be the condition that all the - * FPU resources belong to an application, but npxproc and CR0_TS + * `npxthread != NULL' is supposed to be the condition that all the + * FPU resources belong to an application, but npxthread and CR0_TS * aren't set atomically enough for this condition to work in * interrupt handlers. * @@ -242,7 +242,7 @@ ENTRY(i586_bzero) * method. CR0_TS must be preserved although it is very likely to * always end up as clear. */ - cmpl $0,_npxproc + cmpl $0,_npxthread je i586_bz1 cmpl $256+184,%ecx /* empirical; not quite 2*108 more */ jb intreg_i586_bzero @@ -294,7 +294,7 @@ fpureg_i586_bzero_loop: cmpl $8,%ecx jae fpureg_i586_bzero_loop - cmpl $0,_npxproc + cmpl $0,_npxthread je i586_bz3 frstor 0(%esp) addl $108,%esp @@ -502,7 +502,7 @@ ENTRY(i586_bcopy) sarb $1,kernel_fpu_lock jc small_i586_bcopy - cmpl $0,_npxproc + cmpl $0,_npxthread je i586_bc1 smsw %dx clts @@ -573,7 +573,7 @@ large_i586_bcopy_loop: cmpl $64,%ecx jae 4b - cmpl $0,_npxproc + cmpl $0,_npxthread je i586_bc2 frstor 0(%esp) addl $108,%esp @@ -967,14 +967,14 @@ ENTRY(fastmove) testl $7,%edi /* check if dst addr is multiple of 8 */ jnz fastmove_tail -/* if (npxproc != NULL) { */ - cmpl $0,_npxproc +/* if (npxthread != NULL) { */ + cmpl $0,_npxthread je 6f /* fnsave(&curpcb->pcb_savefpu); */ movl _curpcb,%eax fnsave PCB_SAVEFPU(%eax) -/* npxproc = NULL; */ - movl $0,_npxproc +/* npxthread = NULL; */ + movl $0,_npxthread /* } */ 6: /* now we own the FPU. */ @@ -1002,10 +1002,9 @@ ENTRY(fastmove) movl -4(%ebp),%edi /* stop_emulating(); */ clts -/* npxproc = curthread->td_proc; */ +/* npxthread = curthread; */ movl _curthread,%eax - movl TD_PROC(%eax),%eax - movl %eax,_npxproc + movl %eax,_npxthread movl _curpcb,%eax movl $fastmove_fault,PCB_ONFAULT(%eax) 4: @@ -1083,8 +1082,8 @@ fastmove_loop: smsw %ax orb $CR0_TS,%al lmsw %ax -/* npxproc = NULL; */ - movl $0,_npxproc +/* npxthread = NULL; */ + movl $0,_npxthread ALIGN_TEXT fastmove_tail: @@ -1118,7 +1117,7 @@ fastmove_fault: smsw %ax orb $CR0_TS,%al lmsw %ax - movl $0,_npxproc + movl $0,_npxthread fastmove_tail_fault: movl %ebp,%esp diff --git a/sys/platform/pc32/i386/swtch.s b/sys/platform/pc32/i386/swtch.s index d108405cd1..592f4eede2 100644 --- a/sys/platform/pc32/i386/swtch.s +++ b/sys/platform/pc32/i386/swtch.s @@ -34,7 +34,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.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/swtch.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include "npx.h" @@ -344,13 +344,15 @@ ENTRY(cpu_switch) #if NNPX > 0 /* have we used fp, and need a save? */ - cmpl %ecx,_npxproc + addl $P_THREAD,%ecx + cmpl %ecx,_npxthread jne 1f addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */ pushl %edx call _npxsave /* do it in a big C function */ popl %eax 1: + /* %ecx,%edx trashed */ #endif /* NNPX > 0 */ /* @@ -581,22 +583,23 @@ ENTRY(savectx) #if NNPX > 0 /* - * If npxproc == NULL, then the npx h/w state is irrelevant and the + * If npxthread == NULL, then the npx h/w state is irrelevant and the * state had better already be in the pcb. This is true for forks * but not for dumps (the old book-keeping with FP flags in the pcb * always lost for dumps because the dump pcb has 0 flags). * - * If npxproc != NULL, then we have to save the npx h/w state to - * npxproc's pcb and copy it to the requested pcb, or save to the + * If npxthread != NULL, then we have to save the npx h/w state to + * npxthread's pcb and copy it to the requested pcb, or save to the * requested pcb and reload. Copying is easier because we would * have to handle h/w bugs for reloading. We used to lose the * parent's npx state for forks by forgetting to reload. */ - movl _npxproc,%eax + movl _npxthread,%eax testl %eax,%eax je 1f pushl %ecx + movl TD_PROC(%eax),%eax movl P_ADDR(%eax),%eax leal PCB_SAVEFPU(%eax),%eax pushl %eax diff --git a/sys/platform/pc32/i386/vm86bios.s b/sys/platform/pc32/i386/vm86bios.s index 32ca474f8d..33f77431de 100644 --- a/sys/platform/pc32/i386/vm86bios.s +++ b/sys/platform/pc32/i386/vm86bios.s @@ -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.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/vm86bios.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include /* miscellaneous asm macros */ @@ -71,12 +71,12 @@ ENTRY(vm86_bioscall) #if NNPX > 0 movl _curthread,%ecx - movl TD_PROC(%ecx),%ecx - cmpl %ecx,_npxproc /* do we need to save fp? */ + cmpl %ecx,_npxthread /* do we need to save fp? */ jne 1f testl %ecx,%ecx - je 1f /* no curproc/npxproc */ + je 1f /* no curthread/npxthread */ pushl %edx + movl TD_PROC(%ecx),%ecx movl P_ADDR(%ecx),%ecx addl $PCB_SAVEFPU,%ecx pushl %ecx @@ -85,6 +85,7 @@ ENTRY(vm86_bioscall) popl %edx /* recover our pcb */ #endif + /* %ecx is garbage at this point */ 1: movl SCR_VMFRAME(%edx),%ebx /* target frame location */ movl %ebx,%edi /* destination */ diff --git a/sys/platform/pc32/i386/vm_machdep.c b/sys/platform/pc32/i386/vm_machdep.c index 5f3e9bf97f..a95fd6be18 100644 --- a/sys/platform/pc32/i386/vm_machdep.c +++ b/sys/platform/pc32/i386/vm_machdep.c @@ -39,7 +39,7 @@ * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.132.2.9 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/i386/vm_machdep.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/vm_machdep.c,v 1.3 2003/06/18 07:04:25 dillon Exp $ */ #include "npx.h" @@ -142,7 +142,7 @@ cpu_fork(p1, p2, flags) #if NNPX > 0 /* Ensure that p1's pcb is up to date. */ - if (npxproc == p1) + if (npxthread == &p1->p_thread) npxsave(&p1->p_addr->u_pcb.pcb_save); #endif diff --git a/sys/platform/pc32/include/asnames.h b/sys/platform/pc32/include/asnames.h index 2b343d4024..c53bb62070 100644 --- a/sys/platform/pc32/include/asnames.h +++ b/sys/platform/pc32/include/asnames.h @@ -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.3 2003/06/18 06:33:29 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/Attic/asnames.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ */ #ifndef _MACHINE_ASNAMES_H_ @@ -348,7 +348,7 @@ #define _astpending FS(astpending) #define _currentldt FS(currentldt) #define _inside_intr FS(inside_intr) -#define _npxproc FS(npxproc) +#define _npxthread FS(npxthread) #define _other_cpus FS(other_cpus) #define _prv_CADDR1 FS(prv_CADDR1) #define _prv_CADDR2 FS(prv_CADDR2) diff --git a/sys/platform/pc32/include/globaldata.h b/sys/platform/pc32/include/globaldata.h index e4b16f0d01..422759a871 100644 --- a/sys/platform/pc32/include/globaldata.h +++ b/sys/platform/pc32/include/globaldata.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/include/globaldata.h,v 1.3 2003/06/18 06:33:29 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/globaldata.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ */ /* @@ -42,7 +42,7 @@ struct globaldata { struct privatespace *gd_prvspace; /* self-reference */ struct thread *gd_curthread; - struct proc *gd_npxproc; + struct thread *gd_npxthread; struct pcb *gd_curpcb; struct timeval gd_switchtime; struct i386tss gd_common_tss; diff --git a/sys/platform/pc32/include/globals.h b/sys/platform/pc32/include/globals.h index bd68ba8677..ea0beb4792 100644 --- a/sys/platform/pc32/include/globals.h +++ b/sys/platform/pc32/include/globals.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globals.h,v 1.5.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/include/Attic/globals.h,v 1.3 2003/06/18 06:33:29 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/Attic/globals.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ */ #ifndef _MACHINE_GLOBALS_H_ @@ -85,7 +85,7 @@ #define curthread GLOBAL_RVALUE_NV(curthread, struct thread *) #define idlethread GLOBAL_RVALUE_NV(idlethread, struct thread) #define curpcb GLOBAL_RVALUE_NV(curpcb, struct pcb *) -#define npxproc GLOBAL_LVALUE(npxproc, struct proc *) +#define npxthread GLOBAL_LVALUE(npxthread, struct thread *) #define common_tss GLOBAL_LVALUE(common_tss, struct i386tss) #define switchtime GLOBAL_LVALUE(switchtime, struct timeval) #define switchticks GLOBAL_LVALUE(switchticks, int) @@ -135,7 +135,7 @@ GLOBAL_FUNC(curthread) GLOBAL_FUNC(idlethread) GLOBAL_FUNC(astpending) GLOBAL_FUNC(curpcb) -GLOBAL_FUNC(npxproc) +GLOBAL_FUNC(npxthread) GLOBAL_FUNC(common_tss) GLOBAL_FUNC(switchtime) GLOBAL_FUNC(switchticks) diff --git a/sys/platform/pc32/isa/npx.c b/sys/platform/pc32/isa/npx.c index 7c0a2f8bc2..de03684120 100644 --- a/sys/platform/pc32/isa/npx.c +++ b/sys/platform/pc32/isa/npx.c @@ -33,7 +33,7 @@ * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/isa/npx.c,v 1.80.2.3 2001/10/20 19:04:38 tegge Exp $ - * $DragonFly: src/sys/platform/pc32/isa/npx.c,v 1.2 2003/06/17 04:28:37 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/isa/npx.c,v 1.3 2003/06/18 07:04:30 dillon Exp $ */ #include "opt_cpu.h" @@ -503,7 +503,7 @@ npxinit(control) /* * fninit has the same h/w bugs as fnsave. Use the detoxified * fnsave to throw away any junk in the fpu. npxsave() initializes - * the fpu and sets npxproc = NULL as important side effects. + * the fpu and sets npxthread = NULL as important side effects. */ npxsave(&dummy); stop_emulating(); @@ -526,7 +526,7 @@ npxexit(p) struct proc *p; { - if (p == npxproc) + if (&p->p_thread == npxthread) npxsave(&curpcb->pcb_save); #ifdef NPX_DEBUG if (npx_exists) { @@ -743,14 +743,14 @@ npx_intr(dummy) struct intrframe *frame; u_long *exstat; - if (npxproc == NULL || !npx_exists) { - printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n", - npxproc, curproc, npx_exists); + if (npxthread == NULL || !npx_exists) { + printf("npxintr: npxthread = %p, curthread = %p, npx_exists = %d\n", + npxthread, curthread, npx_exists); panic("npxintr from nowhere"); } - if (npxproc != curproc) { - printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n", - npxproc, curproc, npx_exists); + if (npxthread != curthread) { + printf("npxintr: npxthread = %p, curthread = %p, npx_exists = %d\n", + npxthread, curthread, npx_exists); panic("npxintr from non-current process"); } @@ -806,7 +806,7 @@ npx_intr(dummy) /* * Implement device not available (DNA) exception * - * It would be better to switch FP context here (if curproc != npxproc) + * It would be better to switch FP context here (if curthread != npxthread) * and not necessarily for every context switch, but it is too hard to * access foreign pcb's. */ @@ -817,16 +817,16 @@ npxdna() if (!npx_exists) return (0); - if (npxproc != NULL) { - printf("npxdna: npxproc = %p, curproc = %p\n", - npxproc, curproc); + if (npxthread != NULL) { + printf("npxdna: npxthread = %p, curthread = %p\n", + npxthread, curthread); panic("npxdna"); } stop_emulating(); /* * Record new context early in case frstor causes an IRQ13. */ - npxproc = curproc; + npxthread = curthread; exstat = GET_FPU_EXSW_PTR(curpcb); *exstat = 0; /* @@ -865,7 +865,7 @@ npxsave(addr) /* fnop(); */ start_emulating(); - npxproc = NULL; + npxthread = NULL; #else /* SMP or CPU_ENABLE_SSE */ @@ -887,7 +887,7 @@ npxsave(addr) fnsave(addr); fnop(); start_emulating(); - npxproc = NULL; + npxthread = NULL; disable_intr(); icu1_mask = inb(IO_ICU1 + 1); /* masks may have changed */ icu2_mask = inb(IO_ICU2 + 1); diff --git a/sys/platform/vkernel/i386/genassym.c b/sys/platform/vkernel/i386/genassym.c index 3e25c73980..99c2bcd778 100644 --- a/sys/platform/vkernel/i386/genassym.c +++ b/sys/platform/vkernel/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.4 2003/06/18 07:04:25 dillon Exp $ */ #include "opt_user_ldt.h" @@ -175,7 +175,7 @@ ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab)); ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_SIZEOF, sizeof(struct globaldata)); ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); -ASSYM(GD_NPXPROC, offsetof(struct globaldata, gd_npxproc)); +ASSYM(GD_NPXTHREAD, offsetof(struct globaldata, gd_npxthread)); ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); -- 2.41.0