beat_spu_priv1.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 <asm/types.h>
  21. #include <asm/spu.h>
  22. #include <asm/spu_priv1.h>
  23. #include "beat_wrapper.h"
  24. static inline void _int_mask_set(struct spu *spu, int class, u64 mask)
  25. {
  26. spu->shadow_int_mask_RW[class] = mask;
  27. beat_set_irq_mask_for_spe(spu->spe_id, class, mask);
  28. }
  29. static inline u64 _int_mask_get(struct spu *spu, int class)
  30. {
  31. return spu->shadow_int_mask_RW[class];
  32. }
  33. static void int_mask_set(struct spu *spu, int class, u64 mask)
  34. {
  35. _int_mask_set(spu, class, mask);
  36. }
  37. static u64 int_mask_get(struct spu *spu, int class)
  38. {
  39. return _int_mask_get(spu, class);
  40. }
  41. static void int_mask_and(struct spu *spu, int class, u64 mask)
  42. {
  43. u64 old_mask;
  44. old_mask = _int_mask_get(spu, class);
  45. _int_mask_set(spu, class, old_mask & mask);
  46. }
  47. static void int_mask_or(struct spu *spu, int class, u64 mask)
  48. {
  49. u64 old_mask;
  50. old_mask = _int_mask_get(spu, class);
  51. _int_mask_set(spu, class, old_mask | mask);
  52. }
  53. static void int_stat_clear(struct spu *spu, int class, u64 stat)
  54. {
  55. beat_clear_interrupt_status_of_spe(spu->spe_id, class, stat);
  56. }
  57. static u64 int_stat_get(struct spu *spu, int class)
  58. {
  59. u64 int_stat;
  60. beat_get_interrupt_status_of_spe(spu->spe_id, class, &int_stat);
  61. return int_stat;
  62. }
  63. static void cpu_affinity_set(struct spu *spu, int cpu)
  64. {
  65. return;
  66. }
  67. static u64 mfc_dar_get(struct spu *spu)
  68. {
  69. u64 dar;
  70. beat_get_spe_privileged_state_1_registers(
  71. spu->spe_id,
  72. offsetof(struct spu_priv1, mfc_dar_RW), &dar);
  73. return dar;
  74. }
  75. static u64 mfc_dsisr_get(struct spu *spu)
  76. {
  77. u64 dsisr;
  78. beat_get_spe_privileged_state_1_registers(
  79. spu->spe_id,
  80. offsetof(struct spu_priv1, mfc_dsisr_RW), &dsisr);
  81. return dsisr;
  82. }
  83. static void mfc_dsisr_set(struct spu *spu, u64 dsisr)
  84. {
  85. beat_set_spe_privileged_state_1_registers(
  86. spu->spe_id,
  87. offsetof(struct spu_priv1, mfc_dsisr_RW), dsisr);
  88. }
  89. static void mfc_sdr_setup(struct spu *spu)
  90. {
  91. return;
  92. }
  93. static void mfc_sr1_set(struct spu *spu, u64 sr1)
  94. {
  95. beat_set_spe_privileged_state_1_registers(
  96. spu->spe_id,
  97. offsetof(struct spu_priv1, mfc_sr1_RW), sr1);
  98. }
  99. static u64 mfc_sr1_get(struct spu *spu)
  100. {
  101. u64 sr1;
  102. beat_get_spe_privileged_state_1_registers(
  103. spu->spe_id,
  104. offsetof(struct spu_priv1, mfc_sr1_RW), &sr1);
  105. return sr1;
  106. }
  107. static void mfc_tclass_id_set(struct spu *spu, u64 tclass_id)
  108. {
  109. beat_set_spe_privileged_state_1_registers(
  110. spu->spe_id,
  111. offsetof(struct spu_priv1, mfc_tclass_id_RW), tclass_id);
  112. }
  113. static u64 mfc_tclass_id_get(struct spu *spu)
  114. {
  115. u64 tclass_id;
  116. beat_get_spe_privileged_state_1_registers(
  117. spu->spe_id,
  118. offsetof(struct spu_priv1, mfc_tclass_id_RW), &tclass_id);
  119. return tclass_id;
  120. }
  121. static void tlb_invalidate(struct spu *spu)
  122. {
  123. beat_set_spe_privileged_state_1_registers(
  124. spu->spe_id,
  125. offsetof(struct spu_priv1, tlb_invalidate_entry_W), 0ul);
  126. }
  127. static void resource_allocation_groupID_set(struct spu *spu, u64 id)
  128. {
  129. beat_set_spe_privileged_state_1_registers(
  130. spu->spe_id,
  131. offsetof(struct spu_priv1, resource_allocation_groupID_RW),
  132. id);
  133. }
  134. static u64 resource_allocation_groupID_get(struct spu *spu)
  135. {
  136. u64 id;
  137. beat_get_spe_privileged_state_1_registers(
  138. spu->spe_id,
  139. offsetof(struct spu_priv1, resource_allocation_groupID_RW),
  140. &id);
  141. return id;
  142. }
  143. static void resource_allocation_enable_set(struct spu *spu, u64 enable)
  144. {
  145. beat_set_spe_privileged_state_1_registers(
  146. spu->spe_id,
  147. offsetof(struct spu_priv1, resource_allocation_enable_RW),
  148. enable);
  149. }
  150. static u64 resource_allocation_enable_get(struct spu *spu)
  151. {
  152. u64 enable;
  153. beat_get_spe_privileged_state_1_registers(
  154. spu->spe_id,
  155. offsetof(struct spu_priv1, resource_allocation_enable_RW),
  156. &enable);
  157. return enable;
  158. }
  159. const struct spu_priv1_ops spu_priv1_beat_ops = {
  160. .int_mask_and = int_mask_and,
  161. .int_mask_or = int_mask_or,
  162. .int_mask_set = int_mask_set,
  163. .int_mask_get = int_mask_get,
  164. .int_stat_clear = int_stat_clear,
  165. .int_stat_get = int_stat_get,
  166. .cpu_affinity_set = cpu_affinity_set,
  167. .mfc_dar_get = mfc_dar_get,
  168. .mfc_dsisr_get = mfc_dsisr_get,
  169. .mfc_dsisr_set = mfc_dsisr_set,
  170. .mfc_sdr_setup = mfc_sdr_setup,
  171. .mfc_sr1_set = mfc_sr1_set,
  172. .mfc_sr1_get = mfc_sr1_get,
  173. .mfc_tclass_id_set = mfc_tclass_id_set,
  174. .mfc_tclass_id_get = mfc_tclass_id_get,
  175. .tlb_invalidate = tlb_invalidate,
  176. .resource_allocation_groupID_set = resource_allocation_groupID_set,
  177. .resource_allocation_groupID_get = resource_allocation_groupID_get,
  178. .resource_allocation_enable_set = resource_allocation_enable_set,
  179. .resource_allocation_enable_get = resource_allocation_enable_get,
  180. };