fpu.c (266552) | fpu.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/amd64/amd64/fpu.c 266552 2014-05-22 18:22:02Z jhb $"); | 34__FBSDID("$FreeBSD: head/sys/amd64/amd64/fpu.c 267767 2014-06-23 07:37:54Z kib $"); |
35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/bus.h> 39#include <sys/kernel.h> 40#include <sys/lock.h> 41#include <sys/malloc.h> 42#include <sys/module.h> --- 842 unchanged lines hidden (view full) --- 885 886DRIVER_MODULE(fpupnp, acpi, fpupnp_driver, fpupnp_devclass, 0, 0); 887#endif /* DEV_ISA */ 888 889static MALLOC_DEFINE(M_FPUKERN_CTX, "fpukern_ctx", 890 "Kernel contexts for FPU state"); 891 892#define FPU_KERN_CTX_FPUINITDONE 0x01 | 35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/bus.h> 39#include <sys/kernel.h> 40#include <sys/lock.h> 41#include <sys/malloc.h> 42#include <sys/module.h> --- 842 unchanged lines hidden (view full) --- 885 886DRIVER_MODULE(fpupnp, acpi, fpupnp_driver, fpupnp_devclass, 0, 0); 887#endif /* DEV_ISA */ 888 889static MALLOC_DEFINE(M_FPUKERN_CTX, "fpukern_ctx", 890 "Kernel contexts for FPU state"); 891 892#define FPU_KERN_CTX_FPUINITDONE 0x01 |
893#define FPU_KERN_CTX_DUMMY 0x02 /* avoided save for the kern thread */ |
|
893 894struct fpu_kern_ctx { 895 struct savefpu *prev; 896 uint32_t flags; 897 char hwstate1[]; 898}; 899 900struct fpu_kern_ctx * --- 27 unchanged lines hidden (view full) --- 928 return ((struct savefpu *)p); 929} 930 931int 932fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags) 933{ 934 struct pcb *pcb; 935 | 894 895struct fpu_kern_ctx { 896 struct savefpu *prev; 897 uint32_t flags; 898 char hwstate1[]; 899}; 900 901struct fpu_kern_ctx * --- 27 unchanged lines hidden (view full) --- 929 return ((struct savefpu *)p); 930} 931 932int 933fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags) 934{ 935 struct pcb *pcb; 936 |
937 if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) { 938 ctx->flags = FPU_KERN_CTX_DUMMY; 939 return (0); 940 } |
|
936 pcb = td->td_pcb; 937 KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save == 938 get_pcb_user_save_pcb(pcb), ("mangled pcb_save")); 939 ctx->flags = 0; 940 if ((pcb->pcb_flags & PCB_FPUINITDONE) != 0) 941 ctx->flags |= FPU_KERN_CTX_FPUINITDONE; 942 fpuexit(td); 943 ctx->prev = pcb->pcb_save; 944 pcb->pcb_save = fpu_kern_ctx_savefpu(ctx); 945 set_pcb_flags(pcb, PCB_KERNFPU); 946 clear_pcb_flags(pcb, PCB_FPUINITDONE); 947 return (0); 948} 949 950int 951fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx) 952{ 953 struct pcb *pcb; 954 | 941 pcb = td->td_pcb; 942 KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save == 943 get_pcb_user_save_pcb(pcb), ("mangled pcb_save")); 944 ctx->flags = 0; 945 if ((pcb->pcb_flags & PCB_FPUINITDONE) != 0) 946 ctx->flags |= FPU_KERN_CTX_FPUINITDONE; 947 fpuexit(td); 948 ctx->prev = pcb->pcb_save; 949 pcb->pcb_save = fpu_kern_ctx_savefpu(ctx); 950 set_pcb_flags(pcb, PCB_KERNFPU); 951 clear_pcb_flags(pcb, PCB_FPUINITDONE); 952 return (0); 953} 954 955int 956fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx) 957{ 958 struct pcb *pcb; 959 |
960 if (is_fpu_kern_thread(0) && (ctx->flags & FPU_KERN_CTX_DUMMY) != 0) 961 return (0); 962 KASSERT((ctx->flags & FPU_KERN_CTX_DUMMY) == 0, ("dummy ctx")); |
|
955 pcb = td->td_pcb; 956 critical_enter(); 957 if (curthread == PCPU_GET(fpcurthread)) 958 fpudrop(); 959 critical_exit(); 960 pcb->pcb_save = ctx->prev; 961 if (pcb->pcb_save == get_pcb_user_save_pcb(pcb)) { 962 if ((pcb->pcb_flags & PCB_USERFPUINITDONE) != 0) { --- 60 unchanged lines hidden --- | 963 pcb = td->td_pcb; 964 critical_enter(); 965 if (curthread == PCPU_GET(fpcurthread)) 966 fpudrop(); 967 critical_exit(); 968 pcb->pcb_save = ctx->prev; 969 if (pcb->pcb_save == get_pcb_user_save_pcb(pcb)) { 970 if ((pcb->pcb_flags & PCB_USERFPUINITDONE) != 0) { --- 60 unchanged lines hidden --- |