Annotation of XNU/osfmk/i386/fpu.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:  * @OSF_COPYRIGHT@
        !            24:  */
        !            25: /* 
        !            26:  * Mach Operating System
        !            27:  * Copyright (c) 1991 Carnegie Mellon University
        !            28:  * All Rights Reserved.
        !            29:  * 
        !            30:  * Permission to use, copy, modify and distribute this software and its
        !            31:  * documentation is hereby granted, provided that both the copyright
        !            32:  * notice and this permission notice appear in all copies of the
        !            33:  * software, derivative works or modified versions, and any portions
        !            34:  * thereof, and that both notices appear in supporting documentation.
        !            35:  * 
        !            36:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            37:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            38:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            39:  * 
        !            40:  * Carnegie Mellon requests users of this software to return to
        !            41:  * 
        !            42:  *  Software Distribution Coordinator  or  [email protected]
        !            43:  *  School of Computer Science
        !            44:  *  Carnegie Mellon University
        !            45:  *  Pittsburgh PA 15213-3890
        !            46:  * 
        !            47:  * any improvements or extensions that they make and grant Carnegie Mellon 
        !            48:  * the rights to redistribute these changes.
        !            49:  */
        !            50: 
        !            51: /*
        !            52:  */
        !            53: 
        !            54: #ifndef        _I386_FPU_H_
        !            55: #define        _I386_FPU_H_
        !            56: 
        !            57: /*
        !            58:  * Macro definitions for routines to manipulate the
        !            59:  * floating-point processor.
        !            60:  */
        !            61: 
        !            62: #include <cpus.h>
        !            63: #include <i386/proc_reg.h>
        !            64: #include <i386/thread.h>
        !            65: #include <kern/kern_types.h>
        !            66: #include <mach/i386/kern_return.h>
        !            67: #include <mach/i386/thread_status.h>
        !            68: 
        !            69: /*
        !            70:  * FPU instructions.
        !            71:  */
        !            72: #define        fninit() \
        !            73:        __asm__ volatile("fninit")
        !            74: 
        !            75: #define        fnstcw(control) \
        !            76:        __asm__("fnstcw %0" : "=m" (*(unsigned short *)(control)))
        !            77: 
        !            78: #define        fldcw(control) \
        !            79:        __asm__ volatile("fldcw %0" : : "m" (*(unsigned short *) &(control)) )
        !            80: 
        !            81: extern unsigned short          fnstsw(void);
        !            82: 
        !            83: extern __inline__ unsigned short fnstsw(void)
        !            84: {
        !            85:        unsigned short status;
        !            86:        __asm__ volatile("fnstsw %0" : "=ma" (status));
        !            87:        return(status);
        !            88: }
        !            89: 
        !            90: #define        fnclex() \
        !            91:        __asm__ volatile("fnclex")
        !            92: 
        !            93: #define        fnsave(state) \
        !            94:        __asm__ volatile("fnsave %0" : "=m" (*state))
        !            95: 
        !            96: #define        frstor(state) \
        !            97:        __asm__ volatile("frstor %0" : : "m" (state))
        !            98: 
        !            99: #define fwait() \
        !           100:        __asm__("fwait");
        !           101: 
        !           102: 
        !           103: #define        fpu_load_context(pcb)
        !           104: 
        !           105: /*
        !           106:  * Save thread`s FPU context.
        !           107:  * If only one CPU, we just set the task-switched bit,
        !           108:  * to keep the new thread from using the coprocessor.
        !           109:  * If multiple CPUs, we save the entire state.
        !           110:  */
        !           111: #if    NCPUS > 1
        !           112: #define        fpu_save_context(thread) \
        !           113:     { \
        !           114:        register struct i386_fpsave_state *ifps; \
        !           115:        ifps = (thread)->top_act->mact.pcb->ims.ifps; \
        !           116:        if (ifps != 0 && !ifps->fp_valid) { \
        !           117:            /* registers are in FPU - save to memory */ \
        !           118:            ifps->fp_valid = TRUE; \
        !           119:            fnsave(&ifps->fp_save_state); \
        !           120:        } \
        !           121:        set_ts(); \
        !           122:     }
        !           123:            
        !           124: #else  /* NCPUS == 1 */
        !           125: #define        fpu_save_context(thread) \
        !           126:     { \
        !           127:            set_ts(); \
        !           128:     }
        !           129: 
        !           130: #endif /* NCPUS == 1 */
        !           131: 
        !           132: 
        !           133: extern int     fp_kind;
        !           134: 
        !           135: extern void            init_fpu(void);
        !           136: extern void            fpu_module_init(void);
        !           137: extern void            fp_free(
        !           138:                                struct i386_fpsave_state        * fps);
        !           139: extern kern_return_t   fpu_set_state(
        !           140:                                thread_act_t                    thr_act,
        !           141:                                struct i386_float_state         * st);
        !           142: extern kern_return_t   fpu_get_state(
        !           143:                                thread_act_t                    thr_act,
        !           144:                                struct i386_float_state         * st);
        !           145: extern void            fpnoextflt(void);
        !           146: extern void            fpextovrflt(void);
        !           147: extern void            fpexterrflt(void);
        !           148: extern void            fp_state_alloc(void);
        !           149: extern void            fpintr(void);
        !           150: extern void            fpflush(thread_act_t);
        !           151: 
        !           152: #endif /* _I386_FPU_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.