1331722Seadler/* 2239268Sgonzo * Copyright (c) 2012 Mark Tinguely 3239268Sgonzo * 4239268Sgonzo * All rights reserved. 5239268Sgonzo * 6239268Sgonzo * Redistribution and use in source and binary forms, with or without 7239268Sgonzo * modification, are permitted provided that the following conditions 8239268Sgonzo * are met: 9239268Sgonzo * 1. Redistributions of source code must retain the above copyright 10239268Sgonzo * notice, this list of conditions and the following disclaimer. 11239268Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 12239268Sgonzo * notice, this list of conditions and the following disclaimer in the 13239268Sgonzo * documentation and/or other materials provided with the distribution. 14239268Sgonzo * 15239268Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16239268Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17239268Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18239268Sgonzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19239268Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20239268Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21239268Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22239268Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23239268Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24239268Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25239268Sgonzo * SUCH DAMAGE. 26239268Sgonzo * $FreeBSD: stable/11/sys/arm/include/vfp.h 325831 2017-11-14 22:18:13Z jhb $ 27239268Sgonzo */ 28239268Sgonzo 29239268Sgonzo 30239268Sgonzo#ifndef _MACHINE__VFP_H_ 31239268Sgonzo#define _MACHINE__VFP_H_ 32239268Sgonzo 33239268Sgonzo/* fpsid, fpscr, fpexc are defined in the newer gas */ 34239268Sgonzo#define VFPSID cr0 35239268Sgonzo#define VFPSCR cr1 36239268Sgonzo#define VMVFR1 cr6 37239268Sgonzo#define VMVFR0 cr7 38239268Sgonzo#define VFPEXC cr8 39239268Sgonzo#define VFPINST cr9 /* vfp 1 and 2 except instruction */ 40239268Sgonzo#define VFPINST2 cr10 /* vfp 2? */ 41239268Sgonzo 42239268Sgonzo/* VFPSID */ 43239268Sgonzo#define VFPSID_IMPLEMENTOR_OFF 24 44239268Sgonzo#define VFPSID_IMPLEMENTOR_MASK (0xff000000) 45239268Sgonzo#define VFPSID_HARDSOFT_IMP (0x00800000) 46239268Sgonzo#define VFPSID_SINGLE_PREC 20 /* version 1 and 2 */ 47239268Sgonzo#define VFPSID_SUBVERSION_OFF 16 48239268Sgonzo#define VFPSID_SUBVERSION2_MASK (0x000f0000) /* version 1 and 2 */ 49239268Sgonzo#define VFPSID_SUBVERSION3_MASK (0x007f0000) /* version 3 */ 50251712Sandrew#define VFP_ARCH1 0x0 51251712Sandrew#define VFP_ARCH2 0x1 52251712Sandrew#define VFP_ARCH3 0x2 53239268Sgonzo#define VFPSID_PARTNUMBER_OFF 8 54239268Sgonzo#define VFPSID_PARTNUMBER_MASK (0x0000ff00) 55239268Sgonzo#define VFPSID_VARIANT_OFF 4 56239268Sgonzo#define VFPSID_VARIANT_MASK (0x000000f0) 57239268Sgonzo#define VFPSID_REVISION_MASK 0x0f 58239268Sgonzo 59239268Sgonzo/* VFPSCR */ 60239268Sgonzo#define VFPSCR_CC_N (0x80000000) /* comparison less than */ 61239268Sgonzo#define VFPSCR_CC_Z (0x40000000) /* comparison equal */ 62239268Sgonzo#define VFPSCR_CC_C (0x20000000) /* comparison = > unordered */ 63239268Sgonzo#define VFPSCR_CC_V (0x10000000) /* comparison unordered */ 64239268Sgonzo#define VFPSCR_QC (0x08000000) /* saturation cululative */ 65239268Sgonzo#define VFPSCR_DN (0x02000000) /* default NaN enable */ 66239268Sgonzo#define VFPSCR_FZ (0x01000000) /* flush to zero enabled */ 67239268Sgonzo 68239268Sgonzo#define VFPSCR_RMODE_OFF 22 /* rounding mode offset */ 69239268Sgonzo#define VFPSCR_RMODE_MASK (0x00c00000) /* rounding mode mask */ 70239268Sgonzo#define VFPSCR_RMODE_RN (0x00000000) /* round nearest */ 71239268Sgonzo#define VFPSCR_RMODE_RPI (0x00400000) /* round to plus infinity */ 72239268Sgonzo#define VFPSCR_RMODE_RNI (0x00800000) /* round to neg infinity */ 73239268Sgonzo#define VFPSCR_RMODE_RM (0x00c00000) /* round to zero */ 74239268Sgonzo 75239268Sgonzo#define VFPSCR_STRIDE_OFF 20 /* vector stride -1 */ 76239268Sgonzo#define VFPSCR_STRIDE_MASK (0x00300000) 77239268Sgonzo#define VFPSCR_LEN_OFF 16 /* vector length -1 */ 78239268Sgonzo#define VFPSCR_LEN_MASK (0x00070000) 79239268Sgonzo#define VFPSCR_IDE (0x00008000) /* input subnormal exc enable */ 80239268Sgonzo#define VFPSCR_IXE (0x00001000) /* inexact exception enable */ 81239268Sgonzo#define VFPSCR_UFE (0x00000800) /* underflow exception enable */ 82239268Sgonzo#define VFPSCR_OFE (0x00000400) /* overflow exception enable */ 83239268Sgonzo#define VFPSCR_DNZ (0x00000200) /* div by zero exception en */ 84239268Sgonzo#define VFPSCR_IOE (0x00000100) /* invalid op exec enable */ 85239268Sgonzo#define VFPSCR_IDC (0x00000080) /* input subnormal cumul */ 86239268Sgonzo#define VFPSCR_IXC (0x00000010) /* Inexact cumulative flag */ 87239268Sgonzo#define VFPSCR_UFC (0x00000008) /* underflow cumulative flag */ 88239268Sgonzo#define VFPSCR_OFC (0x00000004) /* overflow cumulative flag */ 89239268Sgonzo#define VFPSCR_DZC (0x00000002) /* division by zero flag */ 90239268Sgonzo#define VFPSCR_IOC (0x00000001) /* invalid operation cumul */ 91239268Sgonzo 92239268Sgonzo/* VFPEXC */ 93239268Sgonzo#define VFPEXC_EX (0x80000000) /* exception v1 v2 */ 94239268Sgonzo#define VFPEXC_EN (0x40000000) /* vfp enable */ 95290243Sgonzo#define VFPEXC_DEX (0x20000000) /* Synchronous exception */ 96263910Sandrew#define VFPEXC_FP2V (0x10000000) /* FPINST2 valid */ 97263910Sandrew#define VFPEXC_INV (0x00000080) /* Input exception */ 98263910Sandrew#define VFPEXC_UFC (0x00000008) /* Underflow exception */ 99263910Sandrew#define VFPEXC_OFC (0x00000004) /* Overflow exception */ 100263910Sandrew#define VFPEXC_IOC (0x00000001) /* Invlaid operation */ 101239268Sgonzo 102239268Sgonzo/* version 3 registers */ 103239268Sgonzo/* VMVFR0 */ 104239268Sgonzo#define VMVFR0_RM_OFF 28 105239268Sgonzo#define VMVFR0_RM_MASK (0xf0000000) /* VFP rounding modes */ 106239268Sgonzo 107239268Sgonzo#define VMVFR0_SV_OFF 24 108239268Sgonzo#define VMVFR0_SV_MASK (0x0f000000) /* VFP short vector supp */ 109239268Sgonzo#define VMVFR0_SR_OFF 20 110239268Sgonzo#define VMVFR0_SR (0x00f00000) /* VFP hw sqrt supp */ 111239268Sgonzo#define VMVFR0_D_OFF 16 112239268Sgonzo#define VMVFR0_D_MASK (0x000f0000) /* VFP divide supp */ 113239268Sgonzo#define VMVFR0_TE_OFF 12 114239268Sgonzo#define VMVFR0_TE_MASK (0x0000f000) /* VFP trap exception supp */ 115239268Sgonzo#define VMVFR0_DP_OFF 8 116239268Sgonzo#define VMVFR0_DP_MASK (0x00000f00) /* VFP double prec support */ 117239268Sgonzo#define VMVFR0_SP_OFF 4 118239268Sgonzo#define VMVFR0_SP_MASK (0x000000f0) /* VFP single prec support */ 119239268Sgonzo#define VMVFR0_RB_MASK (0x0000000f) /* VFP 64 bit media support */ 120239268Sgonzo 121239268Sgonzo/* VMVFR1 */ 122325810Sjhb#define VMVFR1_FMAC_OFF 28 123325810Sjhb#define VMVFR1_FMAC_MASK (0xf0000000) /* Neon FMAC support */ 124325810Sjhb#define VMVFR1_VFP_HP_OFF 24 125325810Sjhb#define VMVFR1_VFP_HP_MASK (0x0f000000) /* VFP half prec support */ 126325810Sjhb#define VMVFR1_HP_OFF 20 127325810Sjhb#define VMVFR1_HP_MASK (0x00f00000) /* Neon half prec support */ 128239268Sgonzo#define VMVFR1_SP_OFF 16 129239268Sgonzo#define VMVFR1_SP_MASK (0x000f0000) /* Neon single prec support */ 130239268Sgonzo#define VMVFR1_I_OFF 12 131239268Sgonzo#define VMVFR1_I_MASK (0x0000f000) /* Neon integer support */ 132239268Sgonzo#define VMVFR1_LS_OFF 8 133239268Sgonzo#define VMVFR1_LS_MASK (0x00000f00) /* Neon ld/st instr support */ 134239268Sgonzo#define VMVFR1_DN_OFF 4 135239268Sgonzo#define VMVFR1_DN_MASK (0x000000f0) /* Neon prop NaN support */ 136239268Sgonzo#define VMVFR1_FZ_MASK (0x0000000f) /* Neon denormal arith supp */ 137239268Sgonzo 138239268Sgonzo#define COPROC10 (0x3 << 20) 139239268Sgonzo#define COPROC11 (0x3 << 22) 140239268Sgonzo 141262941Sian#ifndef LOCORE 142317005Smmelstruct vfp_state { 143317005Smmel uint64_t reg[32]; 144317005Smmel uint32_t fpscr; 145317005Smmel uint32_t fpexec; 146317005Smmel uint32_t fpinst; 147317005Smmel uint32_t fpinst2; 148317005Smmel}; 149317005Smmel 150317005Smmel#ifdef _KERNEL 151325831Sjhbvoid get_vfpcontext(struct thread *, mcontext_vfp_t *); 152325831Sjhbvoid set_vfpcontext(struct thread *, mcontext_vfp_t *); 153247341Scognetvoid vfp_init(void); 154262941Sianvoid vfp_store(struct vfp_state *, boolean_t); 155262948Sianvoid vfp_discard(struct thread *); 156317005Smmel#endif /* _KERNEL */ 157317005Smmel#endif /* LOCORE */ 158239268Sgonzo 159239268Sgonzo#endif 160