15b81b6b3SRodney W. Grimes /*- 25b81b6b3SRodney W. Grimes * Copyright (c) 1990 The Regents of the University of California. 35b81b6b3SRodney W. Grimes * All rights reserved. 45b81b6b3SRodney W. Grimes * 55b81b6b3SRodney W. Grimes * This code is derived from software contributed to Berkeley by 65b81b6b3SRodney W. Grimes * William Jolitz. 75b81b6b3SRodney W. Grimes * 85b81b6b3SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 95b81b6b3SRodney W. Grimes * modification, are permitted provided that the following conditions 105b81b6b3SRodney W. Grimes * are met: 115b81b6b3SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 125b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 135b81b6b3SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 145b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 155b81b6b3SRodney W. Grimes * documentation and/or other materials provided with the distribution. 165b81b6b3SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 175b81b6b3SRodney W. Grimes * may be used to endorse or promote products derived from this software 185b81b6b3SRodney W. Grimes * without specific prior written permission. 195b81b6b3SRodney W. Grimes * 205b81b6b3SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 215b81b6b3SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 225b81b6b3SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 235b81b6b3SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 245b81b6b3SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 255b81b6b3SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 265b81b6b3SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 275b81b6b3SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 285b81b6b3SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 295b81b6b3SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 305b81b6b3SRodney W. Grimes * SUCH DAMAGE. 315b81b6b3SRodney W. Grimes * 3234a8ed1bSRodney W. Grimes * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 33c3aac50fSPeter Wemm * $FreeBSD$ 345b81b6b3SRodney W. Grimes */ 355b81b6b3SRodney W. Grimes 365b81b6b3SRodney W. Grimes /* 37bf2f09eeSPeter Wemm * Floating Point Data Structures and Constants 385b81b6b3SRodney W. Grimes * W. Jolitz 1/90 395b81b6b3SRodney W. Grimes */ 405b81b6b3SRodney W. Grimes 41bf2f09eeSPeter Wemm #ifndef _MACHINE_FPU_H_ 42bf2f09eeSPeter Wemm #define _MACHINE_FPU_H_ 435b81b6b3SRodney W. Grimes 4478664507STijl Coosemans #include <x86/fpu.h> 456db9cf55SKonstantin Belousov 466cf9a08dSKonstantin Belousov #ifdef _KERNEL 478c6f8f3dSKonstantin Belousov 488c6f8f3dSKonstantin Belousov struct fpu_kern_ctx; 496cf9a08dSKonstantin Belousov 506cf9a08dSKonstantin Belousov #define PCB_USER_FPU(pcb) (((pcb)->pcb_flags & PCB_KERNFPU) == 0) 518c6f8f3dSKonstantin Belousov 528c6f8f3dSKonstantin Belousov #define XSAVE_AREA_ALIGN 64 538c6f8f3dSKonstantin Belousov 54a8346a98SJohn Baldwin void fpudna(void); 55bf2f09eeSPeter Wemm void fpudrop(void); 56bf2f09eeSPeter Wemm void fpuexit(struct thread *td); 57bf2f09eeSPeter Wemm int fpuformat(void); 585c6eb037SKonstantin Belousov int fpugetregs(struct thread *td); 59398dbb11SPeter Wemm void fpuinit(void); 602741efecSPeter Grehan void fpurestore(void *addr); 618c6f8f3dSKonstantin Belousov void fpusave(void *addr); 628c6f8f3dSKonstantin Belousov int fpusetregs(struct thread *td, struct savefpu *addr, 638c6f8f3dSKonstantin Belousov char *xfpustate, size_t xfpustate_size); 648c6f8f3dSKonstantin Belousov int fpusetxstate(struct thread *td, char *xfpustate, 658c6f8f3dSKonstantin Belousov size_t xfpustate_size); 66*1d22d877SJung-uk Kim void fpususpend(void *addr); 67bc84db62SKonstantin Belousov int fputrap_sse(void); 68bc84db62SKonstantin Belousov int fputrap_x87(void); 695c6eb037SKonstantin Belousov void fpuuserinited(struct thread *td); 708c6f8f3dSKonstantin Belousov struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); 718c6f8f3dSKonstantin Belousov void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); 726cf9a08dSKonstantin Belousov int fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, 736cf9a08dSKonstantin Belousov u_int flags); 746cf9a08dSKonstantin Belousov int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); 756cf9a08dSKonstantin Belousov int fpu_kern_thread(u_int flags); 766cf9a08dSKonstantin Belousov int is_fpu_kern_thread(u_int flags); 776cf9a08dSKonstantin Belousov 782741efecSPeter Grehan struct savefpu *fpu_save_area_alloc(void); 792741efecSPeter Grehan void fpu_save_area_free(struct savefpu *fsa); 802741efecSPeter Grehan void fpu_save_area_reset(struct savefpu *fsa); 812741efecSPeter Grehan 826cf9a08dSKonstantin Belousov /* 838c6f8f3dSKonstantin Belousov * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread(). 846cf9a08dSKonstantin Belousov */ 856cf9a08dSKonstantin Belousov #define FPU_KERN_NORMAL 0x0000 868c6f8f3dSKonstantin Belousov #define FPU_KERN_NOWAIT 0x0001 876cf9a08dSKonstantin Belousov 88a1ca704eSBruce Evans #endif 89a1ca704eSBruce Evans 90bf2f09eeSPeter Wemm #endif /* !_MACHINE_FPU_H_ */ 91