1 /* 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 24 #include <linux/types.h> 25 26 struct spu; 27 struct spu_context; 28 29 /* access to priv1 registers */ 30 31 struct spu_priv1_ops { 32 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); 38 void (*cpu_affinity_set) (struct spu *spu, int cpu); 39 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); 42 void (*mfc_sdr_setup) (struct spu *spu); 43 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 54 extern const struct spu_priv1_ops* spu_priv1_ops; 55 56 static inline void 57 spu_int_mask_and (struct spu *spu, int class, u64 mask) 58 { 59 spu_priv1_ops->int_mask_and(spu, class, mask); 60 } 61 62 static inline void 63 spu_int_mask_or (struct spu *spu, int class, u64 mask) 64 { 65 spu_priv1_ops->int_mask_or(spu, class, mask); 66 } 67 68 static inline void 69 spu_int_mask_set (struct spu *spu, int class, u64 mask) 70 { 71 spu_priv1_ops->int_mask_set(spu, class, mask); 72 } 73 74 static inline u64 75 spu_int_mask_get (struct spu *spu, int class) 76 { 77 return spu_priv1_ops->int_mask_get(spu, class); 78 } 79 80 static inline void 81 spu_int_stat_clear (struct spu *spu, int class, u64 stat) 82 { 83 spu_priv1_ops->int_stat_clear(spu, class, stat); 84 } 85 86 static inline u64 87 spu_int_stat_get (struct spu *spu, int class) 88 { 89 return spu_priv1_ops->int_stat_get (spu, class); 90 } 91 92 static inline void 93 spu_cpu_affinity_set (struct spu *spu, int cpu) 94 { 95 spu_priv1_ops->cpu_affinity_set(spu, cpu); 96 } 97 98 static inline u64 99 spu_mfc_dar_get (struct spu *spu) 100 { 101 return spu_priv1_ops->mfc_dar_get(spu); 102 } 103 104 static inline u64 105 spu_mfc_dsisr_get (struct spu *spu) 106 { 107 return spu_priv1_ops->mfc_dsisr_get(spu); 108 } 109 110 static inline void 111 spu_mfc_dsisr_set (struct spu *spu, u64 dsisr) 112 { 113 spu_priv1_ops->mfc_dsisr_set(spu, dsisr); 114 } 115 116 static inline void 117 spu_mfc_sdr_setup (struct spu *spu) 118 { 119 spu_priv1_ops->mfc_sdr_setup(spu); 120 } 121 122 static inline void 123 spu_mfc_sr1_set (struct spu *spu, u64 sr1) 124 { 125 spu_priv1_ops->mfc_sr1_set(spu, sr1); 126 } 127 128 static inline u64 129 spu_mfc_sr1_get (struct spu *spu) 130 { 131 return spu_priv1_ops->mfc_sr1_get(spu); 132 } 133 134 static inline void 135 spu_mfc_tclass_id_set (struct spu *spu, u64 tclass_id) 136 { 137 spu_priv1_ops->mfc_tclass_id_set(spu, tclass_id); 138 } 139 140 static inline u64 141 spu_mfc_tclass_id_get (struct spu *spu) 142 { 143 return spu_priv1_ops->mfc_tclass_id_get(spu); 144 } 145 146 static inline void 147 spu_tlb_invalidate (struct spu *spu) 148 { 149 spu_priv1_ops->tlb_invalidate(spu); 150 } 151 152 static inline void 153 spu_resource_allocation_groupID_set (struct spu *spu, u64 id) 154 { 155 spu_priv1_ops->resource_allocation_groupID_set(spu, id); 156 } 157 158 static inline u64 159 spu_resource_allocation_groupID_get (struct spu *spu) 160 { 161 return spu_priv1_ops->resource_allocation_groupID_get(spu); 162 } 163 164 static inline void 165 spu_resource_allocation_enable_set (struct spu *spu, u64 enable) 166 { 167 spu_priv1_ops->resource_allocation_enable_set(spu, enable); 168 } 169 170 static inline u64 171 spu_resource_allocation_enable_get (struct spu *spu) 172 { 173 return spu_priv1_ops->resource_allocation_enable_get(spu); 174 } 175 176 /* spu management abstraction */ 177 178 struct 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); 182 void (*enable_spu)(struct spu_context *ctx); 183 void (*disable_spu)(struct spu_context *ctx); 184 int (*init_affinity)(void); 185 }; 186 187 extern const struct spu_management_ops* spu_management_ops; 188 189 static inline int 190 spu_enumerate_spus (int (*fn)(void *data)) 191 { 192 return spu_management_ops->enumerate_spus(fn); 193 } 194 195 static inline int 196 spu_create_spu (struct spu *spu, void *data) 197 { 198 return spu_management_ops->create_spu(spu, data); 199 } 200 201 static inline int 202 spu_destroy_spu (struct spu *spu) 203 { 204 return spu_management_ops->destroy_spu(spu); 205 } 206 207 static inline int 208 spu_init_affinity (void) 209 { 210 return spu_management_ops->init_affinity(); 211 } 212 213 static inline void 214 spu_enable_spu (struct spu_context *ctx) 215 { 216 spu_management_ops->enable_spu(ctx); 217 } 218 219 static inline void 220 spu_disable_spu (struct spu_context *ctx) 221 { 222 spu_management_ops->disable_spu(ctx); 223 } 224 225 /* 226 * The declarations following are put here for convenience 227 * and only intended to be used by the platform setup code. 228 */ 229 230 extern const struct spu_priv1_ops spu_priv1_mmio_ops; 231 extern const struct spu_priv1_ops spu_priv1_beat_ops; 232 233 extern const struct spu_management_ops spu_management_of_ops; 234 235 #endif /* __KERNEL__ */ 236 #endif 237