beat_spu_priv1.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * spu hypervisor abstraction for Beat
  3. *
  4. * (C) Copyright 2006-2007 TOSHIBA CORPORATION
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #include <linux/module.h>
  21. #include <asm/types.h>
  22. #include <asm/spu.h>
  23. #include <asm/spu_priv1.h>
  24. #include "beat_wrapper.h"
  25. static inline void _int_mask_set(struct spu *spu, int class, u64 mask)
  26. {
  27. spu->shadow_int_mask_RW[class] = mask;
  28. beat_set_irq_mask_for_spe(spu->spe_id, class, mask);
  29. }
  30. static inline u64 _int_mask_get(struct spu *spu, int class)
  31. {
  32. return spu->shadow_int_mask_RW[class];
  33. }
  34. static void int_mask_set(struct spu *spu, int class, u64 mask)
  35. {
  36. _int_mask_set(spu, class, mask);
  37. }
  38. static u64 int_mask_get(struct spu *spu, int class)
  39. {
  40. return _int_mask_get(spu, class);
  41. }
  42. static void int_mask_and(struct spu *spu, int class, u64 mask)
  43. {
  44. u64 old_mask;
  45. old_mask = _int_mask_get(spu, class);
  46. _int_mask_set(spu, class, old_mask & mask);
  47. }
  48. static void int_mask_or(struct spu *spu, int class, u64 mask)
  49. {
  50. u64 old_mask;
  51. old_mask = _int_mask_get(spu, class);
  52. _int_mask_set(spu, class, old_mask | mask);
  53. }
  54. static void int_stat_clear(struct spu *spu, int class, u64 stat)
  55. {
  56. beat_clear_interrupt_status_of_spe(spu->spe_id, class, stat);
  57. }
  58. static u64 int_stat_get(struct spu *spu, int class)
  59. {
  60. u64 int_stat;
  61. beat_get_interrupt_status_of_spe(spu->spe_id, class, &int_stat);
  62. return int_stat;
  63. }
  64. static void cpu_affinity_set(struct spu *spu, int cpu)
  65. {
  66. return;
  67. }
  68. static u64 mfc_dar_get(struct spu *spu)
  69. {
  70. u64 dar;
  71. beat_get_spe_privileged_state_1_registers(
  72. spu->spe_id,
  73. offsetof(struct spu_priv1, mfc_dar_RW), &dar);
  74. return dar;
  75. }
  76. static u64 mfc_dsisr_get(struct spu *spu)
  77. {
  78. u64 dsisr;
  79. beat_get_spe_privileged_state_1_registers(
  80. spu->spe_id,
  81. offsetof(struct spu_priv1, mfc_dsisr_RW), &dsisr);
  82. return dsisr;
  83. }
  84. static void mfc_dsisr_set(struct spu *spu, u64 dsisr)
  85. {
  86. beat_set_spe_privileged_state_1_registers(
  87. spu->spe_id,
  88. offsetof(struct spu_priv1, mfc_dsisr_RW), dsisr);
  89. }
  90. static void mfc_sdr_setup(struct spu *spu)
  91. {
  92. return;
  93. }
  94. static void mfc_sr1_set(struct spu *spu, u64 sr1)
  95. {
  96. beat_set_spe_privileged_state_1_registers(
  97. spu->spe_id,
  98. offsetof(struct spu_priv1, mfc_sr1_RW), sr1);
  99. }
  100. static u64 mfc_sr1_get(struct spu *spu)
  101. {
  102. u64 sr1;
  103. beat_get_spe_privileged_state_1_registers(
  104. spu->spe_id,
  105. offsetof(struct spu_priv1, mfc_sr1_RW), &sr1);
  106. return sr1;
  107. }
  108. static void mfc_tclass_id_set(struct spu *spu, u64 tclass_id)
  109. {
  110. beat_set_spe_privileged_state_1_registers(
  111. spu->spe_id,
  112. offsetof(struct spu_priv1, mfc_tclass_id_RW), tclass_id);
  113. }
  114. static u64 mfc_tclass_id_get(struct spu *spu)
  115. {
  116. u64 tclass_id;
  117. beat_get_spe_privileged_state_1_registers(
  118. spu->spe_id,
  119. offsetof(struct spu_priv1, mfc_tclass_id_RW), &tclass_id);
  120. return tclass_id;
  121. }
  122. static void tlb_invalidate(struct spu *spu)
  123. {
  124. beat_set_spe_privileged_state_1_registers(
  125. spu->spe_id,
  126. offsetof(struct spu_priv1, tlb_invalidate_entry_W), 0ul);
  127. }
  128. static void resource_allocation_groupID_set(struct spu *spu, u64 id)
  129. {
  130. beat_set_spe_privileged_state_1_registers(
  131. spu->spe_id,
  132. offsetof(struct spu_priv1, resource_allocation_groupID_RW),
  133. id);
  134. }
  135. static u64 resource_allocation_groupID_get(struct spu *spu)
  136. {
  137. u64 id;
  138. beat_get_spe_privileged_state_1_registers(
  139. spu->spe_id,
  140. offsetof(struct spu_priv1, resource_allocation_groupID_RW),
  141. &id);
  142. return id;
  143. }
  144. static void resource_allocation_enable_set(struct spu *spu, u64 enable)
  145. {
  146. beat_set_spe_privileged_state_1_registers(
  147. spu->spe_id,
  148. offsetof(struct spu_priv1, resource_allocation_enable_RW),
  149. enable);
  150. }
  151. static u64 resource_allocation_enable_get(struct spu *spu)
  152. {
  153. u64 enable;
  154. beat_get_spe_privileged_state_1_registers(
  155. spu->spe_id,
  156. offsetof(struct spu_priv1, resource_allocation_enable_RW),
  157. &enable);
  158. return enable;
  159. }
  160. const struct spu_priv1_ops spu_priv1_beat_ops = {
  161. .int_mask_and = int_mask_and,
  162. .int_mask_or = int_mask_or,
  163. .int_mask_set = int_mask_set,
  164. .int_mask_get = int_mask_get,
  165. .int_stat_clear = int_stat_clear,
  166. .int_stat_get = int_stat_get,
  167. .cpu_affinity_set = cpu_affinity_set,
  168. .mfc_dar_get = mfc_dar_get,
  169. .mfc_dsisr_get = mfc_dsisr_get,
  170. .mfc_dsisr_set = mfc_dsisr_set,
  171. .mfc_sdr_setup = mfc_sdr_setup,
  172. .mfc_sr1_set = mfc_sr1_set,
  173. .mfc_sr1_get = mfc_sr1_get,
  174. .mfc_tclass_id_set = mfc_tclass_id_set,
  175. .mfc_tclass_id_get = mfc_tclass_id_get,
  176. .tlb_invalidate = tlb_invalidate,
  177. .resource_allocation_groupID_set = resource_allocation_groupID_set,
  178. .resource_allocation_groupID_get = resource_allocation_groupID_get,
  179. .resource_allocation_enable_set = resource_allocation_enable_set,
  180. .resource_allocation_enable_get = resource_allocation_enable_get,
  181. };