1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Defines an spu hypervisor abstraction layer.
5 * Copyright 2006 Sony Corp.
8 #if !defined(_SPU_PRIV1_H)
10 #if defined(__KERNEL__)
12 #include <linux/types.h>
17 /* access to priv1 registers */
19 struct spu_priv1_ops
{
20 void (*int_mask_and
) (struct spu
*spu
, int class, u64 mask
);
21 void (*int_mask_or
) (struct spu
*spu
, int class, u64 mask
);
22 void (*int_mask_set
) (struct spu
*spu
, int class, u64 mask
);
23 u64 (*int_mask_get
) (struct spu
*spu
, int class);
24 void (*int_stat_clear
) (struct spu
*spu
, int class, u64 stat
);
25 u64 (*int_stat_get
) (struct spu
*spu
, int class);
26 void (*cpu_affinity_set
) (struct spu
*spu
, int cpu
);
27 u64 (*mfc_dar_get
) (struct spu
*spu
);
28 u64 (*mfc_dsisr_get
) (struct spu
*spu
);
29 void (*mfc_dsisr_set
) (struct spu
*spu
, u64 dsisr
);
30 void (*mfc_sdr_setup
) (struct spu
*spu
);
31 void (*mfc_sr1_set
) (struct spu
*spu
, u64 sr1
);
32 u64 (*mfc_sr1_get
) (struct spu
*spu
);
33 void (*mfc_tclass_id_set
) (struct spu
*spu
, u64 tclass_id
);
34 u64 (*mfc_tclass_id_get
) (struct spu
*spu
);
35 void (*tlb_invalidate
) (struct spu
*spu
);
36 void (*resource_allocation_groupID_set
) (struct spu
*spu
, u64 id
);
37 u64 (*resource_allocation_groupID_get
) (struct spu
*spu
);
38 void (*resource_allocation_enable_set
) (struct spu
*spu
, u64 enable
);
39 u64 (*resource_allocation_enable_get
) (struct spu
*spu
);
42 extern const struct spu_priv1_ops
* spu_priv1_ops
;
45 spu_int_mask_and (struct spu
*spu
, int class, u64 mask
)
47 spu_priv1_ops
->int_mask_and(spu
, class, mask
);
51 spu_int_mask_or (struct spu
*spu
, int class, u64 mask
)
53 spu_priv1_ops
->int_mask_or(spu
, class, mask
);
57 spu_int_mask_set (struct spu
*spu
, int class, u64 mask
)
59 spu_priv1_ops
->int_mask_set(spu
, class, mask
);
63 spu_int_mask_get (struct spu
*spu
, int class)
65 return spu_priv1_ops
->int_mask_get(spu
, class);
69 spu_int_stat_clear (struct spu
*spu
, int class, u64 stat
)
71 spu_priv1_ops
->int_stat_clear(spu
, class, stat
);
75 spu_int_stat_get (struct spu
*spu
, int class)
77 return spu_priv1_ops
->int_stat_get (spu
, class);
81 spu_cpu_affinity_set (struct spu
*spu
, int cpu
)
83 spu_priv1_ops
->cpu_affinity_set(spu
, cpu
);
87 spu_mfc_dar_get (struct spu
*spu
)
89 return spu_priv1_ops
->mfc_dar_get(spu
);
93 spu_mfc_dsisr_get (struct spu
*spu
)
95 return spu_priv1_ops
->mfc_dsisr_get(spu
);
99 spu_mfc_dsisr_set (struct spu
*spu
, u64 dsisr
)
101 spu_priv1_ops
->mfc_dsisr_set(spu
, dsisr
);
105 spu_mfc_sdr_setup (struct spu
*spu
)
107 spu_priv1_ops
->mfc_sdr_setup(spu
);
111 spu_mfc_sr1_set (struct spu
*spu
, u64 sr1
)
113 spu_priv1_ops
->mfc_sr1_set(spu
, sr1
);
117 spu_mfc_sr1_get (struct spu
*spu
)
119 return spu_priv1_ops
->mfc_sr1_get(spu
);
123 spu_mfc_tclass_id_set (struct spu
*spu
, u64 tclass_id
)
125 spu_priv1_ops
->mfc_tclass_id_set(spu
, tclass_id
);
129 spu_mfc_tclass_id_get (struct spu
*spu
)
131 return spu_priv1_ops
->mfc_tclass_id_get(spu
);
135 spu_tlb_invalidate (struct spu
*spu
)
137 spu_priv1_ops
->tlb_invalidate(spu
);
141 spu_resource_allocation_groupID_set (struct spu
*spu
, u64 id
)
143 spu_priv1_ops
->resource_allocation_groupID_set(spu
, id
);
147 spu_resource_allocation_groupID_get (struct spu
*spu
)
149 return spu_priv1_ops
->resource_allocation_groupID_get(spu
);
153 spu_resource_allocation_enable_set (struct spu
*spu
, u64 enable
)
155 spu_priv1_ops
->resource_allocation_enable_set(spu
, enable
);
159 spu_resource_allocation_enable_get (struct spu
*spu
)
161 return spu_priv1_ops
->resource_allocation_enable_get(spu
);
164 /* spu management abstraction */
166 struct spu_management_ops
{
167 int (*enumerate_spus
)(int (*fn
)(void *data
));
168 int (*create_spu
)(struct spu
*spu
, void *data
);
169 int (*destroy_spu
)(struct spu
*spu
);
170 void (*enable_spu
)(struct spu_context
*ctx
);
171 void (*disable_spu
)(struct spu_context
*ctx
);
172 int (*init_affinity
)(void);
175 extern const struct spu_management_ops
* spu_management_ops
;
178 spu_enumerate_spus (int (*fn
)(void *data
))
180 return spu_management_ops
->enumerate_spus(fn
);
184 spu_create_spu (struct spu
*spu
, void *data
)
186 return spu_management_ops
->create_spu(spu
, data
);
190 spu_destroy_spu (struct spu
*spu
)
192 return spu_management_ops
->destroy_spu(spu
);
196 spu_init_affinity (void)
198 return spu_management_ops
->init_affinity();
202 spu_enable_spu (struct spu_context
*ctx
)
204 spu_management_ops
->enable_spu(ctx
);
208 spu_disable_spu (struct spu_context
*ctx
)
210 spu_management_ops
->disable_spu(ctx
);
214 * The declarations following are put here for convenience
215 * and only intended to be used by the platform setup code.
218 extern const struct spu_priv1_ops spu_priv1_mmio_ops
;
219 extern const struct spu_priv1_ops spu_priv1_beat_ops
;
221 extern const struct spu_management_ops spu_management_of_ops
;
223 #endif /* __KERNEL__ */