memoryOperation.c 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * linux/arch/arm/vfp/vfpdouble.c
  3. *
  4. * This code is derived in part from John R. Housers softfloat library, which
  5. * carries the following notice:
  6. *
  7. * ===========================================================================
  8. * This C source file is part of the SoftFloat IEC/IEEE Floating-point
  9. * Arithmetic Package, Release 2.
  10. *
  11. * Written by John R. Hauser. This work was made possible in part by the
  12. * International Computer Science Institute, located at Suite 600, 1947 Center
  13. * Street, Berkeley, California 94704. Funding was partially provided by the
  14. * National Science Foundation under grant MIP-9311980. The original version
  15. * of this code was written as part of a project to build a fixed-point vector
  16. * processor in collaboration with the University of California at Berkeley,
  17. * overseen by Profs. Nelson Morgan and John Wawrzynek. More information
  18. * is available through the web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
  19. * arithmetic/softfloat.html'.
  20. *
  21. * THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
  22. * has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
  23. * TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
  24. * PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
  25. * AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
  26. *
  27. * Derivative works are acceptable, even for commercial purposes, so long as
  28. * (1) they include prominent notice that the work is derivative, and (2) they
  29. * include prominent notice akin to these three paragraphs for those parts of
  30. * this code that are retained.
  31. * ===========================================================================
  32. */
  33. #include <linux/kernel.h>
  34. #include <linux/bitops.h>
  35. #include <asm/div64.h>
  36. #include <asm/vfp.h>
  37. #include "vfpinstr.h"
  38. #include "vfp.h"
  39. static struct vfp_double vfp_double_default_qnan = {
  40. .exponent = 2047,
  41. .sign = 0,
  42. .significand = VFP_DOUBLE_SIGNIFICAND_QNAN,
  43. };
  44. static void vfp_double_dump(const char *str, struct vfp_double *d)
  45. {
  46. pr_debug("VFP: %s: sign=%d exponent=%d significand=%016llx\n",
  47. str, d->sign != 0, d->exponent, d->significand);
  48. }
  49. static void vfp_double_normalise_denormal(struct vfp_double *vd)
  50. {
  51. int bits = 31 - fls(vd->significand >> 32);
  52. if (bits == 31)
  53. bits = 63 - fls(vd->significand);
  54. vfp_double_dump("normalise_denormal: in", vd);
  55. if (bits) {
  56. vd->exponent -= bits - 1;
  57. vd->significand <<= bits;
  58. }
  59. vfp_double_dump("normalise_denormal: out", vd);
  60. }
  61. u32 vfp_double_normaliseround(int dd, struct vfp_double *vd, u32 fpscr, u32 exceptions, const char *func)
  62. {
  63. u64 significand, incr;
  64. int exponent, shift, underflow;
  65. u32 rmode;
  66. vfp_double_dump("pack: in", vd);
  67. /*
  68. * Infinities and NaNs are a special case.
  69. */
  70. if (vd->exponent == 2047 && (vd->significand == 0 || exceptions))
  71. goto pack;
  72. /*
  73. * Special-case zero.
  74. */
  75. if (vd->significand == 0) {
  76. vd->exponent = 0;
  77. goto pack;
  78. }
  79. exponent = vd->exponent;
  80. significand = vd->significand;