inotify: fix race
[linux-2.6.22.y-op.git] / include / asm-powerpc / spu_csa.h
blobc48ae185c8744ecc3a6e57a3c93bb852a039c5f4
1 /*
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)
11 * any later version.
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.
23 #ifndef _SPU_CSA_H_
24 #define _SPU_CSA_H_
25 #ifdef __KERNEL__
28 * Total number of 128-bit registers.
30 #define NR_SPU_GPRS 128
31 #define NR_SPU_SPRS 9
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
53 #ifndef __ASSEMBLY__
54 /**
55 * spu_reg128 - generic 128-bit register definition.
57 struct spu_reg128 {
58 u32 slot[4];
61 /**
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.
71 * @srr0: Saved SRR0.
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.
78 struct spu_lscsa {
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;
91 * 'ls' must be page-aligned on all configurations.
92 * Since we don't want to rely on having the spu-gcc
93 * installed to build the kernel and this structure
94 * is used in the SPU-side code, make it 64k-page
95 * aligned for now.
97 unsigned char ls[LS_SIZE] __attribute__((aligned(65536)));
100 #ifndef __SPU__
102 * struct spu_problem_collapsed - condensed problem state area, w/o pads.
104 struct spu_problem_collapsed {
105 u64 spc_mssync_RW;
106 u32 mfc_lsa_W;
107 u32 unused_pad0;
108 u64 mfc_ea_W;
109 union mfc_tag_size_class_cmd mfc_union_W;
110 u32 dma_qstatus_R;
111 u32 dma_querytype_RW;
112 u32 dma_querymask_RW;
113 u32 dma_tagstatus_R;
114 u32 pu_mb_R;
115 u32 spu_mb_W;
116 u32 mb_stat_R;
117 u32 spu_runcntl_RW;
118 u32 spu_status_R;
119 u32 spu_spc_R;
120 u32 spu_npc_RW;
121 u32 signal_notify1;
122 u32 signal_notify2;
123 u32 unused_pad1;
127 * struct spu_priv1_collapsed - condensed privileged 1 area, w/o pads.
129 struct spu_priv1_collapsed {
130 u64 mfc_sr1_RW;
131 u64 mfc_lpid_RW;
132 u64 spu_idr_RW;
133 u64 mfc_vr_RO;
134 u64 spu_vr_RO;
135 u64 int_mask_class0_RW;
136 u64 int_mask_class1_RW;
137 u64 int_mask_class2_RW;
138 u64 int_stat_class0_RW;
139 u64 int_stat_class1_RW;
140 u64 int_stat_class2_RW;
141 u64 int_route_RW;
142 u64 mfc_atomic_flush_RW;
143 u64 resource_allocation_groupID_RW;
144 u64 resource_allocation_enable_RW;
145 u64 mfc_fir_R;
146 u64 mfc_fir_status_or_W;
147 u64 mfc_fir_status_and_W;
148 u64 mfc_fir_mask_R;
149 u64 mfc_fir_mask_or_W;
150 u64 mfc_fir_mask_and_W;
151 u64 mfc_fir_chkstp_enable_RW;
152 u64 smf_sbi_signal_sel;
153 u64 smf_ato_signal_sel;
154 u64 tlb_index_hint_RO;
155 u64 tlb_index_W;
156 u64 tlb_vpn_RW;
157 u64 tlb_rpn_RW;
158 u64 tlb_invalidate_entry_W;
159 u64 tlb_invalidate_all_W;
160 u64 smm_hid;
161 u64 mfc_accr_RW;
162 u64 mfc_dsisr_RW;
163 u64 mfc_dar_RW;
164 u64 rmt_index_RW;
165 u64 rmt_data1_RW;
166 u64 mfc_dsir_R;
167 u64 mfc_lsacr_RW;
168 u64 mfc_lscrr_R;
169 u64 mfc_tclass_id_RW;
170 u64 mfc_rm_boundary;
171 u64 smf_dma_signal_sel;
172 u64 smm_signal_sel;
173 u64 mfc_cer_R;
174 u64 pu_ecc_cntl_RW;
175 u64 pu_ecc_stat_RW;
176 u64 spu_ecc_addr_RW;
177 u64 spu_err_mask_RW;
178 u64 spu_trig0_sel;
179 u64 spu_trig1_sel;
180 u64 spu_trig2_sel;
181 u64 spu_trig3_sel;
182 u64 spu_trace_sel;
183 u64 spu_event0_sel;
184 u64 spu_event1_sel;
185 u64 spu_event2_sel;
186 u64 spu_event3_sel;
187 u64 spu_trace_cntl;
191 * struct spu_priv2_collapsed - condensed priviliged 2 area, w/o pads.
193 struct spu_priv2_collapsed {
194 u64 slb_index_W;
195 u64 slb_esid_RW;
196 u64 slb_vsid_RW;
197 u64 slb_invalidate_entry_W;
198 u64 slb_invalidate_all_W;
199 struct mfc_cq_sr spuq[16];
200 struct mfc_cq_sr puq[8];
201 u64 mfc_control_RW;
202 u64 puint_mb_R;
203 u64 spu_privcntl_RW;
204 u64 spu_lslr_RW;
205 u64 spu_chnlcntptr_RW;
206 u64 spu_chnlcnt_RW;
207 u64 spu_chnldata_RW;
208 u64 spu_cfg_RW;
209 u64 spu_tag_status_query_RW;
210 u64 spu_cmd_buf1_RW;
211 u64 spu_cmd_buf2_RW;
212 u64 spu_atomic_status_RW;
216 * struct spu_state
217 * @lscsa: Local Store Context Save Area.
218 * @prob: Collapsed Problem State Area, w/o pads.
219 * @priv1: Collapsed Privileged 1 Area, w/o pads.
220 * @priv2: Collapsed Privileged 2 Area, w/o pads.
221 * @spu_chnlcnt_RW: Array of saved channel counts.
222 * @spu_chnldata_RW: Array of saved channel data.
223 * @suspend_time: Time stamp when decrementer disabled.
225 * Structure representing the whole of the SPU
226 * context save area (CSA). This struct contains
227 * all of the state necessary to suspend and then
228 * later optionally resume execution of an SPU
229 * context.
231 * The @lscsa region is by far the largest, and is
232 * allocated separately so that it may either be
233 * pinned or mapped to/from application memory, as
234 * appropriate for the OS environment.
236 struct spu_state {
237 struct spu_lscsa *lscsa;
238 #ifdef CONFIG_SPU_FS_64K_LS
239 int use_big_pages;
240 /* One struct page per 64k page */
241 #define SPU_LSCSA_NUM_BIG_PAGES (sizeof(struct spu_lscsa) / 0x10000)
242 struct page *lscsa_pages[SPU_LSCSA_NUM_BIG_PAGES];
243 #endif
244 struct spu_problem_collapsed prob;
245 struct spu_priv1_collapsed priv1;
246 struct spu_priv2_collapsed priv2;
247 u64 spu_chnlcnt_RW[32];
248 u64 spu_chnldata_RW[32];
249 u32 spu_mailbox_data[4];
250 u32 pu_mailbox_data[1];
251 u64 dar, dsisr;
252 unsigned long suspend_time;
253 spinlock_t register_lock;
256 extern int spu_init_csa(struct spu_state *csa);
257 extern void spu_fini_csa(struct spu_state *csa);
258 extern int spu_save(struct spu_state *prev, struct spu *spu);
259 extern int spu_restore(struct spu_state *new, struct spu *spu);
260 extern int spu_switch(struct spu_state *prev, struct spu_state *new,
261 struct spu *spu);
262 extern int spu_alloc_lscsa(struct spu_state *csa);
263 extern void spu_free_lscsa(struct spu_state *csa);
265 #endif /* !__SPU__ */
266 #endif /* __KERNEL__ */
267 #endif /* !__ASSEMBLY__ */
268 #endif /* _SPU_CSA_H_ */