blob: 25020a34ce7fd47b6478a272b6969af4e74981aa [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;
Masato Noguchic25620d2007-12-05 13:49:31 +110027struct spu_context;
Geoff Levand540270d2006-06-19 20:33:29 +020028
29/* access to priv1 registers */
30
Geoff Levande28b0032006-11-23 00:46:49 +010031struct spu_priv1_ops {
Geoff Levand540270d2006-06-19 20:33:29 +020032 void (*int_mask_and) (struct spu *spu, int class, u64 mask);
33 void (*int_mask_or) (struct spu *spu, int class, u64 mask);
34 void (*int_mask_set) (struct spu *spu, int class, u64 mask);
35 u64 (*int_mask_get) (struct spu *spu, int class);
36 void (*int_stat_clear) (struct spu *spu, int class, u64 stat);
37 u64 (*int_stat_get) (struct spu *spu, int class);
Geoff Levanda91942a2006-06-19 20:33:30 +020038 void (*cpu_affinity_set) (struct spu *spu, int cpu);
Geoff Levand540270d2006-06-19 20:33:29 +020039 u64 (*mfc_dar_get) (struct spu *spu);
40 u64 (*mfc_dsisr_get) (struct spu *spu);
41 void (*mfc_dsisr_set) (struct spu *spu, u64 dsisr);
Masato Noguchi24f43b32006-10-24 18:31:14 +020042 void (*mfc_sdr_setup) (struct spu *spu);
Geoff Levand540270d2006-06-19 20:33:29 +020043 void (*mfc_sr1_set) (struct spu *spu, u64 sr1);
44 u64 (*mfc_sr1_get) (struct spu *spu);
45 void (*mfc_tclass_id_set) (struct spu *spu, u64 tclass_id);
46 u64 (*mfc_tclass_id_get) (struct spu *spu);
47 void (*tlb_invalidate) (struct spu *spu);
48 void (*resource_allocation_groupID_set) (struct spu *spu, u64 id);
49 u64 (*resource_allocation_groupID_get) (struct spu *spu);
50 void (*resource_allocation_enable_set) (struct spu *spu, u64 enable);
51 u64 (*resource_allocation_enable_get) (struct spu *spu);
52};
53
54extern const struct spu_priv1_ops* spu_priv1_ops;
55
56static inline void
57spu_int_mask_and (struct spu *spu, int class, u64 mask)
58{
59 spu_priv1_ops->int_mask_and(spu, class, mask);
60}
61
62static inline void
63spu_int_mask_or (struct spu *spu, int class, u64 mask)
64{
65 spu_priv1_ops->int_mask_or(spu, class, mask);
66}
67
68static inline void
69spu_int_mask_set (struct spu *spu, int class, u64 mask)
70{
71 spu_priv1_ops->int_mask_set(spu, class, mask);
72}
73
74static inline u64
75spu_int_mask_get (struct spu *spu, int class)
76{
77 return spu_priv1_ops->int_mask_get(spu, class);
78}
79
80static inline void
81spu_int_stat_clear (struct spu *spu, int class, u64 stat)
82{
83 spu_priv1_ops->int_stat_clear(spu, class, stat);
84}
85
86static inline u64
87spu_int_stat_get (struct spu *spu, int class)
88{
89 return spu_priv1_ops->int_stat_get (spu, class);
90}
91
92static inline void
Geoff Levanda91942a2006-06-19 20:33:30 +020093spu_cpu_affinity_set (struct spu *spu, int cpu)
Geoff Levand540270d2006-06-19 20:33:29 +020094{
Geoff Levanda91942a2006-06-19 20:33:30 +020095 spu_priv1_ops->cpu_affinity_set(spu, cpu);
Geoff Levand540270d2006-06-19 20:33:29 +020096}
97
98static inline u64
99spu_mfc_dar_get (struct spu *spu)
100{
101 return spu_priv1_ops->mfc_dar_get(spu);
102}
103
104static inline u64
105spu_mfc_dsisr_get (struct spu *spu)
106{
107 return spu_priv1_ops->mfc_dsisr_get(spu);
108}
109
110static inline void
111spu_mfc_dsisr_set (struct spu *spu, u64 dsisr)
112{
113 spu_priv1_ops->mfc_dsisr_set(spu, dsisr);
114}
115
116static inline void
Masato Noguchi24f43b32006-10-24 18:31:14 +0200117spu_mfc_sdr_setup (struct spu *spu)
Geoff Levand540270d2006-06-19 20:33:29 +0200118{
Masato Noguchi24f43b32006-10-24 18:31:14 +0200119 spu_priv1_ops->mfc_sdr_setup(spu);
Geoff Levand540270d2006-06-19 20:33:29 +0200120}
121
122static inline void
123spu_mfc_sr1_set (struct spu *spu, u64 sr1)
124{
125 spu_priv1_ops->mfc_sr1_set(spu, sr1);
126}
127
128static inline u64
129spu_mfc_sr1_get (struct spu *spu)
130{
131 return spu_priv1_ops->mfc_sr1_get(spu);
132}
133
134static inline void
135spu_mfc_tclass_id_set (struct spu *spu, u64 tclass_id)
136{
137 spu_priv1_ops->mfc_tclass_id_set(spu, tclass_id);
138}
139
140static inline u64
141spu_mfc_tclass_id_get (struct spu *spu)
142{
143 return spu_priv1_ops->mfc_tclass_id_get(spu);
144}
145
146static inline void
147spu_tlb_invalidate (struct spu *spu)
148{
149 spu_priv1_ops->tlb_invalidate(spu);
150}
151
152static inline void
153spu_resource_allocation_groupID_set (struct spu *spu, u64 id)
154{
155 spu_priv1_ops->resource_allocation_groupID_set(spu, id);
156}
157
158static inline u64
159spu_resource_allocation_groupID_get (struct spu *spu)
160{
161 return spu_priv1_ops->resource_allocation_groupID_get(spu);
162}
163
164static inline void
165spu_resource_allocation_enable_set (struct spu *spu, u64 enable)
166{
167 spu_priv1_ops->resource_allocation_enable_set(spu, enable);
168}
169
170static inline u64
171spu_resource_allocation_enable_get (struct spu *spu)
172{
173 return spu_priv1_ops->resource_allocation_enable_get(spu);
174}
175
Geoff Levande28b0032006-11-23 00:46:49 +0100176/* spu management abstraction */
177
178struct spu_management_ops {
179 int (*enumerate_spus)(int (*fn)(void *data));
180 int (*create_spu)(struct spu *spu, void *data);
181 int (*destroy_spu)(struct spu *spu);
Masato Noguchic25620d2007-12-05 13:49:31 +1100182 void (*enable_spu)(struct spu_context *ctx);
183 void (*disable_spu)(struct spu_context *ctx);
Andre Detschf5996442007-08-03 18:53:46 -0700184 int (*init_affinity)(void);
Geoff Levande28b0032006-11-23 00:46:49 +0100185};
186
187extern const struct spu_management_ops* spu_management_ops;
188
189static inline int
190spu_enumerate_spus (int (*fn)(void *data))
191{
192 return spu_management_ops->enumerate_spus(fn);
193}
194
195static inline int
196spu_create_spu (struct spu *spu, void *data)
197{
198 return spu_management_ops->create_spu(spu, data);
199}
200
201static inline int
202spu_destroy_spu (struct spu *spu)
203{
204 return spu_management_ops->destroy_spu(spu);
205}
206
Andre Detschf5996442007-08-03 18:53:46 -0700207static inline int
208spu_init_affinity (void)
209{
210 return spu_management_ops->init_affinity();
211}
212
Masato Noguchic25620d2007-12-05 13:49:31 +1100213static inline void
214spu_enable_spu (struct spu_context *ctx)
215{
216 spu_management_ops->enable_spu(ctx);
217}
218
219static inline void
220spu_disable_spu (struct spu_context *ctx)
221{
222 spu_management_ops->disable_spu(ctx);
223}
224
Geoff Levande28b0032006-11-23 00:46:49 +0100225/*
226 * The declarations folowing are put here for convenience
227 * and only intended to be used by the platform setup code.
Geoff Levand540270d2006-06-19 20:33:29 +0200228 */
229
230extern const struct spu_priv1_ops spu_priv1_mmio_ops;
Ishizaki Kouc9868fe2007-02-02 16:45:33 +0900231extern const struct spu_priv1_ops spu_priv1_beat_ops;
232
Geoff Levande28b0032006-11-23 00:46:49 +0100233extern const struct spu_management_ops spu_management_of_ops;
Geoff Levand540270d2006-06-19 20:33:29 +0200234
235#endif /* __KERNEL__ */
236#endif