blob: 69dcb0c53884f64f82960239d87462257cbc3e17 [file] [log] [blame]
Geoff Levand540270d2006-06-19 20:33:29 +02001/*
2 * Defines an spu hypervisor abstraction layer.
3 *
4 * Copyright 2006 Sony Corp.
5 *
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.
9 *
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.
14 *
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
18 */
19
20#if !defined(_SPU_PRIV1_H)
21#define _SPU_PRIV1_H
22#if defined(__KERNEL__)
23
Geoff Levande28b0032006-11-23 00:46:49 +010024#include <linux/types.h>
25
Geoff Levand540270d2006-06-19 20:33:29 +020026struct spu;
27
28/* access to priv1 registers */
29
Geoff Levande28b0032006-11-23 00:46:49 +010030struct spu_priv1_ops {
Geoff Levand540270d2006-06-19 20:33:29 +020031 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);
Geoff Levanda91942a2006-06-19 20:33:30 +020037 void (*cpu_affinity_set) (struct spu *spu, int cpu);
Geoff Levand540270d2006-06-19 20:33:29 +020038 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);
Masato Noguchi24f43b32006-10-24 18:31:14 +020041 void (*mfc_sdr_setup) (struct spu *spu);
Geoff Levand540270d2006-06-19 20:33:29 +020042 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);
51};
52
53extern const struct spu_priv1_ops* spu_priv1_ops;
54
55static inline void
56spu_int_mask_and (struct spu *spu, int class, u64 mask)
57{
58 spu_priv1_ops->int_mask_and(spu, class, mask);
59}
60
61static inline void
62spu_int_mask_or (struct spu *spu, int class, u64 mask)
63{
64 spu_priv1_ops->int_mask_or(spu, class, mask);
65}
66
67static inline void
68spu_int_mask_set (struct spu *spu, int class, u64 mask)
69{
70 spu_priv1_ops->int_mask_set(spu, class, mask);
71}
72
73static inline u64
74spu_int_mask_get (struct spu *spu, int class)
75{
76 return spu_priv1_ops->int_mask_get(spu, class);
77}
78
79static inline void
80spu_int_stat_clear (struct spu *spu, int class, u64 stat)
81{
82 spu_priv1_ops->int_stat_clear(spu, class, stat);
83}
84
85static inline u64
86spu_int_stat_get (struct spu *spu, int class)
87{
88 return spu_priv1_ops->int_stat_get (spu, class);
89}
90
91static inline void
Geoff Levanda91942a2006-06-19 20:33:30 +020092spu_cpu_affinity_set (struct spu *spu, int cpu)
Geoff Levand540270d2006-06-19 20:33:29 +020093{
Geoff Levanda91942a2006-06-19 20:33:30 +020094 spu_priv1_ops->cpu_affinity_set(spu, cpu);
Geoff Levand540270d2006-06-19 20:33:29 +020095}
96
97static inline u64
98spu_mfc_dar_get (struct spu *spu)
99{
100 return spu_priv1_ops->mfc_dar_get(spu);
101}
102
103static inline u64
104spu_mfc_dsisr_get (struct spu *spu)
105{
106 return spu_priv1_ops->mfc_dsisr_get(spu);
107}
108
109static inline void
110spu_mfc_dsisr_set (struct spu *spu, u64 dsisr)
111{
112 spu_priv1_ops->mfc_dsisr_set(spu, dsisr);
113}
114
115static inline void
Masato Noguchi24f43b32006-10-24 18:31:14 +0200116spu_mfc_sdr_setup (struct spu *spu)
Geoff Levand540270d2006-06-19 20:33:29 +0200117{
Masato Noguchi24f43b32006-10-24 18:31:14 +0200118 spu_priv1_ops->mfc_sdr_setup(spu);
Geoff Levand540270d2006-06-19 20:33:29 +0200119}
120
121static inline void
122spu_mfc_sr1_set (struct spu *spu, u64 sr1)
123{
124 spu_priv1_ops->mfc_sr1_set(spu, sr1);
125}
126
127static inline u64
128spu_mfc_sr1_get (struct spu *spu)
129{
130 return spu_priv1_ops->mfc_sr1_get(spu);
131}
132
133static inline void
134spu_mfc_tclass_id_set (struct spu *spu, u64 tclass_id)
135{
136 spu_priv1_ops->mfc_tclass_id_set(spu, tclass_id);
137}
138
139static inline u64
140spu_mfc_tclass_id_get (struct spu *spu)
141{
142 return spu_priv1_ops->mfc_tclass_id_get(spu);
143}
144
145static inline void
146spu_tlb_invalidate (struct spu *spu)
147{
148 spu_priv1_ops->tlb_invalidate(spu);
149}
150
151static inline void
152spu_resource_allocation_groupID_set (struct spu *spu, u64 id)
153{
154 spu_priv1_ops->resource_allocation_groupID_set(spu, id);
155}
156
157static inline u64
158spu_resource_allocation_groupID_get (struct spu *spu)
159{
160 return spu_priv1_ops->resource_allocation_groupID_get(spu);
161}
162
163static inline void
164spu_resource_allocation_enable_set (struct spu *spu, u64 enable)
165{
166 spu_priv1_ops->resource_allocation_enable_set(spu, enable);
167}
168
169static inline u64
170spu_resource_allocation_enable_get (struct spu *spu)
171{
172 return spu_priv1_ops->resource_allocation_enable_get(spu);
173}
174
Geoff Levande28b0032006-11-23 00:46:49 +0100175/* spu management abstraction */
176
177struct 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);
181};
182
183extern const struct spu_management_ops* spu_management_ops;
184
185static inline int
186spu_enumerate_spus (int (*fn)(void *data))
187{
188 return spu_management_ops->enumerate_spus(fn);
189}
190
191static inline int
192spu_create_spu (struct spu *spu, void *data)
193{
194 return spu_management_ops->create_spu(spu, data);
195}
196
197static inline int
198spu_destroy_spu (struct spu *spu)
199{
200 return spu_management_ops->destroy_spu(spu);
201}
202
203/*
204 * The declarations folowing are put here for convenience
205 * and only intended to be used by the platform setup code.
Geoff Levand540270d2006-06-19 20:33:29 +0200206 */
207
208extern const struct spu_priv1_ops spu_priv1_mmio_ops;
Geoff Levande28b0032006-11-23 00:46:49 +0100209extern const struct spu_management_ops spu_management_of_ops;
Geoff Levand540270d2006-06-19 20:33:29 +0200210
211#endif /* __KERNEL__ */
212#endif