spu_priv1.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * Defines an spu hypervisor abstraction layer.
  3. *
  4. * Copyright 2006 Sony Corp.
  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; version 2 of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #if !defined(_SPU_PRIV1_H)
  20. #define _SPU_PRIV1_H
  21. #if defined(__KERNEL__)
  22. #include <linux/types.h>
  23. struct spu;
  24. struct spu_context;
  25. /* access to priv1 registers */
  26. struct spu_priv1_ops {
  27. void (*int_mask_and) (struct spu *spu, int class, u64 mask);
  28. void (*int_mask_or) (struct spu *spu, int class, u64 mask);
  29. void (*int_mask_set) (struct spu *spu, int class, u64 mask);
  30. u64 (*int_mask_get) (struct spu *spu, int class);
  31. void (*int_stat_clear) (struct spu *spu, int class, u64 stat);
  32. u64 (*int_stat_get) (struct spu *spu, int class);
  33. void (*cpu_affinity_set) (struct spu *spu, int cpu);
  34. u64 (*mfc_dar_get) (struct spu *spu);
  35. u64 (*mfc_dsisr_get) (struct spu *spu);
  36. void (*mfc_dsisr_set) (struct spu *spu, u64 dsisr);
  37. void (*mfc_sdr_setup) (struct spu *spu);
  38. void (*mfc_sr1_set) (struct spu *spu, u64 sr1);
  39. u64 (*mfc_sr1_get) (struct spu *spu);
  40. void (*mfc_tclass_id_set) (struct spu *spu, u64 tclass_id);
  41. u64 (*mfc_tclass_id_get) (struct spu *spu);
  42. void (*tlb_invalidate) (struct spu *spu);
  43. void (*resource_allocation_groupID_set) (struct spu *spu, u64 id);
  44. u64 (*resource_allocation_groupID_get) (struct spu *spu);
  45. void (*resource_allocation_enable_set) (struct spu *spu, u64 enable);
  46. u64 (*resource_allocation_enable_get) (struct spu *spu);
  47. };
  48. extern const struct spu_priv1_ops* spu_priv1_ops;
  49. static inline void
  50. spu_int_mask_and (struct spu *spu, int class, u64 mask)
  51. {
  52. spu_priv1_ops->int_mask_and(spu, class, mask);
  53. }
  54. static inline void
  55. spu_int_mask_or (struct spu *spu, int class, u64 mask)
  56. {
  57. spu_priv1_ops->int_mask_or(spu, class, mask);
  58. }
  59. static inline void
  60. spu_int_mask_set (struct spu *spu, int class, u64 mask)
  61. {
  62. spu_priv1_ops->int_mask_set(spu, class, mask);
  63. }
  64. static inline u64
  65. spu_int_mask_get (struct spu *spu, int class)
  66. {
  67. return spu_priv1_ops->int_mask_get(spu, class);
  68. }
  69. static inline void
  70. spu_int_stat_clear (struct spu *spu, int class, u64 stat)
  71. {
  72. spu_priv1_ops->int_stat_clear(spu, class, stat);
  73. }
  74. static inline u64
  75. spu_int_stat_get (struct spu *spu, int class)
  76. {
  77. return spu_priv1_ops->int_stat_get (spu, class);
  78. }
  79. static inline void
  80. spu_cpu_affinity_set (struct spu *spu, int cpu)
  81. {
  82. spu_priv1_ops->cpu_affinity_set(spu, cpu);
  83. }
  84. static inline u64
  85. spu_mfc_dar_get (struct spu *spu)
  86. {
  87. return spu_priv1_ops->mfc_dar_get(spu);
  88. }
  89. static inline u64
  90. spu_mfc_dsisr_get (struct spu *spu)
  91. {
  92. return spu_priv1_ops->mfc_dsisr_get(spu);
  93. }
  94. static inline void
  95. spu_mfc_dsisr_set (struct spu *spu, u64 dsisr)
  96. {
  97. spu_priv1_ops->mfc_dsisr_set(spu, dsisr);
  98. }
  99. static inline void
  100. spu_mfc_sdr_setup (struct spu *spu)
  101. {
  102. spu_priv1_ops->mfc_sdr_setup(spu);
  103. }
  104. static inline void
  105. spu_mfc_sr1_set (struct spu *spu, u64 sr1)
  106. {
  107. spu_priv1_ops->mfc_sr1_set(spu, sr1);
  108. }
  109. static inline u64
  110. spu_mfc_sr1_get (struct spu *spu)
  111. {
  112. return spu_priv1_ops->mfc_sr1_get(spu);
  113. }
  114. static inline void
  115. spu_mfc_tclass_id_set (struct spu *spu, u64 tclass_id)
  116. {
  117. spu_priv1_ops->mfc_tclass_id_set(spu, tclass_id);
  118. }
  119. static inline u64
  120. spu_mfc_tclass_id_get (struct spu *spu)
  121. {
  122. return spu_priv1_ops->mfc_tclass_id_get(spu);
  123. }
  124. static inline void
  125. spu_tlb_invalidate (struct spu *spu)
  126. {
  127. spu_priv1_ops->tlb_invalidate(spu);
  128. }
  129. static inline void
  130. spu_resource_allocation_groupID_set (struct spu *spu, u64 id)
  131. {
  132. spu_priv1_ops->resource_allocation_groupID_set(spu, id);
  133. }
  134. static inline u64
  135. spu_resource_allocation_groupID_get (struct spu *spu)
  136. {
  137. return spu_priv1_ops->resource_allocation_groupID_get(spu);
  138. }
  139. static inline void
  140. spu_resource_allocation_enable_set (struct spu *spu, u64 enable)
  141. {
  142. spu_priv1_ops->resource_allocation_enable_set(spu, enable);
  143. }
  144. static inline u64
  145. spu_resource_allocation_enable_get (struct spu *spu)
  146. {
  147. return spu_priv1_ops->resource_allocation_enable_get(spu);
  148. }
  149. /* spu management abstraction */
  150. struct spu_management_ops {
  151. int (*enumerate_spus)(int (*fn)(void *data));
  152. int (*create_spu)(struct spu *spu, void *data);
  153. int (*destroy_spu)(struct spu *spu);
  154. void (*enable_spu)(struct spu_context *ctx);
  155. void (*disable_spu)(struct spu_context *ctx);
  156. int (*init_affinity)(void);
  157. };
  158. extern const struct spu_management_ops* spu_management_ops;
  159. static inline int
  160. spu_enumerate_spus (int (*fn)(void *data))
  161. {
  162. return spu_management_ops->enumerate_spus(fn);
  163. }
  164. static inline int
  165. spu_create_spu (struct spu *spu, void *data)
  166. {
  167. return spu_management_ops->create_spu(spu, data);
  168. }
  169. static inline int
  170. spu_destroy_spu (struct spu *spu)
  171. {
  172. return spu_management_ops->destroy_spu(spu);
  173. }
  174. static inline int
  175. spu_init_affinity (void)
  176. {
  177. return spu_management_ops->init_affinity();
  178. }
  179. static inline void
  180. spu_enable_spu (struct spu_context *ctx)
  181. {
  182. spu_management_ops->enable_spu(ctx);
  183. }
  184. static inline void
  185. spu_disable_spu (struct spu_context *ctx)
  186. {
  187. spu_management_ops->disable_spu(ctx);
  188. }
  189. /*
  190. * The declarations following are put here for convenience
  191. * and only intended to be used by the platform setup code.
  192. */
  193. extern const struct spu_priv1_ops spu_priv1_mmio_ops;
  194. extern const struct spu_priv1_ops spu_priv1_beat_ops;
  195. extern const struct spu_management_ops spu_management_of_ops;
  196. #endif /* __KERNEL__ */
  197. #endif