2 * Defines an spu hypervisor abstraction layer.
4 * Copyright 2006 Sony Corp.
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.
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.
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
20 #if !defined(_SPU_PRIV1_H)
22 #if defined(__KERNEL__)
24 #include <linux/types.h>
28 /* access to priv1 registers */
30 struct spu_priv1_ops {
31 void (*int_mask_and) (struct spu *spu, int class, u64 mask);
32 void (*int_mask_or) (struct spu *spu, int class, u64 mask);
33 void (*int_mask_set) (struct spu *spu, int class, u64 mask);
34 u64 (*int_mask_get) (struct spu *spu, int class);
35 void (*int_stat_clear) (struct spu *spu, int class, u64 stat);
36 u64 (*int_stat_get) (struct spu *spu, int class);
37 void (*cpu_affinity_set) (struct spu *spu, int cpu);
38 u64 (*mfc_dar_get) (struct spu *spu);
39 u64 (*mfc_dsisr_get) (struct spu *spu);
40 void (*mfc_dsisr_set) (struct spu *spu, u64 dsisr);
41 void (*mfc_sdr_setup) (struct spu *spu);
42 void (*mfc_sr1_set) (struct spu *spu, u64 sr1);
43 u64 (*mfc_sr1_get) (struct spu *spu);
44 void (*mfc_tclass_id_set) (struct spu *spu, u64 tclass_id);
45 u64 (*mfc_tclass_id_get) (struct spu *spu);
46 void (*tlb_invalidate) (struct spu *spu);
47 void (*resource_allocation_groupID_set) (struct spu *spu, u64 id);
48 u64 (*resource_allocation_groupID_get) (struct spu *spu);
49 void (*resource_allocation_enable_set) (struct spu *spu, u64 enable);
50 u64 (*resource_allocation_enable_get) (struct spu *spu);
53 extern const struct spu_priv1_ops* spu_priv1_ops;
56 spu_int_mask_and (struct spu *spu, int class, u64 mask)
58 spu_priv1_ops->int_mask_and(spu, class, mask);
62 spu_int_mask_or (struct spu *spu, int class, u64 mask)
64 spu_priv1_ops->int_mask_or(spu, class, mask);
68 spu_int_mask_set (struct spu *spu, int class, u64 mask)
70 spu_priv1_ops->int_mask_set(spu, class, mask);
74 spu_int_mask_get (struct spu *spu, int class)
76 return spu_priv1_ops->int_mask_get(spu, class);
80 spu_int_stat_clear (struct spu *spu, int class, u64 stat)
82 spu_priv1_ops->int_stat_clear(spu, class, stat);
86 spu_int_stat_get (struct spu *spu, int class)
88 return spu_priv1_ops->int_stat_get (spu, class);
92 spu_cpu_affinity_set (struct spu *spu, int cpu)
94 spu_priv1_ops->cpu_affinity_set(spu, cpu);
98 spu_mfc_dar_get (struct spu *spu)
100 return spu_priv1_ops->mfc_dar_get(spu);
104 spu_mfc_dsisr_get (struct spu *spu)
106 return spu_priv1_ops->mfc_dsisr_get(spu);
110 spu_mfc_dsisr_set (struct spu *spu, u64 dsisr)
112 spu_priv1_ops->mfc_dsisr_set(spu, dsisr);
116 spu_mfc_sdr_setup (struct spu *spu)
118 spu_priv1_ops->mfc_sdr_setup(spu);
122 spu_mfc_sr1_set (struct spu *spu, u64 sr1)
124 spu_priv1_ops->mfc_sr1_set(spu, sr1);
128 spu_mfc_sr1_get (struct spu *spu)
130 return spu_priv1_ops->mfc_sr1_get(spu);
134 spu_mfc_tclass_id_set (struct spu *spu, u64 tclass_id)
136 spu_priv1_ops->mfc_tclass_id_set(spu, tclass_id);
140 spu_mfc_tclass_id_get (struct spu *spu)
142 return spu_priv1_ops->mfc_tclass_id_get(spu);
146 spu_tlb_invalidate (struct spu *spu)
148 spu_priv1_ops->tlb_invalidate(spu);
152 spu_resource_allocation_groupID_set (struct spu *spu, u64 id)
154 spu_priv1_ops->resource_allocation_groupID_set(spu, id);
158 spu_resource_allocation_groupID_get (struct spu *spu)
160 return spu_priv1_ops->resource_allocation_groupID_get(spu);
164 spu_resource_allocation_enable_set (struct spu *spu, u64 enable)
166 spu_priv1_ops->resource_allocation_enable_set(spu, enable);
170 spu_resource_allocation_enable_get (struct spu *spu)
172 return spu_priv1_ops->resource_allocation_enable_get(spu);
175 /* spu management abstraction */
177 struct spu_management_ops {
178 int (*enumerate_spus)(int (*fn)(void *data));
179 int (*create_spu)(struct spu *spu, void *data);
180 int (*destroy_spu)(struct spu *spu);
183 extern const struct spu_management_ops* spu_management_ops;
186 spu_enumerate_spus (int (*fn)(void *data))
188 return spu_management_ops->enumerate_spus(fn);
192 spu_create_spu (struct spu *spu, void *data)
194 return spu_management_ops->create_spu(spu, data);
198 spu_destroy_spu (struct spu *spu)
200 return spu_management_ops->destroy_spu(spu);
204 * The declarations folowing are put here for convenience
205 * and only intended to be used by the platform setup code.
208 extern const struct spu_priv1_ops spu_priv1_mmio_ops;
209 extern const struct spu_priv1_ops spu_priv1_beat_ops;
211 extern const struct spu_management_ops spu_management_of_ops;
213 #endif /* __KERNEL__ */