fpu.h revision 244144
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: head/sys/amd64/include/fpu.h 244144 2012-12-12 08:35:32Z grehan $ 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); 61230426Skibvoid fpusave(void *addr); 62230426Skibint fpusetregs(struct thread *td, struct savefpu *addr, 63230426Skib char *xfpustate, size_t xfpustate_size); 64230426Skibint fpusetxstate(struct thread *td, char *xfpustate, 65230426Skib size_t xfpustate_size); 66238598Skibint fputrap_sse(void); 67238598Skibint fputrap_x87(void); 68215865Skibvoid fpuuserinited(struct thread *td); 69230426Skibstruct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); 70230426Skibvoid fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); 71208833Skibint fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, 72208833Skib u_int flags); 73208833Skibint fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); 74208833Skibint fpu_kern_thread(u_int flags); 75208833Skibint is_fpu_kern_thread(u_int flags); 76208833Skib 77244144Sgrehanstruct savefpu *fpu_save_area_alloc(void); 78244144Sgrehanvoid fpu_save_area_free(struct savefpu *fsa); 79244144Sgrehanvoid fpu_save_area_reset(struct savefpu *fsa); 80244144Sgrehan 81208833Skib/* 82230426Skib * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread(). 83208833Skib */ 84208833Skib#define FPU_KERN_NORMAL 0x0000 85230426Skib#define FPU_KERN_NOWAIT 0x0001 86208833Skib 874175Sbde#endif 884175Sbde 89122292Speter#endif /* !_MACHINE_FPU_H_ */ 90