15b81b6b3SRodney W. Grimes /*- 251369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 351369649SPedro F. Giffuni * 45b81b6b3SRodney W. Grimes * Copyright (c) 1990 The Regents of the University of California. 55b81b6b3SRodney W. Grimes * All rights reserved. 65b81b6b3SRodney W. Grimes * 75b81b6b3SRodney W. Grimes * This code is derived from software contributed to Berkeley by 85b81b6b3SRodney W. Grimes * William Jolitz. 95b81b6b3SRodney W. Grimes * 105b81b6b3SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 115b81b6b3SRodney W. Grimes * modification, are permitted provided that the following conditions 125b81b6b3SRodney W. Grimes * are met: 135b81b6b3SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 145b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 155b81b6b3SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 165b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 175b81b6b3SRodney W. Grimes * documentation and/or other materials provided with the distribution. 18fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 195b81b6b3SRodney W. Grimes * may be used to endorse or promote products derived from this software 205b81b6b3SRodney W. Grimes * without specific prior written permission. 215b81b6b3SRodney W. Grimes * 225b81b6b3SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 235b81b6b3SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 245b81b6b3SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 255b81b6b3SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 265b81b6b3SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 275b81b6b3SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 285b81b6b3SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 295b81b6b3SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 305b81b6b3SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 315b81b6b3SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 325b81b6b3SRodney W. Grimes * SUCH DAMAGE. 335b81b6b3SRodney W. Grimes */ 345b81b6b3SRodney W. Grimes 355b81b6b3SRodney W. Grimes /* 36bf2f09eeSPeter Wemm * Floating Point Data Structures and Constants 375b81b6b3SRodney W. Grimes * W. Jolitz 1/90 385b81b6b3SRodney W. Grimes */ 395b81b6b3SRodney W. Grimes 40bf2f09eeSPeter Wemm #ifndef _MACHINE_FPU_H_ 41bf2f09eeSPeter Wemm #define _MACHINE_FPU_H_ 425b81b6b3SRodney W. Grimes 4378664507STijl Coosemans #include <x86/fpu.h> 446db9cf55SKonstantin Belousov 456cf9a08dSKonstantin Belousov #ifdef _KERNEL 468c6f8f3dSKonstantin Belousov 478c6f8f3dSKonstantin Belousov struct fpu_kern_ctx; 486cf9a08dSKonstantin Belousov 496cf9a08dSKonstantin Belousov #define PCB_USER_FPU(pcb) (((pcb)->pcb_flags & PCB_KERNFPU) == 0) 508c6f8f3dSKonstantin Belousov 518c6f8f3dSKonstantin Belousov #define XSAVE_AREA_ALIGN 64 528c6f8f3dSKonstantin Belousov 53a8346a98SJohn Baldwin void fpudna(void); 54bf2f09eeSPeter Wemm void fpudrop(void); 55bf2f09eeSPeter Wemm void fpuexit(struct thread *td); 56bf2f09eeSPeter Wemm int fpuformat(void); 575c6eb037SKonstantin Belousov int fpugetregs(struct thread *td); 58398dbb11SPeter Wemm void fpuinit(void); 592741efecSPeter Grehan void fpurestore(void *addr); 60b1d735baSJohn Baldwin void fpuresume(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); 661d22d877SJung-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); 71*c74a3041SConrad Meyer struct fpu_kern_ctx *fpu_kern_alloc_ctx_domain(int domain, u_int flags); 728c6f8f3dSKonstantin Belousov void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); 73849ce31aSConrad Meyer void fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, 746cf9a08dSKonstantin Belousov u_int flags); 756cf9a08dSKonstantin Belousov int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); 766cf9a08dSKonstantin Belousov int fpu_kern_thread(u_int flags); 776cf9a08dSKonstantin Belousov int is_fpu_kern_thread(u_int flags); 786cf9a08dSKonstantin Belousov 792741efecSPeter Grehan struct savefpu *fpu_save_area_alloc(void); 802741efecSPeter Grehan void fpu_save_area_free(struct savefpu *fsa); 812741efecSPeter Grehan void fpu_save_area_reset(struct savefpu *fsa); 822741efecSPeter Grehan 836cf9a08dSKonstantin Belousov /* 848c6f8f3dSKonstantin Belousov * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread(). 856cf9a08dSKonstantin Belousov */ 866cf9a08dSKonstantin Belousov #define FPU_KERN_NORMAL 0x0000 878c6f8f3dSKonstantin Belousov #define FPU_KERN_NOWAIT 0x0001 88633034feSKonstantin Belousov #define FPU_KERN_KTHR 0x0002 89cf1c4776SKonstantin Belousov #define FPU_KERN_NOCTX 0x0004 906cf9a08dSKonstantin Belousov 91a1ca704eSBruce Evans #endif 92a1ca704eSBruce Evans 93bf2f09eeSPeter Wemm #endif /* !_MACHINE_FPU_H_ */ 94