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: releng/11.0/sys/i386/include/npx.h 284926 2015-06-29 12:06:36Z kib $ 344Srgrimes */ 354Srgrimes 364Srgrimes/* 374Srgrimes * 287/387 NPX Coprocessor Data Structures and Constants 384Srgrimes * W. Jolitz 1/90 394Srgrimes */ 404Srgrimes 414175Sbde#ifndef _MACHINE_NPX_H_ 424175Sbde#define _MACHINE_NPX_H_ 434Srgrimes 44233044Stijl#include <x86/fpu.h> 454Srgrimes 4655205Speter#ifdef _KERNEL 47146137Snyan 48273995Sjhbstruct fpu_kern_ctx; 49273995Sjhb 50208833Skib#define PCB_USER_FPU(pcb) (((pcb)->pcb_flags & PCB_KERNNPX) == 0) 51208833Skib 52273995Sjhb#define XSAVE_AREA_ALIGN 64 53273995Sjhb 5492761Salfredint npxdna(void); 55103408Sminivoid npxdrop(void); 5692761Salfredvoid npxexit(struct thread *td); 57103408Sminiint npxformat(void); 58215865Skibint npxgetregs(struct thread *td); 59273995Sjhbvoid npxinit(bool bsp); 60270850Sjhbvoid npxresume(union savefpu *addr); 6192761Salfredvoid npxsave(union savefpu *addr); 62273995Sjhbint npxsetregs(struct thread *td, union savefpu *addr, 63273995Sjhb char *xfpustate, size_t xfpustate_size); 64273995Sjhbint npxsetxstate(struct thread *td, char *xfpustate, 65273995Sjhb size_t xfpustate_size); 66270850Sjhbvoid npxsuspend(union savefpu *addr); 67238678Skibint npxtrap_x87(void); 68238678Skibint npxtrap_sse(void); 69215865Skibvoid npxuserinited(struct thread *); 70284926Skibvoid npx_get_fsave(void *); 71284926Skibint npx_set_fsave(void *); 72284926Skibvoid npx_fill_fpregs_xmm(struct savexmm *, struct save87 *); 73284926Skibvoid npx_set_fpregs_xmm(struct save87 *, struct savexmm *); 74284926Skib 75230426Skibstruct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); 76230426Skibvoid fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); 77208833Skibint fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, 78208833Skib u_int flags); 79208833Skibint fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); 80208833Skibint fpu_kern_thread(u_int flags); 81208833Skibint is_fpu_kern_thread(u_int flags); 82158995Sdavidxu 83273995Sjhbunion savefpu *fpu_save_area_alloc(void); 84273995Sjhbvoid fpu_save_area_free(union savefpu *fsa); 85273995Sjhbvoid fpu_save_area_reset(union savefpu *fsa); 86273995Sjhb 87208833Skib/* 88273995Sjhb * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread(). 89208833Skib */ 90208833Skib#define FPU_KERN_NORMAL 0x0000 91230426Skib#define FPU_KERN_NOWAIT 0x0001 92267767Skib#define FPU_KERN_KTHR 0x0002 93208833Skib 944175Sbde#endif 954175Sbde 964175Sbde#endif /* !_MACHINE_NPX_H_ */ 97