fpu.h revision 238598
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 238598 2012-07-18 15:43:47Z kib $ 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); 60230426Skibvoid fpusave(void *addr); 61230426Skibint fpusetregs(struct thread *td, struct savefpu *addr, 62230426Skib char *xfpustate, size_t xfpustate_size); 63230426Skibint fpusetxstate(struct thread *td, char *xfpustate, 64230426Skib size_t xfpustate_size); 65238598Skibint fputrap_sse(void); 66238598Skibint fputrap_x87(void); 67215865Skibvoid fpuuserinited(struct thread *td); 68230426Skibstruct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); 69230426Skibvoid fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); 70208833Skibint fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, 71208833Skib u_int flags); 72208833Skibint fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); 73208833Skibint fpu_kern_thread(u_int flags); 74208833Skibint is_fpu_kern_thread(u_int flags); 75208833Skib 76208833Skib/* 77230426Skib * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread(). 78208833Skib */ 79208833Skib#define FPU_KERN_NORMAL 0x0000 80230426Skib#define FPU_KERN_NOWAIT 0x0001 81208833Skib 824175Sbde#endif 834175Sbde 84122292Speter#endif /* !_MACHINE_FPU_H_ */ 85