14Srgrimes/*- 24Srgrimes * Copyright (c) 1990 The Regents of the University of California. 34Srgrimes * All rights reserved. 44Srgrimes * 54Srgrimes * This code is derived from software contributed to Berkeley by 64Srgrimes * William Jolitz. 74Srgrimes * 84Srgrimes * Redistribution and use in source and binary forms, with or without 94Srgrimes * modification, are permitted provided that the following conditions 104Srgrimes * are met: 114Srgrimes * 1. Redistributions of source code must retain the above copyright 124Srgrimes * notice, this list of conditions and the following disclaimer. 134Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 144Srgrimes * notice, this list of conditions and the following disclaimer in the 154Srgrimes * documentation and/or other materials provided with the distribution. 164Srgrimes * 4. Neither the name of the University nor the names of its contributors 174Srgrimes * may be used to endorse or promote products derived from this software 184Srgrimes * without specific prior written permission. 194Srgrimes * 204Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 214Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 244Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 254Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 264Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 274Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 284Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 294Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304Srgrimes * SUCH DAMAGE. 314Srgrimes * 32621Srgrimes * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 3350477Speter * $FreeBSD$ 344Srgrimes */ 354Srgrimes 364Srgrimes/* 37122292Speter * Floating Point Data Structures and Constants 384Srgrimes * W. Jolitz 1/90 394Srgrimes */ 404Srgrimes 41122292Speter#ifndef _MACHINE_FPU_H_ 42122292Speter#define _MACHINE_FPU_H_ 434Srgrimes 44233044Stijl#include <x86/fpu.h> 454Srgrimes 46208833Skib#ifdef _KERNEL 47208833Skib 48230426Skibstruct fpu_kern_ctx; 49230426Skib 50208833Skib#define PCB_USER_FPU(pcb) (((pcb)->pcb_flags & PCB_KERNFPU) == 0) 51230426Skib 52230426Skib#define XSAVE_AREA_ALIGN 64 53230426Skib 54189412Sjhbvoid fpudna(void); 55122292Spetervoid fpudrop(void); 56122292Spetervoid fpuexit(struct thread *td); 57122292Speterint fpuformat(void); 58215865Skibint fpugetregs(struct thread *td); 59122295Spetervoid fpuinit(void); 60244144Sgrehanvoid fpurestore(void *addr); 61271999Sjhbvoid fpuresume(void *addr); 62230426Skibvoid fpusave(void *addr); 63230426Skibint fpusetregs(struct thread *td, struct savefpu *addr, 64230426Skib char *xfpustate, size_t xfpustate_size); 65230426Skibint fpusetxstate(struct thread *td, char *xfpustate, 66230426Skib size_t xfpustate_size); 67262981Sjkimvoid fpususpend(void *addr); 68238598Skibint fputrap_sse(void); 69238598Skibint fputrap_x87(void); 70215865Skibvoid fpuuserinited(struct thread *td); 71230426Skibstruct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); 72230426Skibvoid fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); 73208833Skibint fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, 74208833Skib u_int flags); 75208833Skibint fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); 76208833Skibint fpu_kern_thread(u_int flags); 77208833Skibint is_fpu_kern_thread(u_int flags); 78208833Skib 79244144Sgrehanstruct savefpu *fpu_save_area_alloc(void); 80244144Sgrehanvoid fpu_save_area_free(struct savefpu *fsa); 81244144Sgrehanvoid fpu_save_area_reset(struct savefpu *fsa); 82244144Sgrehan 83208833Skib/* 84230426Skib * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread(). 85208833Skib */ 86208833Skib#define FPU_KERN_NORMAL 0x0000 87230426Skib#define FPU_KERN_NOWAIT 0x0001 88268033Skib#define FPU_KERN_KTHR 0x0002 89208833Skib 904175Sbde#endif 914175Sbde 92122292Speter#endif /* !_MACHINE_FPU_H_ */ 93