vfp.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. vfp/vfp.h - ARM VFPv3 emulation unit - vfp interface
  3. Copyright (C) 2003 Skyeye Develop Group
  4. for help please send mail to <skyeye-developer@lists.gro.clinux.org>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #ifndef __VFP_H__
  18. #define __VFP_H__
  19. #include "core/arm/skyeye_common/vfp/vfp_helper.h" /* for references to cdp SoftFloat functions */
  20. #define VFP_DEBUG_UNIMPLEMENTED(x) LOG_ERROR(Core_ARM11, "in func %s, " #x " unimplemented\n", __FUNCTION__); exit(-1);
  21. #define VFP_DEBUG_UNTESTED(x) LOG_TRACE(Core_ARM11, "in func %s, " #x " untested\n", __FUNCTION__);
  22. #define CHECK_VFP_ENABLED
  23. #define CHECK_VFP_CDP_RET vfp_raise_exceptions(cpu, ret, inst_cream->instr, cpu->VFP[VFP_OFFSET(VFP_FPSCR)]); //if (ret == -1) {printf("VFP CDP FAILURE %x\n", inst_cream->instr); exit(-1);}
  24. unsigned VFPInit (ARMul_State *state);
  25. unsigned VFPMRC (ARMul_State * state, unsigned type, ARMword instr, ARMword * value);
  26. unsigned VFPMCR (ARMul_State * state, unsigned type, ARMword instr, ARMword value);
  27. unsigned VFPMRRC (ARMul_State * state, unsigned type, ARMword instr, ARMword * value1, ARMword * value2);
  28. unsigned VFPMCRR (ARMul_State * state, unsigned type, ARMword instr, ARMword value1, ARMword value2);
  29. unsigned VFPSTC (ARMul_State * state, unsigned type, ARMword instr, ARMword * value);
  30. unsigned VFPLDC (ARMul_State * state, unsigned type, ARMword instr, ARMword value);
  31. unsigned VFPCDP (ARMul_State * state, unsigned type, ARMword instr);
  32. /* FPSID Information */
  33. #define VFP_FPSID_IMPLMEN 0 /* should be the same as cp15 0 c0 0*/
  34. #define VFP_FPSID_SW 0
  35. #define VFP_FPSID_SUBARCH 0x2 /* VFP version. Current is v3 (not strict) */
  36. #define VFP_FPSID_PARTNUM 0x1
  37. #define VFP_FPSID_VARIANT 0x1
  38. #define VFP_FPSID_REVISION 0x1
  39. /* FPEXC Flags */
  40. #define VFP_FPEXC_EX 1<<31
  41. #define VFP_FPEXC_EN 1<<30
  42. /* FPSCR Flags */
  43. #define VFP_FPSCR_NFLAG 1<<31
  44. #define VFP_FPSCR_ZFLAG 1<<30
  45. #define VFP_FPSCR_CFLAG 1<<29
  46. #define VFP_FPSCR_VFLAG 1<<28
  47. #define VFP_FPSCR_AHP 1<<26 /* Alternative Half Precision */
  48. #define VFP_FPSCR_DN 1<<25 /* Default NaN */
  49. #define VFP_FPSCR_FZ 1<<24 /* Flush-to-zero */
  50. #define VFP_FPSCR_RMODE 3<<22 /* Rounding Mode */
  51. #define VFP_FPSCR_STRIDE 3<<20 /* Stride (vector) */
  52. #define VFP_FPSCR_LEN 7<<16 /* Stride (vector) */
  53. #define VFP_FPSCR_IDE 1<<15 /* Input Denormal exc */
  54. #define VFP_FPSCR_IXE 1<<12 /* Inexact exc */
  55. #define VFP_FPSCR_UFE 1<<11 /* Undeflow exc */
  56. #define VFP_FPSCR_OFE 1<<10 /* Overflow exc */
  57. #define VFP_FPSCR_DZE 1<<9 /* Division by Zero exc */
  58. #define VFP_FPSCR_IOE 1<<8 /* Invalid Operation exc */
  59. #define VFP_FPSCR_IDC 1<<7 /* Input Denormal cum exc */
  60. #define VFP_FPSCR_IXC 1<<4 /* Inexact cum exc */
  61. #define VFP_FPSCR_UFC 1<<3 /* Undeflow cum exc */
  62. #define VFP_FPSCR_OFC 1<<2 /* Overflow cum exc */
  63. #define VFP_FPSCR_DZC 1<<1 /* Division by Zero cum exc */
  64. #define VFP_FPSCR_IOC 1<<0 /* Invalid Operation cum exc */
  65. /* Inline instructions. Note: Used in a cpp file as well */
  66. #ifdef __cplusplus
  67. extern "C" {
  68. #endif
  69. int32_t vfp_get_float(ARMul_State * state, unsigned int reg);
  70. void vfp_put_float(ARMul_State * state, int32_t val, unsigned int reg);
  71. uint64_t vfp_get_double(ARMul_State * state, unsigned int reg);
  72. void vfp_put_double(ARMul_State * state, uint64_t val, unsigned int reg);
  73. void vfp_raise_exceptions(ARMul_State * state, uint32_t exceptions, uint32_t inst, uint32_t fpscr);
  74. u32 vfp_single_cpdo(ARMul_State* state, u32 inst, u32 fpscr);
  75. u32 vfp_double_cpdo(ARMul_State* state, u32 inst, u32 fpscr);
  76. /* MRC */
  77. void VMRS(ARMul_State * state, ARMword reg, ARMword Rt, ARMword *value);
  78. void VMOVBRS(ARMul_State * state, ARMword to_arm, ARMword t, ARMword n, ARMword *value);
  79. void VMOVBRRD(ARMul_State * state, ARMword to_arm, ARMword t, ARMword t2, ARMword n, ARMword *value1, ARMword *value2);
  80. void VMOVBRRSS(ARMul_State* state, ARMword to_arm, ARMword t, ARMword t2, ARMword n, ARMword* value1, ARMword* value2);
  81. void VMOVI(ARMul_State * state, ARMword single, ARMword d, ARMword imm);
  82. void VMOVR(ARMul_State * state, ARMword single, ARMword d, ARMword imm);
  83. /* MCR */
  84. void VMSR(ARMul_State * state, ARMword reg, ARMword Rt);
  85. /* STC */
  86. int VSTM(ARMul_State * state, int type, ARMword instr, ARMword* value);
  87. int VPUSH(ARMul_State * state, int type, ARMword instr, ARMword* value);
  88. int VSTR(ARMul_State * state, int type, ARMword instr, ARMword* value);
  89. /* LDC */
  90. int VLDM(ARMul_State * state, int type, ARMword instr, ARMword value);
  91. int VPOP(ARMul_State * state, int type, ARMword instr, ARMword value);
  92. int VLDR(ARMul_State * state, int type, ARMword instr, ARMword value);
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. #endif