spu_csa.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /*
  2. * spu_csa.h: Definitions for SPU context save area (CSA).
  3. *
  4. * (C) Copyright IBM 2005
  5. *
  6. * Author: Mark Nutter <mnutter@us.ibm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2, or (at your option)
  11. * any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #ifndef _SPU_CSA_H_
  23. #define _SPU_CSA_H_
  24. #ifdef __KERNEL__
  25. /*
  26. * Total number of 128-bit registers.
  27. */
  28. #define NR_SPU_GPRS 128
  29. #define NR_SPU_SPRS 9
  30. #define NR_SPU_REGS_PAD 7
  31. #define NR_SPU_SPILL_REGS 144 /* GPRS + SPRS + PAD */
  32. #define SIZEOF_SPU_SPILL_REGS NR_SPU_SPILL_REGS * 16
  33. #define SPU_SAVE_COMPLETE 0x3FFB
  34. #define SPU_RESTORE_COMPLETE 0x3FFC
  35. /*
  36. * Definitions for various 'stopped' status conditions,
  37. * to be recreated during context restore.
  38. */
  39. #define SPU_STOPPED_STATUS_P 1
  40. #define SPU_STOPPED_STATUS_I 2
  41. #define SPU_STOPPED_STATUS_H 3
  42. #define SPU_STOPPED_STATUS_S 4
  43. #define SPU_STOPPED_STATUS_S_I 5
  44. #define SPU_STOPPED_STATUS_S_P 6
  45. #define SPU_STOPPED_STATUS_P_H 7
  46. #define SPU_STOPPED_STATUS_P_I 8
  47. #define SPU_STOPPED_STATUS_R 9
  48. #ifndef __ASSEMBLY__
  49. /**
  50. * spu_reg128 - generic 128-bit register definition.
  51. */
  52. struct spu_reg128 {
  53. u32 slot[4];
  54. };
  55. /**
  56. * struct spu_lscsa - Local Store Context Save Area.
  57. * @gprs: Array of saved registers.
  58. * @fpcr: Saved floating point status control register.
  59. * @decr: Saved decrementer value.
  60. * @decr_status: Indicates decrementer run status.
  61. * @ppu_mb: Saved PPU mailbox data.
  62. * @ppuint_mb: Saved PPU interrupting mailbox data.
  63. * @tag_mask: Saved tag group mask.
  64. * @event_mask: Saved event mask.
  65. * @srr0: Saved SRR0.
  66. * @stopped_status: Conditions to be recreated by restore.
  67. * @ls: Saved contents of Local Storage Area.
  68. *
  69. * The LSCSA represents state that is primarily saved and
  70. * restored by SPU-side code.
  71. */
  72. struct spu_lscsa {
  73. struct spu_reg128 gprs[128];
  74. struct spu_reg128 fpcr;
  75. struct spu_reg128 decr;
  76. struct spu_reg128 decr_status;
  77. struct spu_reg128 ppu_mb;
  78. struct spu_reg128 ppuint_mb;
  79. struct spu_reg128 tag_mask;
  80. struct spu_reg128 event_mask;
  81. struct spu_reg128 srr0;
  82. struct spu_reg128 stopped_status;
  83. /*
  84. * 'ls' must be page-aligned on all configurations.
  85. * Since we don't want to rely on having the spu-gcc
  86. * installed to build the kernel and this structure
  87. * is used in the SPU-side code, make it 64k-page
  88. * aligned for now.
  89. */
  90. unsigned char ls[LS_SIZE] __attribute__((aligned(65536)));
  91. };
  92. #ifndef __SPU__
  93. /*
  94. * struct spu_problem_collapsed - condensed problem state area, w/o pads.
  95. */
  96. struct spu_problem_collapsed {
  97. u64 spc_mssync_RW;
  98. u32 mfc_lsa_W;
  99. u32 unused_pad0;
  100. u64 mfc_ea_W;
  101. union mfc_tag_size_class_cmd mfc_union_W;
  102. u32 dma_qstatus_R;
  103. u32 dma_querytype_RW;
  104. u32 dma_querymask_RW;
  105. u32 dma_tagstatus_R;
  106. u32 pu_mb_R;
  107. u32 spu_mb_W;
  108. u32 mb_stat_R;
  109. u32 spu_runcntl_RW;
  110. u32 spu_status_R;
  111. u32 spu_spc_R;
  112. u32 spu_npc_RW;
  113. u32 signal_notify1;
  114. u32 signal_notify2;
  115. u32 unused_pad1;
  116. };
  117. /*
  118. * struct spu_priv1_collapsed - condensed privileged 1 area, w/o pads.
  119. */
  120. struct spu_priv1_collapsed {
  121. u64 mfc_sr1_RW;
  122. u64 mfc_lpid_RW;
  123. u64 spu_idr_RW;
  124. u64 mfc_vr_RO;
  125. u64 spu_vr_RO;
  126. u64 int_mask_class0_RW;
  127. u64 int_mask_class1_RW;
  128. u64 int_mask_class2_RW;
  129. u64 int_stat_class0_RW;
  130. u64 int_stat_class1_RW;
  131. u64 int_stat_class2_RW;
  132. u64 int_route_RW;
  133. u64 mfc_atomic_flush_RW;
  134. u64 resource_allocation_groupID_RW;
  135. u64 resource_allocation_enable_RW;
  136. u64 mfc_fir_R;
  137. u64 mfc_fir_status_or_W;
  138. u64 mfc_fir_status_and_W;
  139. u64 mfc_fir_mask_R;
  140. u64 mfc_fir_mask_or_W;
  141. u64 mfc_fir_mask_and_W;
  142. u64 mfc_fir_chkstp_enable_RW;
  143. u64 smf_sbi_signal_sel;
  144. u64 smf_ato_signal_sel;
  145. u64 mfc_sdr_RW;
  146. u64 tlb_index_hint_RO;
  147. u64 tlb_index_W;
  148. u64 tlb_vpn_RW;
  149. u64 tlb_rpn_RW;
  150. u64 tlb_invalidate_entry_W;
  151. u64 tlb_invalidate_all_W;
  152. u64 smm_hid;
  153. u64 mfc_accr_RW;
  154. u64 mfc_dsisr_RW;
  155. u64 mfc_dar_RW;
  156. u64 rmt_index_RW;
  157. u64 rmt_data1_RW;
  158. u64 mfc_dsir_R;
  159. u64 mfc_lsacr_RW;
  160. u64 mfc_lscrr_R;
  161. u64 mfc_tclass_id_RW;
  162. u64 mfc_rm_boundary;
  163. u64 smf_dma_signal_sel;
  164. u64 smm_signal_sel;
  165. u64 mfc_cer_R;
  166. u64 pu_ecc_cntl_RW;
  167. u64 pu_ecc_stat_RW;
  168. u64 spu_ecc_addr_RW;
  169. u64 spu_err_mask_RW;
  170. u64 spu_trig0_sel;
  171. u64 spu_trig1_sel;
  172. u64 spu_trig2_sel;
  173. u64 spu_trig3_sel;
  174. u64 spu_trace_sel;
  175. u64 spu_event0_sel;
  176. u64 spu_event1_sel;
  177. u64 spu_event2_sel;
  178. u64 spu_event3_sel;
  179. u64 spu_trace_cntl;
  180. };
  181. /*
  182. * struct spu_priv2_collapsed - condensed priviliged 2 area, w/o pads.
  183. */
  184. struct spu_priv2_collapsed {
  185. u64 slb_index_W;
  186. u64 slb_esid_RW;
  187. u64 slb_vsid_RW;
  188. u64 slb_invalidate_entry_W;
  189. u64 slb_invalidate_all_W;
  190. struct mfc_cq_sr spuq[16];
  191. struct mfc_cq_sr puq[8];
  192. u64 mfc_control_RW;
  193. u64 puint_mb_R;
  194. u64 spu_privcntl_RW;
  195. u64 spu_lslr_RW;
  196. u64 spu_chnlcntptr_RW;
  197. u64 spu_chnlcnt_RW;
  198. u64 spu_chnldata_RW;
  199. u64 spu_cfg_RW;
  200. u64 spu_tag_status_query_RW;
  201. u64 spu_cmd_buf1_RW;
  202. u64 spu_cmd_buf2_RW;
  203. u64 spu_atomic_status_RW;
  204. };
  205. /**
  206. * struct spu_state
  207. * @lscsa: Local Store Context Save Area.
  208. * @prob: Collapsed Problem State Area, w/o pads.
  209. * @priv1: Collapsed Privileged 1 Area, w/o pads.
  210. * @priv2: Collapsed Privileged 2 Area, w/o pads.
  211. * @spu_chnlcnt_RW: Array of saved channel counts.
  212. * @spu_chnldata_RW: Array of saved channel data.
  213. * @suspend_time: Time stamp when decrementer disabled.
  214. * @slb_esid_RW: Array of saved SLB esid entries.
  215. * @slb_vsid_RW: Array of saved SLB vsid entries.
  216. *
  217. * Structure representing the whole of the SPU
  218. * context save area (CSA). This struct contains
  219. * all of the state necessary to suspend and then
  220. * later optionally resume execution of an SPU
  221. * context.
  222. *
  223. * The @lscsa region is by far the largest, and is
  224. * allocated separately so that it may either be
  225. * pinned or mapped to/from application memory, as
  226. * appropriate for the OS environment.
  227. */
  228. struct spu_state {
  229. struct spu_lscsa *lscsa;
  230. struct spu_problem_collapsed prob;
  231. struct spu_priv1_collapsed priv1;
  232. struct spu_priv2_collapsed priv2;
  233. u64 spu_chnlcnt_RW[32];
  234. u64 spu_chnldata_RW[32];
  235. u32 spu_mailbox_data[4];
  236. u32 pu_mailbox_data[1];
  237. unsigned long suspend_time;
  238. u64 slb_esid_RW[8];
  239. u64 slb_vsid_RW[8];
  240. spinlock_t register_lock;
  241. };
  242. extern void spu_init_csa(struct spu_state *csa);
  243. extern void spu_fini_csa(struct spu_state *csa);
  244. extern int spu_save(struct spu_state *prev, struct spu *spu);
  245. extern int spu_restore(struct spu_state *new, struct spu *spu);
  246. extern int spu_switch(struct spu_state *prev, struct spu_state *new,
  247. struct spu *spu);
  248. #endif /* !__SPU__ */
  249. #endif /* __KERNEL__ */
  250. #endif /* !__ASSEMBLY__ */
  251. #endif /* _SPU_CSA_H_ */