cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

spu_priv1.h (5186B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 * Defines an spu hypervisor abstraction layer.
      4 *
      5 *  Copyright 2006 Sony Corp.
      6 */
      7
      8#if !defined(_SPU_PRIV1_H)
      9#define _SPU_PRIV1_H
     10#if defined(__KERNEL__)
     11
     12#include <linux/types.h>
     13
     14struct spu;
     15struct spu_context;
     16
     17/* access to priv1 registers */
     18
     19struct 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);
     40};
     41
     42extern const struct spu_priv1_ops* spu_priv1_ops;
     43
     44static inline void
     45spu_int_mask_and (struct spu *spu, int class, u64 mask)
     46{
     47	spu_priv1_ops->int_mask_and(spu, class, mask);
     48}
     49
     50static inline void
     51spu_int_mask_or (struct spu *spu, int class, u64 mask)
     52{
     53	spu_priv1_ops->int_mask_or(spu, class, mask);
     54}
     55
     56static inline void
     57spu_int_mask_set (struct spu *spu, int class, u64 mask)
     58{
     59	spu_priv1_ops->int_mask_set(spu, class, mask);
     60}
     61
     62static inline u64
     63spu_int_mask_get (struct spu *spu, int class)
     64{
     65	return spu_priv1_ops->int_mask_get(spu, class);
     66}
     67
     68static inline void
     69spu_int_stat_clear (struct spu *spu, int class, u64 stat)
     70{
     71	spu_priv1_ops->int_stat_clear(spu, class, stat);
     72}
     73
     74static inline u64
     75spu_int_stat_get (struct spu *spu, int class)
     76{
     77	return spu_priv1_ops->int_stat_get (spu, class);
     78}
     79
     80static inline void
     81spu_cpu_affinity_set (struct spu *spu, int cpu)
     82{
     83	spu_priv1_ops->cpu_affinity_set(spu, cpu);
     84}
     85
     86static inline u64
     87spu_mfc_dar_get (struct spu *spu)
     88{
     89	return spu_priv1_ops->mfc_dar_get(spu);
     90}
     91
     92static inline u64
     93spu_mfc_dsisr_get (struct spu *spu)
     94{
     95	return spu_priv1_ops->mfc_dsisr_get(spu);
     96}
     97
     98static inline void
     99spu_mfc_dsisr_set (struct spu *spu, u64 dsisr)
    100{
    101	spu_priv1_ops->mfc_dsisr_set(spu, dsisr);
    102}
    103
    104static inline void
    105spu_mfc_sdr_setup (struct spu *spu)
    106{
    107	spu_priv1_ops->mfc_sdr_setup(spu);
    108}
    109
    110static inline void
    111spu_mfc_sr1_set (struct spu *spu, u64 sr1)
    112{
    113	spu_priv1_ops->mfc_sr1_set(spu, sr1);
    114}
    115
    116static inline u64
    117spu_mfc_sr1_get (struct spu *spu)
    118{
    119	return spu_priv1_ops->mfc_sr1_get(spu);
    120}
    121
    122static inline void
    123spu_mfc_tclass_id_set (struct spu *spu, u64 tclass_id)
    124{
    125	spu_priv1_ops->mfc_tclass_id_set(spu, tclass_id);
    126}
    127
    128static inline u64
    129spu_mfc_tclass_id_get (struct spu *spu)
    130{
    131	return spu_priv1_ops->mfc_tclass_id_get(spu);
    132}
    133
    134static inline void
    135spu_tlb_invalidate (struct spu *spu)
    136{
    137	spu_priv1_ops->tlb_invalidate(spu);
    138}
    139
    140static inline void
    141spu_resource_allocation_groupID_set (struct spu *spu, u64 id)
    142{
    143	spu_priv1_ops->resource_allocation_groupID_set(spu, id);
    144}
    145
    146static inline u64
    147spu_resource_allocation_groupID_get (struct spu *spu)
    148{
    149	return spu_priv1_ops->resource_allocation_groupID_get(spu);
    150}
    151
    152static inline void
    153spu_resource_allocation_enable_set (struct spu *spu, u64 enable)
    154{
    155	spu_priv1_ops->resource_allocation_enable_set(spu, enable);
    156}
    157
    158static inline u64
    159spu_resource_allocation_enable_get (struct spu *spu)
    160{
    161	return spu_priv1_ops->resource_allocation_enable_get(spu);
    162}
    163
    164/* spu management abstraction */
    165
    166struct 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);
    173};
    174
    175extern const struct spu_management_ops* spu_management_ops;
    176
    177static inline int
    178spu_enumerate_spus (int (*fn)(void *data))
    179{
    180	return spu_management_ops->enumerate_spus(fn);
    181}
    182
    183static inline int
    184spu_create_spu (struct spu *spu, void *data)
    185{
    186	return spu_management_ops->create_spu(spu, data);
    187}
    188
    189static inline int
    190spu_destroy_spu (struct spu *spu)
    191{
    192	return spu_management_ops->destroy_spu(spu);
    193}
    194
    195static inline int
    196spu_init_affinity (void)
    197{
    198	return spu_management_ops->init_affinity();
    199}
    200
    201static inline void
    202spu_enable_spu (struct spu_context *ctx)
    203{
    204	spu_management_ops->enable_spu(ctx);
    205}
    206
    207static inline void
    208spu_disable_spu (struct spu_context *ctx)
    209{
    210	spu_management_ops->disable_spu(ctx);
    211}
    212
    213/*
    214 * The declarations following are put here for convenience
    215 * and only intended to be used by the platform setup code.
    216 */
    217
    218extern const struct spu_priv1_ops spu_priv1_mmio_ops;
    219extern const struct spu_priv1_ops spu_priv1_beat_ops;
    220
    221extern const struct spu_management_ops spu_management_of_ops;
    222
    223#endif /* __KERNEL__ */
    224#endif