fpreg.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * arch/alpha/lib/fpreg.c
  3. *
  4. * (C) Copyright 1998 Linus Torvalds
  5. */
  6. #include <linux/compiler.h>
  7. #include <linux/export.h>
  8. #if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
  9. #define STT(reg,val) asm volatile ("ftoit $f"#reg",%0" : "=r"(val));
  10. #else
  11. #define STT(reg,val) asm volatile ("stt $f"#reg",%0" : "=m"(val));
  12. #endif
  13. unsigned long
  14. alpha_read_fp_reg (unsigned long reg)
  15. {
  16. unsigned long val;
  17. switch (reg) {
  18. case 0: STT( 0, val); break;
  19. case 1: STT( 1, val); break;
  20. case 2: STT( 2, val); break;
  21. case 3: STT( 3, val); break;
  22. case 4: STT( 4, val); break;
  23. case 5: STT( 5, val); break;
  24. case 6: STT( 6, val); break;
  25. case 7: STT( 7, val); break;
  26. case 8: STT( 8, val); break;
  27. case 9: STT( 9, val); break;
  28. case 10: STT(10, val); break;
  29. case 11: STT(11, val); break;
  30. case 12: STT(12, val); break;
  31. case 13: STT(13, val); break;
  32. case 14: STT(14, val); break;
  33. case 15: STT(15, val); break;
  34. case 16: STT(16, val); break;
  35. case 17: STT(17, val); break;
  36. case 18: STT(18, val); break;
  37. case 19: STT(19, val); break;
  38. case 20: STT(20, val); break;
  39. case 21: STT(21, val); break;
  40. case 22: STT(22, val); break;
  41. case 23: STT(23, val); break;
  42. case 24: STT(24, val); break;
  43. case 25: STT(25, val); break;
  44. case 26: STT(26, val); break;
  45. case 27: STT(27, val); break;
  46. case 28: STT(28, val); break;
  47. case 29: STT(29, val); break;
  48. case 30: STT(30, val); break;
  49. case 31: STT(31, val); break;
  50. default: return 0;
  51. }
  52. return val;
  53. }
  54. EXPORT_SYMBOL(alpha_read_fp_reg);
  55. #if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
  56. #define LDT(reg,val) asm volatile ("itoft %0,$f"#reg : : "r"(val));
  57. #else
  58. #define LDT(reg,val) asm volatile ("ldt $f"#reg",%0" : : "m"(val));
  59. #endif
  60. void
  61. alpha_write_fp_reg (unsigned long reg, unsigned long val)
  62. {
  63. switch (reg) {
  64. case 0: LDT( 0, val); break;
  65. case 1: LDT( 1, val); break;
  66. case 2: LDT( 2, val); break;
  67. case 3: LDT( 3, val); break;
  68. case 4: LDT( 4, val); break;
  69. case 5: LDT( 5, val); break;
  70. case 6: LDT( 6, val); break;
  71. case 7: LDT( 7, val); break;
  72. case 8: LDT( 8, val); break;
  73. case 9: LDT( 9, val); break;
  74. case 10: LDT(10, val); break;
  75. case 11: LDT(11, val); break;
  76. case 12: LDT(12, val); break;
  77. case 13: LDT(13, val); break;
  78. case 14: LDT(14, val); break;
  79. case 15: LDT(15, val); break;
  80. case 16: LDT(16, val); break;
  81. case 17: LDT(17, val); break;
  82. case 18: LDT(18, val); break;
  83. case 19: LDT(19, val); break;
  84. case 20: LDT(20, val); break;
  85. case 21: LDT(21, val); break;
  86. case 22: LDT(22, val); break;
  87. case 23: LDT(23, val); break;
  88. case 24: LDT(24, val); break;
  89. case 25: LDT(25, val); break;
  90. case 26: LDT(26, val); break;
  91. case 27: LDT(27, val); break;
  92. case 28: LDT(28, val); break;
  93. case 29: LDT(29, val); break;
  94. case 30: LDT(30, val); break;
  95. case 31: LDT(31, val); break;
  96. }
  97. }
  98. EXPORT_SYMBOL(alpha_write_fp_reg);
  99. #if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
  100. #define STS(reg,val) asm volatile ("ftois $f"#reg",%0" : "=r"(val));
  101. #else
  102. #define STS(reg,val) asm volatile ("sts $f"#reg",%0" : "=m"(val));
  103. #endif
  104. unsigned long
  105. alpha_read_fp_reg_s (unsigned long reg)
  106. {
  107. unsigned long val;
  108. switch (reg) {
  109. case 0: STS( 0, val); break;
  110. case 1: STS( 1, val); break;
  111. case 2: STS( 2, val); break;
  112. case 3: STS( 3, val); break;
  113. case 4: STS( 4, val); break;
  114. case 5: STS( 5, val); break;
  115. case 6: STS( 6, val); break;
  116. case 7: STS( 7, val); break;
  117. case 8: STS( 8, val); break;
  118. case 9: STS( 9, val); break;
  119. case 10: STS(10, val); break;
  120. case 11: STS(11, val); break;
  121. case 12: STS(12, val); break;
  122. case 13: STS(13, val); break;
  123. case 14: STS(14, val); break;
  124. case 15: STS(15, val); break;
  125. case 16: STS(16, val); break;
  126. case 17: STS(17, val); break;
  127. case 18: STS(18, val); break;
  128. case 19: STS(19, val); break;
  129. case 20: STS(20, val); break;
  130. case 21: STS(21, val); break;
  131. case 22: STS(22, val); break;
  132. case 23: STS(23, val); break;
  133. case 24: STS(24, val); break;
  134. case 25: STS(25, val); break;
  135. case 26: STS(26, val); break;
  136. case 27: STS(27, val); break;
  137. case 28: STS(28, val); break;
  138. case 29: STS(29, val); break;
  139. case 30: STS(30, val); break;
  140. case 31: STS(31, val); break;
  141. default: return 0;
  142. }
  143. return val;
  144. }
  145. EXPORT_SYMBOL(alpha_read_fp_reg_s);
  146. #if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
  147. #define LDS(reg,val) asm volatile ("itofs %0,$f"#reg : : "r"(val));
  148. #else
  149. #define LDS(reg,val) asm volatile ("lds $f"#reg",%0" : : "m"(val));
  150. #endif
  151. void
  152. alpha_write_fp_reg_s (unsigned long reg, unsigned long val)
  153. {
  154. switch (reg) {
  155. case 0: LDS( 0, val); break;
  156. case 1: LDS( 1, val); break;
  157. case 2: LDS( 2, val); break;
  158. case 3: LDS( 3, val); break;
  159. case 4: LDS( 4, val); break;
  160. case 5: LDS( 5, val); break;
  161. case 6: LDS( 6, val); break;
  162. case 7: LDS( 7, val); break;
  163. case 8: LDS( 8, val); break;
  164. case 9: LDS( 9, val); break;
  165. case 10: LDS(10, val); break;
  166. case 11: LDS(11, val); break;
  167. case 12: LDS(12, val); break;
  168. case 13: LDS(13, val); break;
  169. case 14: LDS(14, val); break;
  170. case 15: LDS(15, val); break;
  171. case 16: LDS(16, val); break;
  172. case 17: LDS(17, val); break;
  173. case 18: LDS(18, val); break;
  174. case 19: LDS(19, val); break;
  175. case 20: LDS(20, val); break;
  176. case 21: LDS(21, val); break;
  177. case 22: LDS(22, val); break;
  178. case 23: LDS(23, val); break;
  179. case 24: LDS(24, val); break;
  180. case 25: LDS(25, val); break;
  181. case 26: LDS(26, val); break;
  182. case 27: LDS(27, val); break;
  183. case 28: LDS(28, val); break;
  184. case 29: LDS(29, val); break;
  185. case 30: LDS(30, val); break;
  186. case 31: LDS(31, val); break;
  187. }
  188. }
  189. EXPORT_SYMBOL(alpha_write_fp_reg_s);