npx.c (255040) | npx.c (267767) |
---|---|
1/*- 2 * Copyright (c) 1990 William Jolitz. 3 * Copyright (c) 1991 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 17 unchanged lines hidden (view full) --- 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1990 William Jolitz. 3 * Copyright (c) 1991 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 17 unchanged lines hidden (view full) --- 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/i386/isa/npx.c 255040 2013-08-29 19:52:18Z gibbs $"); | 34__FBSDID("$FreeBSD: head/sys/i386/isa/npx.c 267767 2014-06-23 07:37:54Z kib $"); |
35 36#include "opt_cpu.h" 37#include "opt_isa.h" 38#include "opt_npx.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/bus.h> --- 960 unchanged lines hidden (view full) --- 1003#endif /* DEV_ISA */ 1004 1005static MALLOC_DEFINE(M_FPUKERN_CTX, "fpukern_ctx", 1006 "Kernel contexts for FPU state"); 1007 1008#define XSAVE_AREA_ALIGN 64 1009 1010#define FPU_KERN_CTX_NPXINITDONE 0x01 | 35 36#include "opt_cpu.h" 37#include "opt_isa.h" 38#include "opt_npx.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/bus.h> --- 960 unchanged lines hidden (view full) --- 1003#endif /* DEV_ISA */ 1004 1005static MALLOC_DEFINE(M_FPUKERN_CTX, "fpukern_ctx", 1006 "Kernel contexts for FPU state"); 1007 1008#define XSAVE_AREA_ALIGN 64 1009 1010#define FPU_KERN_CTX_NPXINITDONE 0x01 |
1011#define FPU_KERN_CTX_DUMMY 0x02 |
|
1011 1012struct fpu_kern_ctx { 1013 union savefpu *prev; 1014 uint32_t flags; 1015 char hwstate1[]; 1016}; 1017 1018struct fpu_kern_ctx * --- 27 unchanged lines hidden (view full) --- 1046 return ((union savefpu *)p); 1047} 1048 1049int 1050fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags) 1051{ 1052 struct pcb *pcb; 1053 | 1012 1013struct fpu_kern_ctx { 1014 union savefpu *prev; 1015 uint32_t flags; 1016 char hwstate1[]; 1017}; 1018 1019struct fpu_kern_ctx * --- 27 unchanged lines hidden (view full) --- 1047 return ((union savefpu *)p); 1048} 1049 1050int 1051fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags) 1052{ 1053 struct pcb *pcb; 1054 |
1055 if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) { 1056 ctx->flags = FPU_KERN_CTX_DUMMY; 1057 return (0); 1058 } |
|
1054 pcb = td->td_pcb; 1055 KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save == &pcb->pcb_user_save, 1056 ("mangled pcb_save")); 1057 ctx->flags = 0; 1058 if ((pcb->pcb_flags & PCB_NPXINITDONE) != 0) 1059 ctx->flags |= FPU_KERN_CTX_NPXINITDONE; 1060 npxexit(td); 1061 ctx->prev = pcb->pcb_save; 1062 pcb->pcb_save = fpu_kern_ctx_savefpu(ctx); 1063 pcb->pcb_flags |= PCB_KERNNPX; 1064 pcb->pcb_flags &= ~PCB_NPXINITDONE; 1065 return (0); 1066} 1067 1068int 1069fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx) 1070{ 1071 struct pcb *pcb; 1072 | 1059 pcb = td->td_pcb; 1060 KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save == &pcb->pcb_user_save, 1061 ("mangled pcb_save")); 1062 ctx->flags = 0; 1063 if ((pcb->pcb_flags & PCB_NPXINITDONE) != 0) 1064 ctx->flags |= FPU_KERN_CTX_NPXINITDONE; 1065 npxexit(td); 1066 ctx->prev = pcb->pcb_save; 1067 pcb->pcb_save = fpu_kern_ctx_savefpu(ctx); 1068 pcb->pcb_flags |= PCB_KERNNPX; 1069 pcb->pcb_flags &= ~PCB_NPXINITDONE; 1070 return (0); 1071} 1072 1073int 1074fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx) 1075{ 1076 struct pcb *pcb; 1077 |
1078 if (is_fpu_kern_thread(0) && (ctx->flags & FPU_KERN_CTX_DUMMY) != 0) 1079 return (0); |
|
1073 pcb = td->td_pcb; 1074 critical_enter(); 1075 if (curthread == PCPU_GET(fpcurthread)) 1076 npxdrop(); 1077 critical_exit(); 1078 pcb->pcb_save = ctx->prev; 1079 if (pcb->pcb_save == &pcb->pcb_user_save) { 1080 if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) != 0) --- 38 unchanged lines hidden --- | 1080 pcb = td->td_pcb; 1081 critical_enter(); 1082 if (curthread == PCPU_GET(fpcurthread)) 1083 npxdrop(); 1084 critical_exit(); 1085 pcb->pcb_save = ctx->prev; 1086 if (pcb->pcb_save == &pcb->pcb_user_save) { 1087 if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) != 0) --- 38 unchanged lines hidden --- |