2 * spu_csa.h: Definitions for SPU context save area (CSA).
4 * (C) Copyright IBM 2005
6 * Author: Mark Nutter <mnutter@us.ibm.com>
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)
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.
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.
27 * Total number of 128-bit registers.
29 #define NR_SPU_GPRS 128
31 #define NR_SPU_REGS_PAD 7
32 #define NR_SPU_SPILL_REGS 144 /* GPRS + SPRS + PAD */
33 #define SIZEOF_SPU_SPILL_REGS NR_SPU_SPILL_REGS * 16
35 #define SPU_SAVE_COMPLETE 0x3FFB
36 #define SPU_RESTORE_COMPLETE 0x3FFC
39 * Definitions for various 'stopped' status conditions,
40 * to be recreated during context restore.
42 #define SPU_STOPPED_STATUS_P 1
43 #define SPU_STOPPED_STATUS_I 2
44 #define SPU_STOPPED_STATUS_H 3
45 #define SPU_STOPPED_STATUS_S 4
46 #define SPU_STOPPED_STATUS_S_I 5
47 #define SPU_STOPPED_STATUS_S_P 6
48 #define SPU_STOPPED_STATUS_P_H 7
49 #define SPU_STOPPED_STATUS_P_I 8
50 #define SPU_STOPPED_STATUS_R 9
54 * spu_reg128 - generic 128-bit register definition.
61 * struct spu_lscsa - Local Store Context Save Area.
62 * @gprs: Array of saved registers.
63 * @fpcr: Saved floating point status control register.
64 * @decr: Saved decrementer value.
65 * @decr_status: Indicates decrementer run status.
66 * @ppu_mb: Saved PPU mailbox data.
67 * @ppuint_mb: Saved PPU interrupting mailbox data.
68 * @tag_mask: Saved tag group mask.
69 * @event_mask: Saved event mask.
71 * @stopped_status: Conditions to be recreated by restore.
72 * @ls: Saved contents of Local Storage Area.
74 * The LSCSA represents state that is primarily saved and
75 * restored by SPU-side code.
78 struct spu_reg128 gprs[128];
79 struct spu_reg128 fpcr;
80 struct spu_reg128 decr;
81 struct spu_reg128 decr_status;
82 struct spu_reg128 ppu_mb;
83 struct spu_reg128 ppuint_mb;
84 struct spu_reg128 tag_mask;
85 struct spu_reg128 event_mask;
86 struct spu_reg128 srr0;
87 struct spu_reg128 stopped_status;
88 struct spu_reg128 pad[119]; /* 'ls' must be page-aligned. */
89 unsigned char ls[LS_SIZE];
95 * struct spu_problem_collapsed - condensed problem state area, w/o pads.
97 struct spu_problem_collapsed {
102 union mfc_tag_size_class_cmd mfc_union_W;
104 u32 dma_querytype_RW;
105 u32 dma_querymask_RW;
120 * struct spu_priv1_collapsed - condensed privileged 1 area, w/o pads.
122 struct spu_priv1_collapsed {
128 u64 int_mask_class0_RW;
129 u64 int_mask_class1_RW;
130 u64 int_mask_class2_RW;
131 u64 int_stat_class0_RW;
132 u64 int_stat_class1_RW;
133 u64 int_stat_class2_RW;
135 u64 mfc_atomic_flush_RW;
136 u64 resource_allocation_groupID_RW;
137 u64 resource_allocation_enable_RW;
139 u64 mfc_fir_status_or_W;
140 u64 mfc_fir_status_and_W;
142 u64 mfc_fir_mask_or_W;
143 u64 mfc_fir_mask_and_W;
144 u64 mfc_fir_chkstp_enable_RW;
145 u64 smf_sbi_signal_sel;
146 u64 smf_ato_signal_sel;
148 u64 tlb_index_hint_RO;
152 u64 tlb_invalidate_entry_W;
153 u64 tlb_invalidate_all_W;
163 u64 mfc_tclass_id_RW;
165 u64 smf_dma_signal_sel;
185 * struct spu_priv2_collapsed - condensed priviliged 2 area, w/o pads.
187 struct spu_priv2_collapsed {
191 u64 slb_invalidate_entry_W;
192 u64 slb_invalidate_all_W;
193 struct mfc_cq_sr spuq[16];
194 struct mfc_cq_sr puq[8];
199 u64 spu_chnlcntptr_RW;
203 u64 spu_pm_trace_tag_status_RW;
204 u64 spu_tag_status_query_RW;
207 u64 spu_atomic_status_RW;
212 * @lscsa: Local Store Context Save Area.
213 * @prob: Collapsed Problem State Area, w/o pads.
214 * @priv1: Collapsed Privileged 1 Area, w/o pads.
215 * @priv2: Collapsed Privileged 2 Area, w/o pads.
216 * @spu_chnlcnt_RW: Array of saved channel counts.
217 * @spu_chnldata_RW: Array of saved channel data.
218 * @suspend_time: Time stamp when decrementer disabled.
219 * @slb_esid_RW: Array of saved SLB esid entries.
220 * @slb_vsid_RW: Array of saved SLB vsid entries.
222 * Structure representing the whole of the SPU
223 * context save area (CSA). This struct contains
224 * all of the state necessary to suspend and then
225 * later optionally resume execution of an SPU
228 * The @lscsa region is by far the largest, and is
229 * allocated separately so that it may either be
230 * pinned or mapped to/from application memory, as
231 * appropriate for the OS environment.
234 struct spu_lscsa *lscsa;
235 struct spu_problem_collapsed prob;
236 struct spu_priv1_collapsed priv1;
237 struct spu_priv2_collapsed priv2;
238 u64 spu_chnlcnt_RW[32];
239 u64 spu_chnldata_RW[32];
240 u32 spu_mailbox_data[4];
241 u32 pu_mailbox_data[1];
242 unsigned long suspend_time;
247 extern void spu_init_csa(struct spu_state *csa);
248 extern void spu_fini_csa(struct spu_state *csa);
249 extern int spu_save(struct spu_state *prev, struct spu *spu);
250 extern int spu_restore(struct spu_state *new, struct spu *spu);
251 extern int spu_switch(struct spu_state *prev, struct spu_state *new,
254 #endif /* __KERNEL__ */
255 #endif /* !__ASSEMBLY__ */
256 #endif /* _SPU_CSA_H_ */