fpu.h revision 262981
1139825Simp/*- 21541Srgrimes * Copyright (c) 1990 The Regents of the University of California. 31541Srgrimes * All rights reserved. 41541Srgrimes * 51541Srgrimes * This code is derived from software contributed to Berkeley by 61541Srgrimes * William Jolitz. 71541Srgrimes * 81541Srgrimes * Redistribution and use in source and binary forms, with or without 91541Srgrimes * modification, are permitted provided that the following conditions 101541Srgrimes * are met: 111541Srgrimes * 1. Redistributions of source code must retain the above copyright 121541Srgrimes * notice, this list of conditions and the following disclaimer. 131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer in the 151541Srgrimes * documentation and/or other materials provided with the distribution. 161541Srgrimes * 4. Neither the name of the University nor the names of its contributors 171541Srgrimes * may be used to endorse or promote products derived from this software 181541Srgrimes * without specific prior written permission. 191541Srgrimes * 201541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3050477Speter * SUCH DAMAGE. 311541Srgrimes * 321541Srgrimes * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 3318444Sbde * $FreeBSD: stable/10/sys/amd64/include/fpu.h 262981 2014-03-10 20:47:24Z jkim $ 3418444Sbde */ 351549Srgrimes 3655205Speter/* 3718444Sbde * Floating Point Data Structures and Constants 3818444Sbde * W. Jolitz 1/90 3918444Sbde */ 4018444Sbde 411541Srgrimes#ifndef _MACHINE_FPU_H_ 421541Srgrimes#define _MACHINE_FPU_H_ 431541Srgrimes 441541Srgrimes#include <x86/fpu.h> 451541Srgrimes 461541Srgrimes#ifdef _KERNEL 471541Srgrimes 4896564Sphkstruct fpu_kern_ctx; 491541Srgrimes 501541Srgrimes#define PCB_USER_FPU(pcb) (((pcb)->pcb_flags & PCB_KERNFPU) == 0) 511541Srgrimes 521541Srgrimes#define XSAVE_AREA_ALIGN 64 531541Srgrimes 541541Srgrimesvoid fpudna(void); 551541Srgrimesvoid fpudrop(void); 561541Srgrimesvoid fpuexit(struct thread *td); 571541Srgrimesint fpuformat(void); 581541Srgrimesint fpugetregs(struct thread *td); 591541Srgrimesvoid fpuinit(void); 601541Srgrimesvoid fpurestore(void *addr); 611541Srgrimesvoid fpusave(void *addr); 621541Srgrimesint fpusetregs(struct thread *td, struct savefpu *addr, 631549Srgrimes char *xfpustate, size_t xfpustate_size); 641549Srgrimesint fpusetxstate(struct thread *td, char *xfpustate, 651549Srgrimes size_t xfpustate_size); 661549Srgrimesvoid fpususpend(void *addr); 671549Srgrimesint fputrap_sse(void); 681549Srgrimesint fputrap_x87(void); 691549Srgrimesvoid fpuuserinited(struct thread *td); 701549Srgrimesstruct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); 711549Srgrimesvoid fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); 7241991Smjacobint fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, 731549Srgrimes u_int flags); 741549Srgrimesint fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); 753963Sjkhint fpu_kern_thread(u_int flags); 767217Sdufaultint is_fpu_kern_thread(u_int flags); 7713347Sjoerg 787217Sdufaultstruct savefpu *fpu_save_area_alloc(void); 7913347Sjoergvoid fpu_save_area_free(struct savefpu *fsa); 8041991Smjacobvoid fpu_save_area_reset(struct savefpu *fsa); 8141991Smjacob 8241991Smjacob/* 83280438Sken * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread(). 84280438Sken */ 853963Sjkh#define FPU_KERN_NORMAL 0x0000 8639248Sgibbs#define FPU_KERN_NOWAIT 0x0001 8739248Sgibbs 8839248Sgibbs#endif 8943630Smjacob 9043630Smjacob#endif /* !_MACHINE_FPU_H_ */ 9143630Smjacob