fpu_simulator.h revision 5892374f87ce6849fd36b2baaee28dc8da038b8c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_FPU_FPU_SIMULATOR_H
#define _SYS_FPU_FPU_SIMULATOR_H
#pragma ident "%Z%%M% %I% %E% SMI"
/* SunOS-4.0 1.10 */
/*
* sparc floating-point simulator definitions.
*/
#ifndef _ASM
#endif /* _ASM */
#ifdef __cplusplus
extern "C" {
#endif
/*
*/
#define FITOS_INSTR_MASK 0xc1f83fe0
#define FITOS_INSTR 0x81a01880
#define FITOS_RS2_SHIFT 0
#define FITOS_RD_SHIFT 25
#define FITOS_REG_MASK 0x1f
#ifndef _ASM
/* PUBLIC TYPES */
enum fcc_type { /* relationships */
fcc_equal = 0,
fcc_less = 1,
fcc_greater = 2,
fcc_unordered = 3
};
fcc_0 = 0,
fcc_1 = 1,
fcc_2 = 2,
fcc_3 = 3,
icc = 4,
xcc = 6
};
/* FSR types. */
enum ftt_type { /* types of traps */
ftt_none = 0,
ftt_ieee = 1,
ftt_unfinished = 2,
ftt_unimplemented = 3,
ftt_sequence = 4,
ftt_7 = 7
};
typedef struct { /* sparc V9 FSR. */
unsigned int : 26;
/* enum fp_direction_type */
unsigned int : 5;
/* enum ftt_type */
/* enum fcc_type */
} fsr_types;
/*
* The C compiler and the C spec do not support bitfields in a long long,
* as per fsr_types above, so don't hold your breath waiting for this
* workaround cruft to disappear.
*/
typedef union {
} fsr_type;
typedef /* FPU register viewed as single components. */
struct {
} single_type;
typedef /* FPU register viewed as double components. */
struct {
} double_type;
typedef /* FPU register viewed as extended components. */
struct {
typedef /* FPU register with multiple data views. */
union {
float float_reg;
} freg_type;
enum fp_op_type { /* Type specifiers in FPU instructions. */
fp_op_int32 = 0, /* Not in hardware, but convenient to define. */
fp_op_single = 1,
fp_op_double = 2,
fp_op_extended = 3,
fp_op_int64 = 4
};
enum fp_opcode { /* FPU op codes, minus precision and leading 0. */
fmovs = 0x0,
fnegs = 0x1,
fabss = 0x2,
fp_op_8 = 0x8,
fp_op_9 = 0x9,
fsqrt = 0xa,
fadd = 0x10,
fsub = 0x11,
fmul = 0x12,
fdiv = 0x13,
fcmp = 0x14,
fcmpe = 0x15,
fp_op_18 = 0x18,
fp_op_19 = 0x19,
fsmuld = 0x1a,
fdmulx = 0x1b,
ftoll = 0x20,
flltos = 0x21,
flltod = 0x22,
flltox = 0x23,
fp_op_30 = 0x30,
fitos = 0x31,
fitod = 0x32,
fitox = 0x33,
ftoi = 0x34,
ft_op_38 = 0x38,
fp_op_3c = 0x3c,
};
typedef /* FPU instruction. */
struct {
} fp_inst_type;
typedef /* Integer condition code. */
struct {
} ccr_type;
typedef /* FPU data used by simulator. */
struct {
void (*fp_current_read_freg) ();
void (*fp_current_write_freg) ();
void (*fp_current_read_dreg) ();
void (*fp_current_write_dreg) ();
int fp_trapcode;
char *fp_trapaddr;
} fp_simd_type;
/*
* FPU related kstat structures
*/
struct fpustat_kstat {
struct kstat_named fpu_ieee_traps;
struct kstat_named fpu_unfinished_traps;
struct kstat_named fpu_unimplemented_traps;
};
struct fpuinfo_kstat {
struct kstat_named fpu_sim_fmovs;
struct kstat_named fpu_sim_fmovd;
struct kstat_named fpu_sim_fmovq;
struct kstat_named fpu_sim_fnegs;
struct kstat_named fpu_sim_fnegd;
struct kstat_named fpu_sim_fnegq;
struct kstat_named fpu_sim_fabss;
struct kstat_named fpu_sim_fabsd;
struct kstat_named fpu_sim_fabsq;
struct kstat_named fpu_sim_fsqrts;
struct kstat_named fpu_sim_fsqrtd;
struct kstat_named fpu_sim_fsqrtq;
struct kstat_named fpu_sim_fadds;
struct kstat_named fpu_sim_faddd;
struct kstat_named fpu_sim_faddq;
struct kstat_named fpu_sim_fsubs;
struct kstat_named fpu_sim_fsubd;
struct kstat_named fpu_sim_fsubq;
struct kstat_named fpu_sim_fmuls;
struct kstat_named fpu_sim_fmuld;
struct kstat_named fpu_sim_fmulq;
struct kstat_named fpu_sim_fdivs;
struct kstat_named fpu_sim_fdivd;
struct kstat_named fpu_sim_fdivq;
struct kstat_named fpu_sim_fcmps;
struct kstat_named fpu_sim_fcmpd;
struct kstat_named fpu_sim_fcmpq;
struct kstat_named fpu_sim_fcmpes;
struct kstat_named fpu_sim_fcmped;
struct kstat_named fpu_sim_fcmpeq;
struct kstat_named fpu_sim_fsmuld;
struct kstat_named fpu_sim_fdmulx;
struct kstat_named fpu_sim_fstox;
struct kstat_named fpu_sim_fdtox;
struct kstat_named fpu_sim_fqtox;
struct kstat_named fpu_sim_fxtos;
struct kstat_named fpu_sim_fxtod;
struct kstat_named fpu_sim_fxtoq;
struct kstat_named fpu_sim_fitos;
struct kstat_named fpu_sim_fitod;
struct kstat_named fpu_sim_fitoq;
struct kstat_named fpu_sim_fstoi;
struct kstat_named fpu_sim_fdtoi;
struct kstat_named fpu_sim_fqtoi;
struct kstat_named fpu_sim_fmovcc;
struct kstat_named fpu_sim_fmovr;
};
struct visinfo_kstat {
struct kstat_named vis_edge8;
struct kstat_named vis_edge8n;
struct kstat_named vis_edge8l;
struct kstat_named vis_edge8ln;
struct kstat_named vis_edge16;
struct kstat_named vis_edge16n;
struct kstat_named vis_edge16l;
struct kstat_named vis_edge16ln;
struct kstat_named vis_edge32;
struct kstat_named vis_edge32n;
struct kstat_named vis_edge32l;
struct kstat_named vis_edge32ln;
struct kstat_named vis_array8;
struct kstat_named vis_array16;
struct kstat_named vis_array32;
struct kstat_named vis_bmask;
struct kstat_named vis_fcmple16;
struct kstat_named vis_fcmpne16;
struct kstat_named vis_fcmpgt16;
struct kstat_named vis_fcmpeq16;
struct kstat_named vis_fcmple32;
struct kstat_named vis_fcmpne32;
struct kstat_named vis_fcmpgt32;
struct kstat_named vis_fcmpeq32;
struct kstat_named vis_fmul8x16;
struct kstat_named vis_fmul8x16au;
struct kstat_named vis_fmul8x16al;
struct kstat_named vis_fmul8sux16;
struct kstat_named vis_fmul8ulx16;
struct kstat_named vis_fmuld8sux16;
struct kstat_named vis_fmuld8ulx16;
struct kstat_named vis_fpack16;
struct kstat_named vis_fpack32;
struct kstat_named vis_fpackfix;
struct kstat_named vis_fexpand;
struct kstat_named vis_fpmerge;
struct kstat_named vis_pdist;
struct kstat_named vis_bshuffle;
};
#define VISINFO_KSTAT(opcode) { \
}
/* PUBLIC FUNCTIONS */
#ifdef __STDC__
/*
* fpu_vis_sim simulates FPU VIS Partial load store instructions; reads and
* writes FPU data registers directly or works with the PCB image if fpu_exists
* is 0.
*/
/*
* fpu_simulator simulates FPU instructions only; reads and writes FPU data
* registers directly.
*/
/*
* fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU
* data registers from image in pfpu.
*/
/*
* fp_traps handles passing exception conditions to the kernel.
* It is called after fp_simulator or fp_emulator fail (return a non-zero ftt).
*/
/*
* fp_kstat_update tracks fpu exception conditions.
* It is called after a hardware trap returns a non-zero ftt.
*/
/*
* fp_precise handles floating point unimplemented and unfinished traps,
* for sparc V9 hardware. These traps are normally passed along to the
* fpu_simulator, to see if it can run the unimplemented instruction or
* finish the unfinished instruction. Needless to say, this takes time.
*/
/*
* fpu_trap handles V9 floating point ieee and other floating point traps.
* It is called after fp_simulator or fp_emulator fail (return a non-zero ftt),
* and from the _fp_ieee_exception trap handler.
*/
#else /* ! __STDC__ */
/*
* fpu_simulator simulates FPU instructions only; reads and writes FPU data
* registers directly.
*/
extern enum ftt_type fpu_simulator(
int instr); /* Instruction to emulate. */
/*
* fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU
* data registers from image in pfpu.
*/
extern enum ftt_type fp_emulator(
/*
* fp_traps handles passing exception conditions to the kernel.
* It is called after fp_simulator or fp_emulator fail (return a non-zero ftt).
*/
extern void fp_traps(
/*
* fp_kstat_update tracks fpu exception conditions.
* It is called after a hardware trap returns a non-zero ftt.
*/
/*
* fp_precise handles floating point unimplemented and unfinished traps,
* for sparc V9 hardware. These traps are normally passed along to the
* fpu_simulator, to see if it can run the unimplemented instruction or
* finish the unfinished instruction. Needless to say, this takes time.
*/
extern void fp_precise(
/*
* fpu_trap handles V9 floating point ieee and other floating point traps.
* It is called after fp_simulator or fp_emulator fail (return a non-zero ftt),
* and from the _fp_ieee_exception trap handler.
*/
extern void fpu_trap(
#endif /* __STDC__ */
#endif /* _ASM */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FPU_FPU_SIMULATOR_H */