17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 525cf1a30Sjl139090 * Common Development and Distribution License (the "License"). 625cf1a30Sjl139090 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 228159a906SSree Vemuri * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_FPU_FPU_SIMULATOR_H 277c478bd9Sstevel@tonic-gate #define _SYS_FPU_FPU_SIMULATOR_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* SunOS-4.0 1.10 */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate /* 327c478bd9Sstevel@tonic-gate * sparc floating-point simulator definitions. 337c478bd9Sstevel@tonic-gate */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifndef _ASM 367c478bd9Sstevel@tonic-gate #include <sys/types.h> 377c478bd9Sstevel@tonic-gate #include <sys/ieeefp.h> 387c478bd9Sstevel@tonic-gate #include <vm/seg.h> 397c478bd9Sstevel@tonic-gate #include <sys/kstat.h> 407c478bd9Sstevel@tonic-gate #endif /* _ASM */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #ifdef __cplusplus 437c478bd9Sstevel@tonic-gate extern "C" { 447c478bd9Sstevel@tonic-gate #endif 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * Constants to decode/extract "fitos" instruction fields 487c478bd9Sstevel@tonic-gate */ 497c478bd9Sstevel@tonic-gate #define FITOS_INSTR_MASK 0xc1f83fe0 507c478bd9Sstevel@tonic-gate #define FITOS_INSTR 0x81a01880 517c478bd9Sstevel@tonic-gate #define FITOS_RS2_SHIFT 0 527c478bd9Sstevel@tonic-gate #define FITOS_RD_SHIFT 25 537c478bd9Sstevel@tonic-gate #define FITOS_REG_MASK 0x1f 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #ifndef _ASM 567c478bd9Sstevel@tonic-gate /* PUBLIC TYPES */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate enum fcc_type { /* relationships */ 597c478bd9Sstevel@tonic-gate fcc_equal = 0, 607c478bd9Sstevel@tonic-gate fcc_less = 1, 617c478bd9Sstevel@tonic-gate fcc_greater = 2, 627c478bd9Sstevel@tonic-gate fcc_unordered = 3 637c478bd9Sstevel@tonic-gate }; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate enum cc_type { /* icc/fcc number */ 667c478bd9Sstevel@tonic-gate fcc_0 = 0, 677c478bd9Sstevel@tonic-gate fcc_1 = 1, 687c478bd9Sstevel@tonic-gate fcc_2 = 2, 697c478bd9Sstevel@tonic-gate fcc_3 = 3, 707c478bd9Sstevel@tonic-gate icc = 4, 717c478bd9Sstevel@tonic-gate xcc = 6 727c478bd9Sstevel@tonic-gate }; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* FSR types. */ 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate enum ftt_type { /* types of traps */ 777c478bd9Sstevel@tonic-gate ftt_none = 0, 787c478bd9Sstevel@tonic-gate ftt_ieee = 1, 797c478bd9Sstevel@tonic-gate ftt_unfinished = 2, 807c478bd9Sstevel@tonic-gate ftt_unimplemented = 3, 817c478bd9Sstevel@tonic-gate ftt_sequence = 4, 827c478bd9Sstevel@tonic-gate ftt_alignment = 5, /* defined by software convention only */ 837c478bd9Sstevel@tonic-gate ftt_fault = 6, /* defined by software convention only */ 847c478bd9Sstevel@tonic-gate ftt_7 = 7 857c478bd9Sstevel@tonic-gate }; 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate typedef struct { /* sparc V9 FSR. */ 887c478bd9Sstevel@tonic-gate unsigned int : 26; 897c478bd9Sstevel@tonic-gate unsigned int fcc3 : 2; /* fp condition code 3 */ 907c478bd9Sstevel@tonic-gate unsigned int fcc2 : 2; /* fp condition code 2 */ 917c478bd9Sstevel@tonic-gate unsigned int fcc1 : 2; /* fp condition code 1 */ 927c478bd9Sstevel@tonic-gate /* enum fp_direction_type */ 937c478bd9Sstevel@tonic-gate unsigned int rnd : 2; /* rounding direction */ 947c478bd9Sstevel@tonic-gate unsigned int rnp : 2; /* for v7 compatibility only */ 957c478bd9Sstevel@tonic-gate unsigned int tem : 5; /* trap enable mask */ 967c478bd9Sstevel@tonic-gate unsigned int ns : 1; /* non-standard */ 977c478bd9Sstevel@tonic-gate unsigned int : 5; 987c478bd9Sstevel@tonic-gate /* enum ftt_type */ 997c478bd9Sstevel@tonic-gate unsigned int ftt : 3; /* FPU trap type */ 1007c478bd9Sstevel@tonic-gate unsigned int qne : 1; /* FPQ not empty */ 1017c478bd9Sstevel@tonic-gate unsigned int pr : 1; /* partial result */ 1027c478bd9Sstevel@tonic-gate /* enum fcc_type */ 1037c478bd9Sstevel@tonic-gate unsigned int fcc : 2; /* fp condition code 0 */ 1047c478bd9Sstevel@tonic-gate unsigned int aexc : 5; /* accumulated exceptions */ 1057c478bd9Sstevel@tonic-gate unsigned int cexc : 5; /* current exception */ 1067c478bd9Sstevel@tonic-gate } fsr_types; 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * The C compiler and the C spec do not support bitfields in a long long, 1107c478bd9Sstevel@tonic-gate * as per fsr_types above, so don't hold your breath waiting for this 1117c478bd9Sstevel@tonic-gate * workaround cruft to disappear. 1127c478bd9Sstevel@tonic-gate */ 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate typedef union { 1157c478bd9Sstevel@tonic-gate fsr_types fsr; 1167c478bd9Sstevel@tonic-gate uint64_t ll; 1177c478bd9Sstevel@tonic-gate } fsr_type; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #define fcc3 fsr.fcc3 1207c478bd9Sstevel@tonic-gate #define fcc2 fsr.fcc2 1217c478bd9Sstevel@tonic-gate #define fcc1 fsr.fcc1 1227c478bd9Sstevel@tonic-gate #define fcc0 fsr.fcc 1237c478bd9Sstevel@tonic-gate #define rnd fsr.rnd 1247c478bd9Sstevel@tonic-gate #define rnp fsr.rnp 1257c478bd9Sstevel@tonic-gate #define tem fsr.tem 1267c478bd9Sstevel@tonic-gate #define aexc fsr.aexc 1277c478bd9Sstevel@tonic-gate #define cexc fsr.cexc 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate typedef /* FPU register viewed as single components. */ 1307c478bd9Sstevel@tonic-gate struct { 1317c478bd9Sstevel@tonic-gate uint32_t sign : 1; 1327c478bd9Sstevel@tonic-gate uint32_t exponent : 8; 1337c478bd9Sstevel@tonic-gate uint32_t significand : 23; 1347c478bd9Sstevel@tonic-gate } single_type; 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate typedef /* FPU register viewed as double components. */ 1377c478bd9Sstevel@tonic-gate struct { 1387c478bd9Sstevel@tonic-gate uint32_t sign : 1; 1397c478bd9Sstevel@tonic-gate uint32_t exponent : 11; 1407c478bd9Sstevel@tonic-gate uint32_t significand : 20; 1417c478bd9Sstevel@tonic-gate } double_type; 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate typedef /* FPU register viewed as extended components. */ 1447c478bd9Sstevel@tonic-gate struct { 1457c478bd9Sstevel@tonic-gate uint32_t sign : 1; 1467c478bd9Sstevel@tonic-gate uint32_t exponent : 15; 1477c478bd9Sstevel@tonic-gate uint32_t significand : 16; 1487c478bd9Sstevel@tonic-gate } extended_type; 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate typedef /* FPU register with multiple data views. */ 1517c478bd9Sstevel@tonic-gate union { 1527c478bd9Sstevel@tonic-gate int32_t int32_reg; 1537c478bd9Sstevel@tonic-gate int64_t int64_reg; 1547c478bd9Sstevel@tonic-gate uint32_t uint32_reg; 1557c478bd9Sstevel@tonic-gate uint64_t uint64_reg; 1567c478bd9Sstevel@tonic-gate float float_reg; 1577c478bd9Sstevel@tonic-gate single_type single_reg; 1587c478bd9Sstevel@tonic-gate double_type double_reg; 1597c478bd9Sstevel@tonic-gate extended_type extended_reg; 1607c478bd9Sstevel@tonic-gate } freg_type; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate enum fp_op_type { /* Type specifiers in FPU instructions. */ 1637c478bd9Sstevel@tonic-gate fp_op_int32 = 0, /* Not in hardware, but convenient to define. */ 1647c478bd9Sstevel@tonic-gate fp_op_single = 1, 1657c478bd9Sstevel@tonic-gate fp_op_double = 2, 1667c478bd9Sstevel@tonic-gate fp_op_extended = 3, 1677c478bd9Sstevel@tonic-gate fp_op_int64 = 4 1687c478bd9Sstevel@tonic-gate }; 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate enum fp_opcode { /* FPU op codes, minus precision and leading 0. */ 1717c478bd9Sstevel@tonic-gate fmovs = 0x0, 1727c478bd9Sstevel@tonic-gate fnegs = 0x1, 1737c478bd9Sstevel@tonic-gate fabss = 0x2, 1747c478bd9Sstevel@tonic-gate fp_op_3 = 3, fp_op_4 = 4, fp_op_5 = 5, fp_op_6 = 6, fp_op_7 = 7, 1757c478bd9Sstevel@tonic-gate fp_op_8 = 0x8, 1767c478bd9Sstevel@tonic-gate fp_op_9 = 0x9, 1777c478bd9Sstevel@tonic-gate fsqrt = 0xa, 1787c478bd9Sstevel@tonic-gate fp_op_b = 0xb, fp_op_c = 0xc, fp_op_d = 0xd, 1797c478bd9Sstevel@tonic-gate fp_op_e = 0xe, fp_op_f = 0xf, 1807c478bd9Sstevel@tonic-gate fadd = 0x10, 1817c478bd9Sstevel@tonic-gate fsub = 0x11, 1827c478bd9Sstevel@tonic-gate fmul = 0x12, 1837c478bd9Sstevel@tonic-gate fdiv = 0x13, 1847c478bd9Sstevel@tonic-gate fcmp = 0x14, 1857c478bd9Sstevel@tonic-gate fcmpe = 0x15, 1867c478bd9Sstevel@tonic-gate fp_op_16 = 0x16, fp_op_17 = 0x17, 1877c478bd9Sstevel@tonic-gate fp_op_18 = 0x18, 1887c478bd9Sstevel@tonic-gate fp_op_19 = 0x19, 1897c478bd9Sstevel@tonic-gate fsmuld = 0x1a, 1907c478bd9Sstevel@tonic-gate fdmulx = 0x1b, 1917c478bd9Sstevel@tonic-gate ftoll = 0x20, 1927c478bd9Sstevel@tonic-gate flltos = 0x21, 1937c478bd9Sstevel@tonic-gate flltod = 0x22, 1947c478bd9Sstevel@tonic-gate flltox = 0x23, 1957c478bd9Sstevel@tonic-gate fp_op_24 = 0x24, fp_op_25 = 0x25, fp_op_26 = 0x26, fp_op_27 = 0x27, 1967c478bd9Sstevel@tonic-gate fp_op_28 = 0x28, fp_op_29 = 0x29, fp_op_2a = 0x2a, fp_op_2b = 0x2b, 1977c478bd9Sstevel@tonic-gate fp_op_2c = 0x2c, fp_op_2d = 0x2d, fp_op_2e = 0x2e, fp_op_2f = 0x2f, 1987c478bd9Sstevel@tonic-gate fp_op_30 = 0x30, 1997c478bd9Sstevel@tonic-gate fitos = 0x31, 2007c478bd9Sstevel@tonic-gate fitod = 0x32, 2017c478bd9Sstevel@tonic-gate fitox = 0x33, 2027c478bd9Sstevel@tonic-gate ftoi = 0x34, 2037c478bd9Sstevel@tonic-gate fp_op_35 = 0x35, fp_op_36 = 0x36, fp_op_37 = 0x37, 2047c478bd9Sstevel@tonic-gate ft_op_38 = 0x38, 2057c478bd9Sstevel@tonic-gate fp_op_39 = 0x39, fp_op_3a = 0x3a, fp_op_3b = 0x3b, 2067c478bd9Sstevel@tonic-gate fp_op_3c = 0x3c, 2079d0d62adSJason Beloro fp_op_3d = 0x3d, fp_op_3e = 0x3e, fp_op_3f = 0x3f 2087c478bd9Sstevel@tonic-gate }; 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate typedef /* FPU instruction. */ 2117c478bd9Sstevel@tonic-gate struct { 2127c478bd9Sstevel@tonic-gate uint32_t hibits : 2; /* Top two bits. */ 2137c478bd9Sstevel@tonic-gate uint32_t rd : 5; /* Destination. */ 2147c478bd9Sstevel@tonic-gate uint32_t op3 : 6; /* Main op code. */ 2157c478bd9Sstevel@tonic-gate uint32_t rs1 : 5; /* First operand. */ 2167c478bd9Sstevel@tonic-gate uint32_t ibit : 1; /* I format bit. */ 2177c478bd9Sstevel@tonic-gate uint32_t /* enum fp_opcode */ opcode : 6; /* Floating-point op code. */ 2187c478bd9Sstevel@tonic-gate uint32_t /* enum fp_op_type */ prec : 2; /* Precision. */ 2197c478bd9Sstevel@tonic-gate uint32_t rs2 : 5; /* Second operand. */ 2207c478bd9Sstevel@tonic-gate } fp_inst_type; 2217c478bd9Sstevel@tonic-gate 2229d0d62adSJason Beloro enum fp_op_fma_var { /* IMPDEP2B FMA-fused instr. variations */ 22325cf1a30Sjl139090 fmadd = 0, 22425cf1a30Sjl139090 fmsub = 1, 22525cf1a30Sjl139090 fnmsub = 2, 22625cf1a30Sjl139090 fnmadd = 3 22725cf1a30Sjl139090 }; 22825cf1a30Sjl139090 2299d0d62adSJason Beloro typedef /* IMPDEP2B FPU FMA-fused instruction. */ 23025cf1a30Sjl139090 struct { 23125cf1a30Sjl139090 uint32_t hibits : 2; /* Top two bits. */ 23225cf1a30Sjl139090 uint32_t rd : 5; /* Destination. */ 23325cf1a30Sjl139090 uint32_t op3 : 6; /* Main op code. */ 23425cf1a30Sjl139090 uint32_t rs1 : 5; /* First operand. */ 23525cf1a30Sjl139090 uint32_t rs3 : 5; /* Third operand */ 23625cf1a30Sjl139090 uint32_t /* enum fp_op_fma_var */ var : 2; /* Instr. variation */ 23725cf1a30Sjl139090 uint32_t sz : 2; /* Size */ 23825cf1a30Sjl139090 uint32_t rs2 : 5; /* Second operand. */ 23925cf1a30Sjl139090 } fp_fma_inst_type; 24025cf1a30Sjl139090 2417c478bd9Sstevel@tonic-gate typedef /* Integer condition code. */ 2427c478bd9Sstevel@tonic-gate struct { 2437c478bd9Sstevel@tonic-gate uint32_t : 28; /* the unused part */ 2447c478bd9Sstevel@tonic-gate uint32_t n : 1; /* Negative bit. */ 2457c478bd9Sstevel@tonic-gate uint32_t z : 1; /* Zero bit. */ 2467c478bd9Sstevel@tonic-gate uint32_t v : 1; /* Overflow bit. */ 2477c478bd9Sstevel@tonic-gate uint32_t c : 1; /* Carry bit. */ 2487c478bd9Sstevel@tonic-gate } ccr_type; 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate typedef /* FPU data used by simulator. */ 2517c478bd9Sstevel@tonic-gate struct { 2527c478bd9Sstevel@tonic-gate uint_t fp_fsrtem; 2537c478bd9Sstevel@tonic-gate enum fp_direction_type fp_direction; 2547c478bd9Sstevel@tonic-gate enum fp_precision_type fp_precision; 2557c478bd9Sstevel@tonic-gate uint_t fp_current_exceptions; 2567c478bd9Sstevel@tonic-gate kfpu_t *fp_current_pfregs; 2577c478bd9Sstevel@tonic-gate void (*fp_current_read_freg) (); 2587c478bd9Sstevel@tonic-gate void (*fp_current_write_freg) (); 2597c478bd9Sstevel@tonic-gate void (*fp_current_read_dreg) (); 2607c478bd9Sstevel@tonic-gate void (*fp_current_write_dreg) (); 2615892374fSdf157793 uint64_t (*fp_current_read_gsr) (kfpu_t *); 2625892374fSdf157793 void (*fp_current_write_gsr) (uint64_t, kfpu_t *); 2637c478bd9Sstevel@tonic-gate int fp_trapcode; 2647c478bd9Sstevel@tonic-gate char *fp_trapaddr; 2657c478bd9Sstevel@tonic-gate struct regs *fp_traprp; 2667c478bd9Sstevel@tonic-gate enum seg_rw fp_traprw; 2677c478bd9Sstevel@tonic-gate } fp_simd_type; 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate /* 2707c478bd9Sstevel@tonic-gate * FPU related kstat structures 2717c478bd9Sstevel@tonic-gate */ 2727c478bd9Sstevel@tonic-gate struct fpustat_kstat { 2737c478bd9Sstevel@tonic-gate struct kstat_named fpu_ieee_traps; 2747c478bd9Sstevel@tonic-gate struct kstat_named fpu_unfinished_traps; 2757c478bd9Sstevel@tonic-gate struct kstat_named fpu_unimplemented_traps; 2767c478bd9Sstevel@tonic-gate }; 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate struct fpuinfo_kstat { 2797c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fmovs; 2807c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fmovd; 2817c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fmovq; 2827c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fnegs; 2837c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fnegd; 2847c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fnegq; 2857c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fabss; 2867c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fabsd; 2877c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fabsq; 2887c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fsqrts; 2897c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fsqrtd; 2907c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fsqrtq; 2917c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fadds; 2927c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_faddd; 2937c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_faddq; 2947c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fsubs; 2957c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fsubd; 2967c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fsubq; 2977c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fmuls; 2987c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fmuld; 2997c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fmulq; 3007c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fdivs; 3017c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fdivd; 3027c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fdivq; 3037c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fcmps; 3047c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fcmpd; 3057c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fcmpq; 3067c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fcmpes; 3077c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fcmped; 3087c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fcmpeq; 3097c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fsmuld; 3107c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fdmulx; 3117c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fstox; 3127c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fdtox; 3137c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fqtox; 3147c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fxtos; 3157c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fxtod; 3167c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fxtoq; 3177c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fitos; 3187c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fitod; 3197c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fitoq; 3207c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fstoi; 3217c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fdtoi; 3227c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fqtoi; 3237c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fmovcc; 3247c478bd9Sstevel@tonic-gate struct kstat_named fpu_sim_fmovr; 32525cf1a30Sjl139090 struct kstat_named fpu_sim_fmadds; 32625cf1a30Sjl139090 struct kstat_named fpu_sim_fmaddd; 32725cf1a30Sjl139090 struct kstat_named fpu_sim_fmsubs; 32825cf1a30Sjl139090 struct kstat_named fpu_sim_fmsubd; 32925cf1a30Sjl139090 struct kstat_named fpu_sim_fnmadds; 33025cf1a30Sjl139090 struct kstat_named fpu_sim_fnmaddd; 33125cf1a30Sjl139090 struct kstat_named fpu_sim_fnmsubs; 33225cf1a30Sjl139090 struct kstat_named fpu_sim_fnmsubd; 33325cf1a30Sjl139090 struct kstat_named fpu_sim_invalid; 3347c478bd9Sstevel@tonic-gate }; 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate struct visinfo_kstat { 3377c478bd9Sstevel@tonic-gate struct kstat_named vis_edge8; 3387c478bd9Sstevel@tonic-gate struct kstat_named vis_edge8n; 3397c478bd9Sstevel@tonic-gate struct kstat_named vis_edge8l; 3407c478bd9Sstevel@tonic-gate struct kstat_named vis_edge8ln; 3417c478bd9Sstevel@tonic-gate struct kstat_named vis_edge16; 3427c478bd9Sstevel@tonic-gate struct kstat_named vis_edge16n; 3437c478bd9Sstevel@tonic-gate struct kstat_named vis_edge16l; 3447c478bd9Sstevel@tonic-gate struct kstat_named vis_edge16ln; 3457c478bd9Sstevel@tonic-gate struct kstat_named vis_edge32; 3467c478bd9Sstevel@tonic-gate struct kstat_named vis_edge32n; 3477c478bd9Sstevel@tonic-gate struct kstat_named vis_edge32l; 3487c478bd9Sstevel@tonic-gate struct kstat_named vis_edge32ln; 3497c478bd9Sstevel@tonic-gate struct kstat_named vis_array8; 3507c478bd9Sstevel@tonic-gate struct kstat_named vis_array16; 3517c478bd9Sstevel@tonic-gate struct kstat_named vis_array32; 3527c478bd9Sstevel@tonic-gate struct kstat_named vis_bmask; 3537c478bd9Sstevel@tonic-gate struct kstat_named vis_fcmple16; 3547c478bd9Sstevel@tonic-gate struct kstat_named vis_fcmpne16; 3557c478bd9Sstevel@tonic-gate struct kstat_named vis_fcmpgt16; 3567c478bd9Sstevel@tonic-gate struct kstat_named vis_fcmpeq16; 3577c478bd9Sstevel@tonic-gate struct kstat_named vis_fcmple32; 3587c478bd9Sstevel@tonic-gate struct kstat_named vis_fcmpne32; 3597c478bd9Sstevel@tonic-gate struct kstat_named vis_fcmpgt32; 3607c478bd9Sstevel@tonic-gate struct kstat_named vis_fcmpeq32; 3617c478bd9Sstevel@tonic-gate struct kstat_named vis_fmul8x16; 3627c478bd9Sstevel@tonic-gate struct kstat_named vis_fmul8x16au; 3637c478bd9Sstevel@tonic-gate struct kstat_named vis_fmul8x16al; 3647c478bd9Sstevel@tonic-gate struct kstat_named vis_fmul8sux16; 3657c478bd9Sstevel@tonic-gate struct kstat_named vis_fmul8ulx16; 3667c478bd9Sstevel@tonic-gate struct kstat_named vis_fmuld8sux16; 3677c478bd9Sstevel@tonic-gate struct kstat_named vis_fmuld8ulx16; 3687c478bd9Sstevel@tonic-gate struct kstat_named vis_fpack16; 3697c478bd9Sstevel@tonic-gate struct kstat_named vis_fpack32; 3707c478bd9Sstevel@tonic-gate struct kstat_named vis_fpackfix; 3717c478bd9Sstevel@tonic-gate struct kstat_named vis_fexpand; 3727c478bd9Sstevel@tonic-gate struct kstat_named vis_fpmerge; 3737c478bd9Sstevel@tonic-gate struct kstat_named vis_pdist; 3748159a906SSree Vemuri struct kstat_named vis_pdistn; 3757c478bd9Sstevel@tonic-gate struct kstat_named vis_bshuffle; 3767c478bd9Sstevel@tonic-gate }; 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate #define VISINFO_KSTAT(opcode) { \ 3797c478bd9Sstevel@tonic-gate extern void __dtrace_probe___visinfo_##opcode(uint64_t *); \ 3807c478bd9Sstevel@tonic-gate uint64_t *stataddr = &visinfo.opcode.value.ui64; \ 3817c478bd9Sstevel@tonic-gate __dtrace_probe___visinfo_##opcode(stataddr); \ 3821a5e258fSJosef 'Jeff' Sipek atomic_inc_64(&visinfo.opcode.value.ui64); \ 3837c478bd9Sstevel@tonic-gate } 3847c478bd9Sstevel@tonic-gate 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate /* PUBLIC FUNCTIONS */ 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate #ifdef __STDC__ 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate /* 3917c478bd9Sstevel@tonic-gate * fpu_vis_sim simulates FPU VIS Partial load store instructions; reads and 3927c478bd9Sstevel@tonic-gate * writes FPU data registers directly or works with the PCB image if fpu_exists 3937c478bd9Sstevel@tonic-gate * is 0. 3947c478bd9Sstevel@tonic-gate */ 3957c478bd9Sstevel@tonic-gate extern enum ftt_type fpu_vis_sim(fp_simd_type *pfpsd, fp_inst_type *pinst, 3967c478bd9Sstevel@tonic-gate struct regs *pregs, fsr_type *pfsr, uint64_t gsr, uint32_t inst); 3977c478bd9Sstevel@tonic-gate /* 3987c478bd9Sstevel@tonic-gate * fpu_simulator simulates FPU instructions only; reads and writes FPU data 3997c478bd9Sstevel@tonic-gate * registers directly. 4007c478bd9Sstevel@tonic-gate */ 4017c478bd9Sstevel@tonic-gate extern enum ftt_type fpu_simulator(fp_simd_type *pfpsd, fp_inst_type *pinst, 4027c478bd9Sstevel@tonic-gate fsr_type *pfsr, uint64_t gsr, uint32_t inst); 4037c478bd9Sstevel@tonic-gate /* 4047c478bd9Sstevel@tonic-gate * fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU 4057c478bd9Sstevel@tonic-gate * data registers from image in pfpu. 4067c478bd9Sstevel@tonic-gate */ 4077c478bd9Sstevel@tonic-gate extern enum ftt_type fp_emulator(fp_simd_type *pfpsd, fp_inst_type *pinst, 4087c478bd9Sstevel@tonic-gate struct regs *rp, void *prw, kfpu_t *pfpu); 4097c478bd9Sstevel@tonic-gate /* 4107c478bd9Sstevel@tonic-gate * fp_traps handles passing exception conditions to the kernel. 4117c478bd9Sstevel@tonic-gate * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt). 4127c478bd9Sstevel@tonic-gate */ 4137c478bd9Sstevel@tonic-gate extern void fp_traps(fp_simd_type *pfpsd, enum ftt_type ftt, struct regs *rp); 4147c478bd9Sstevel@tonic-gate 4157c478bd9Sstevel@tonic-gate /* 4167c478bd9Sstevel@tonic-gate * fp_kstat_update tracks fpu exception conditions. 4177c478bd9Sstevel@tonic-gate * It is called after a hardware trap returns a non-zero ftt. 4187c478bd9Sstevel@tonic-gate */ 4197c478bd9Sstevel@tonic-gate extern void fp_kstat_update(enum ftt_type ftt); 4207c478bd9Sstevel@tonic-gate 4217c478bd9Sstevel@tonic-gate /* 4227c478bd9Sstevel@tonic-gate * fp_precise handles floating point unimplemented and unfinished traps, 4237c478bd9Sstevel@tonic-gate * for sparc V9 hardware. These traps are normally passed along to the 4247c478bd9Sstevel@tonic-gate * fpu_simulator, to see if it can run the unimplemented instruction or 4257c478bd9Sstevel@tonic-gate * finish the unfinished instruction. Needless to say, this takes time. 4267c478bd9Sstevel@tonic-gate */ 4277c478bd9Sstevel@tonic-gate extern void fp_precise(struct regs *rp); 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate /* 4307c478bd9Sstevel@tonic-gate * fpu_trap handles V9 floating point ieee and other floating point traps. 4317c478bd9Sstevel@tonic-gate * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt), 4327c478bd9Sstevel@tonic-gate * and from the _fp_ieee_exception trap handler. 4337c478bd9Sstevel@tonic-gate */ 4347c478bd9Sstevel@tonic-gate extern void fpu_trap(struct regs *rp, caddr_t addr, uint32_t type, 4357c478bd9Sstevel@tonic-gate uint32_t code); 4367c478bd9Sstevel@tonic-gate 4377c478bd9Sstevel@tonic-gate #else /* ! __STDC__ */ 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate /* 4407c478bd9Sstevel@tonic-gate * fpu_simulator simulates FPU instructions only; reads and writes FPU data 4417c478bd9Sstevel@tonic-gate * registers directly. 4427c478bd9Sstevel@tonic-gate */ 4437c478bd9Sstevel@tonic-gate extern enum ftt_type fpu_simulator( 4447c478bd9Sstevel@tonic-gate fp_simd_type *pfpsd, /* Pointer to FPU simulator data */ 4457c478bd9Sstevel@tonic-gate fp_inst_type *pinst, /* Pointer to FPU instruction to simulate. */ 4467c478bd9Sstevel@tonic-gate fsr_type *pfsr, /* Pointer to image of FSR to read & write. */ 4477c478bd9Sstevel@tonic-gate int instr); /* Instruction to emulate. */ 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate /* 4507c478bd9Sstevel@tonic-gate * fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU 4517c478bd9Sstevel@tonic-gate * data registers from image in pfpu. 4527c478bd9Sstevel@tonic-gate */ 4537c478bd9Sstevel@tonic-gate extern enum ftt_type fp_emulator( 4547c478bd9Sstevel@tonic-gate fp_simd_type *pfpsd, /* Pointer to FPU simulator data */ 4557c478bd9Sstevel@tonic-gate fp_inst_type *pinst, /* Pointer to FPU instruction to simulate. */ 4567c478bd9Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 4577c478bd9Sstevel@tonic-gate struct rwindow *pwindow, /* Pointer to locals and ins. */ 458*bc0e9132SGordon Ross struct _fpu *pfpu); /* Pointer to FPU register block. */ 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate /* 4617c478bd9Sstevel@tonic-gate * fp_traps handles passing exception conditions to the kernel. 4627c478bd9Sstevel@tonic-gate * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt). 4637c478bd9Sstevel@tonic-gate */ 4647c478bd9Sstevel@tonic-gate extern void fp_traps( 4657c478bd9Sstevel@tonic-gate fp_simd_type *pfpsd, /* Pointer to FPU simulator data */ 4667c478bd9Sstevel@tonic-gate enum ftt_type ftt, /* Type of trap. */ 4677c478bd9Sstevel@tonic-gate struct regs *rp); /* Pointer to PCB image of registers. */ 4687c478bd9Sstevel@tonic-gate 4697c478bd9Sstevel@tonic-gate /* 4707c478bd9Sstevel@tonic-gate * fp_kstat_update tracks fpu exception conditions. 4717c478bd9Sstevel@tonic-gate * It is called after a hardware trap returns a non-zero ftt. 4727c478bd9Sstevel@tonic-gate */ 4737c478bd9Sstevel@tonic-gate extern void fp_kstat_update(enum ftt_type ftt); /* Type of trap. */ 4747c478bd9Sstevel@tonic-gate 4757c478bd9Sstevel@tonic-gate /* 4767c478bd9Sstevel@tonic-gate * fp_precise handles floating point unimplemented and unfinished traps, 4777c478bd9Sstevel@tonic-gate * for sparc V9 hardware. These traps are normally passed along to the 4787c478bd9Sstevel@tonic-gate * fpu_simulator, to see if it can run the unimplemented instruction or 4797c478bd9Sstevel@tonic-gate * finish the unfinished instruction. Needless to say, this takes time. 4807c478bd9Sstevel@tonic-gate */ 4817c478bd9Sstevel@tonic-gate extern void fp_precise( 4827c478bd9Sstevel@tonic-gate struct regs *rp); /* Pointer to PCB image of registers. */ 4837c478bd9Sstevel@tonic-gate 4847c478bd9Sstevel@tonic-gate /* 4857c478bd9Sstevel@tonic-gate * fpu_trap handles V9 floating point ieee and other floating point traps. 4867c478bd9Sstevel@tonic-gate * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt), 4877c478bd9Sstevel@tonic-gate * and from the _fp_ieee_exception trap handler. 4887c478bd9Sstevel@tonic-gate */ 4897c478bd9Sstevel@tonic-gate extern void fpu_trap( 4907c478bd9Sstevel@tonic-gate struct regs *rp, /* Pointer to PCB image of registers. */ 4917c478bd9Sstevel@tonic-gate caddr_t addr, /* Address of trapping instruction. */ 4927c478bd9Sstevel@tonic-gate uint32_t type, /* Type of trapping exception. */ 4937c478bd9Sstevel@tonic-gate uint32_t code); /* Trap code -> si_code. */ 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 4967c478bd9Sstevel@tonic-gate #endif /* _ASM */ 4977c478bd9Sstevel@tonic-gate 4987c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4997c478bd9Sstevel@tonic-gate } 5007c478bd9Sstevel@tonic-gate #endif 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate #endif /* _SYS_FPU_FPU_SIMULATOR_H */ 503