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.
28 * Total number of 128-bit registers.
30 #define NR_SPU_GPRS 128
32 #define NR_SPU_REGS_PAD 7
33 #define NR_SPU_SPILL_REGS 144 /* GPRS + SPRS + PAD */
34 #define SIZEOF_SPU_SPILL_REGS NR_SPU_SPILL_REGS * 16
36 #define SPU_SAVE_COMPLETE 0x3FFB
37 #define SPU_RESTORE_COMPLETE 0x3FFC
40 * Definitions for various 'stopped' status conditions,
41 * to be recreated during context restore.
43 #define SPU_STOPPED_STATUS_P 1
44 #define SPU_STOPPED_STATUS_I 2
45 #define SPU_STOPPED_STATUS_H 3
46 #define SPU_STOPPED_STATUS_S 4
47 #define SPU_STOPPED_STATUS_S_I 5
48 #define SPU_STOPPED_STATUS_S_P 6
49 #define SPU_STOPPED_STATUS_P_H 7
50 #define SPU_STOPPED_STATUS_P_I 8
51 #define SPU_STOPPED_STATUS_R 9
55 * spu_reg128 - generic 128-bit register definition.
62 * struct spu_lscsa - Local Store Context Save Area.
63 * @gprs: Array of saved registers.
64 * @fpcr: Saved floating point status control register.
65 * @decr: Saved decrementer value.
66 * @decr_status: Indicates decrementer run status.
67 * @ppu_mb: Saved PPU mailbox data.
68 * @ppuint_mb: Saved PPU interrupting mailbox data.
69 * @tag_mask: Saved tag group mask.
70 * @event_mask: Saved event mask.
72 * @stopped_status: Conditions to be recreated by restore.
73 * @ls: Saved contents of Local Storage Area.
75 * The LSCSA represents state that is primarily saved and
76 * restored by SPU-side code.
79 struct spu_reg128 gprs[128];
80 struct spu_reg128 fpcr;
81 struct spu_reg128 decr;
82 struct spu_reg128 decr_status;
83 struct spu_reg128 ppu_mb;
84 struct spu_reg128 ppuint_mb;
85 struct spu_reg128 tag_mask;
86 struct spu_reg128 event_mask;
87 struct spu_reg128 srr0;
88 struct spu_reg128 stopped_status;
89 struct spu_reg128 pad[119]; /* 'ls' must be page-aligned. */
90 unsigned char ls[LS_SIZE];
94 * struct spu_problem_collapsed - condensed problem state area, w/o pads.
96 struct spu_problem_collapsed {
101 union mfc_tag_size_class_cmd mfc_union_W;
103 u32 dma_querytype_RW;
104 u32 dma_querymask_RW;
119 * struct spu_priv1_collapsed - condensed privileged 1 area, w/o pads.
121 struct spu_priv1_collapsed {
127 u64 int_mask_class0_RW;
128 u64 int_mask_class1_RW;
129 u64 int_mask_class2_RW;
130 u64 int_stat_class0_RW;
131 u64 int_stat_class1_RW;
132 u64 int_stat_class2_RW;
134 u64 mfc_atomic_flush_RW;
135 u64 resource_allocation_groupID_RW;
136 u64 resource_allocation_enable_RW;
138 u64 mfc_fir_status_or_W;
139 u64 mfc_fir_status_and_W;
141 u64 mfc_fir_mask_or_W;
142 u64 mfc_fir_mask_and_W;
143 u64 mfc_fir_chkstp_enable_RW;
144 u64 smf_sbi_signal_sel;
145 u64 smf_ato_signal_sel;
147 u64 tlb_index_hint_RO;
151 u64 tlb_invalidate_entry_W;
152 u64 tlb_invalidate_all_W;
162 u64 mfc_tclass_id_RW;
164 u64 smf_dma_signal_sel;
184 * struct spu_priv2_collapsed - condensed priviliged 2 area, w/o pads.
186 struct spu_priv2_collapsed {
190 u64 slb_invalidate_entry_W;
191 u64 slb_invalidate_all_W;
192 struct mfc_cq_sr spuq[16];
193 struct mfc_cq_sr puq[8];
198 u64 spu_chnlcntptr_RW;
202 u64 spu_tag_status_query_RW;
205 u64 spu_atomic_status_RW;
210 * @lscsa: Local Store Context Save Area.
211 * @prob: Collapsed Problem State Area, w/o pads.
212 * @priv1: Collapsed Privileged 1 Area, w/o pads.
213 * @priv2: Collapsed Privileged 2 Area, w/o pads.
214 * @spu_chnlcnt_RW: Array of saved channel counts.
215 * @spu_chnldata_RW: Array of saved channel data.
216 * @suspend_time: Time stamp when decrementer disabled.
217 * @slb_esid_RW: Array of saved SLB esid entries.
218 * @slb_vsid_RW: Array of saved SLB vsid entries.
220 * Structure representing the whole of the SPU
221 * context save area (CSA). This struct contains
222 * all of the state necessary to suspend and then
223 * later optionally resume execution of an SPU
226 * The @lscsa region is by far the largest, and is
227 * allocated separately so that it may either be
228 * pinned or mapped to/from application memory, as
229 * appropriate for the OS environment.
232 struct spu_lscsa *lscsa;
233 struct spu_problem_collapsed prob;
234 struct spu_priv1_collapsed priv1;
235 struct spu_priv2_collapsed priv2;
236 u64 spu_chnlcnt_RW[32];
237 u64 spu_chnldata_RW[32];
238 u32 spu_mailbox_data[4];
239 u32 pu_mailbox_data[1];
240 unsigned long suspend_time;
243 spinlock_t register_lock;
246 extern void spu_init_csa(struct spu_state *csa);
247 extern void spu_fini_csa(struct spu_state *csa);
248 extern int spu_save(struct spu_state *prev, struct spu *spu);
249 extern int spu_restore(struct spu_state *new, struct spu *spu);
250 extern int spu_switch(struct spu_state *prev, struct spu_state *new,
253 #endif /* __KERNEL__ */
254 #endif /* !__ASSEMBLY__ */
255 #endif /* _SPU_CSA_H_ */