Deleted Added
full compact
34c34
< __FBSDID("$FreeBSD: head/sys/i386/isa/npx.c 190426 2009-03-25 22:08:30Z jhb $");
---
> __FBSDID("$FreeBSD: head/sys/i386/isa/npx.c 208833 2010-06-05 15:59:59Z kib $");
138,139c138,139
< (thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_cw : \
< (thread)->td_pcb->pcb_save.sv_87.sv_env.en_cw)
---
> (thread)->td_pcb->pcb_save->sv_xmm.sv_env.en_cw : \
> (thread)->td_pcb->pcb_save->sv_87.sv_env.en_cw)
142,143c142,143
< (thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_sw : \
< (thread)->td_pcb->pcb_save.sv_87.sv_env.en_sw)
---
> (thread)->td_pcb->pcb_save->sv_xmm.sv_env.en_sw : \
> (thread)->td_pcb->pcb_save->sv_87.sv_env.en_sw)
152c152
< (thread->td_pcb->pcb_save.sv_87.sv_env.en_cw)
---
> (thread->td_pcb->pcb_save->sv_87.sv_env.en_cw)
154c154
< (thread->td_pcb->pcb_save.sv_87.sv_env.en_sw)
---
> (thread->td_pcb->pcb_save->sv_87.sv_env.en_sw)
505c505
< npxsave(&PCPU_GET(curpcb)->pcb_save);
---
> npxsave(PCPU_GET(curpcb)->pcb_save);
811a812,813
> if (PCB_USER_FPU(pcb))
> pcb->pcb_flags |= PCB_NPXUSERINITDONE;
827c829
< fpurstor(&pcb->pcb_save);
---
> fpurstor(pcb->pcb_save);
898,900c900
< npxgetregs(td, addr)
< struct thread *td;
< union savefpu *addr;
---
> npxgetregs(struct thread *td, union savefpu *addr)
901a902
> struct pcb *pcb;
907c908,909
< if ((td->td_pcb->pcb_flags & PCB_NPXINITDONE) == 0) {
---
> pcb = td->td_pcb;
> if ((pcb->pcb_flags & PCB_NPXINITDONE) == 0) {
909c911
< SET_FPU_CW(addr, td->td_pcb->pcb_initial_npxcw);
---
> SET_FPU_CW(addr, pcb->pcb_initial_npxcw);
928c930
< bcopy(&td->td_pcb->pcb_save, addr, sizeof(*addr));
---
> bcopy(pcb->pcb_save, addr, sizeof(*addr));
932a935,970
> int
> npxgetuserregs(struct thread *td, union savefpu *addr)
> {
> struct pcb *pcb;
> register_t s;
>
> if (!npx_exists)
> return (_MC_FPOWNED_NONE);
>
> pcb = td->td_pcb;
> if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) == 0) {
> bcopy(&npx_initialstate, addr, sizeof(npx_initialstate));
> SET_FPU_CW(addr, pcb->pcb_initial_npxcw);
> return (_MC_FPOWNED_NONE);
> }
> s = intr_disable();
> if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) {
> fpusave(addr);
> #ifdef CPU_ENABLE_SSE
> if (!cpu_fxsr)
> #endif
> /*
> * fnsave initializes the FPU and destroys whatever
> * context it contains. Make sure the FPU owner
> * starts with a clean state next time.
> */
> npxdrop();
> intr_restore(s);
> return (_MC_FPOWNED_FPU);
> } else {
> intr_restore(s);
> bcopy(&pcb->pcb_user_save, addr, sizeof(*addr));
> return (_MC_FPOWNED_PCB);
> }
> }
>
937,939c975
< npxsetregs(td, addr)
< struct thread *td;
< union savefpu *addr;
---
> npxsetregs(struct thread *td, union savefpu *addr)
940a977
> struct pcb *pcb;
945a983
> pcb = td->td_pcb;
956c994
< bcopy(addr, &td->td_pcb->pcb_save, sizeof(*addr));
---
> bcopy(addr, pcb->pcb_save, sizeof(*addr));
958c996,998
< curthread->td_pcb->pcb_flags |= PCB_NPXINITDONE;
---
> if (PCB_USER_FPU(pcb))
> pcb->pcb_flags |= PCB_NPXUSERINITDONE;
> pcb->pcb_flags |= PCB_NPXINITDONE;
960a1001,1028
> void
> npxsetuserregs(struct thread *td, union savefpu *addr)
> {
> struct pcb *pcb;
> register_t s;
>
> if (!npx_exists)
> return;
>
> pcb = td->td_pcb;
> s = intr_disable();
> if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) {
> #ifdef CPU_ENABLE_SSE
> if (!cpu_fxsr)
> #endif
> fnclex(); /* As in npxdrop(). */
> fpurstor(addr);
> intr_restore(s);
> pcb->pcb_flags |= PCB_NPXUSERINITDONE | PCB_NPXINITDONE;
> } else {
> intr_restore(s);
> bcopy(addr, &pcb->pcb_user_save, sizeof(*addr));
> if (PCB_USER_FPU(pcb))
> pcb->pcb_flags |= PCB_NPXINITDONE;
> pcb->pcb_flags |= PCB_NPXUSERINITDONE;
> }
> }
>
1126a1195,1265
>
> int
> fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
> {
> struct pcb *pcb;
>
> pcb = td->td_pcb;
> KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save == &pcb->pcb_user_save,
> ("mangled pcb_save"));
> ctx->flags = 0;
> if ((pcb->pcb_flags & PCB_NPXINITDONE) != 0)
> ctx->flags |= FPU_KERN_CTX_NPXINITDONE;
> npxexit(td);
> ctx->prev = pcb->pcb_save;
> pcb->pcb_save = &ctx->hwstate;
> pcb->pcb_flags |= PCB_KERNNPX;
> pcb->pcb_flags &= ~PCB_NPXINITDONE;
> return (0);
> }
>
> int
> fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx)
> {
> struct pcb *pcb;
> register_t savecrit;
>
> pcb = td->td_pcb;
> savecrit = intr_disable();
> if (curthread == PCPU_GET(fpcurthread))
> npxdrop();
> intr_restore(savecrit);
> pcb->pcb_save = ctx->prev;
> if (pcb->pcb_save == &pcb->pcb_user_save) {
> if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) != 0)
> pcb->pcb_flags |= PCB_NPXINITDONE;
> else
> pcb->pcb_flags &= ~PCB_NPXINITDONE;
> pcb->pcb_flags &= ~PCB_KERNNPX;
> } else {
> if ((ctx->flags & FPU_KERN_CTX_NPXINITDONE) != 0)
> pcb->pcb_flags |= PCB_NPXINITDONE;
> else
> pcb->pcb_flags &= ~PCB_NPXINITDONE;
> KASSERT(!PCB_USER_FPU(pcb), ("unpaired fpu_kern_leave"));
> }
> return (0);
> }
>
> int
> fpu_kern_thread(u_int flags)
> {
> struct pcb *pcb;
>
> pcb = PCPU_GET(curpcb);
> KASSERT((curthread->td_pflags & TDP_KTHREAD) != 0,
> ("Only kthread may use fpu_kern_thread"));
> KASSERT(pcb->pcb_save == &pcb->pcb_user_save, ("mangled pcb_save"));
> KASSERT(PCB_USER_FPU(pcb), ("recursive call"));
>
> pcb->pcb_flags |= PCB_KERNNPX;
> return (0);
> }
>
> int
> is_fpu_kern_thread(u_int flags)
> {
>
> if ((curthread->td_pflags & TDP_KTHREAD) == 0)
> return (0);
> return ((PCPU_GET(curpcb)->pcb_flags & PCB_KERNNPX) != 0);
> }