Path: blob/master/arch/powerpc/platforms/cell/beat_spu_priv1.c
10818 views
/*1* spu hypervisor abstraction for Beat2*3* (C) Copyright 2006-2007 TOSHIBA CORPORATION4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License along16* with this program; if not, write to the Free Software Foundation, Inc.,17* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.18*/1920#include <linux/module.h>2122#include <asm/types.h>23#include <asm/spu.h>24#include <asm/spu_priv1.h>2526#include "beat_wrapper.h"2728static inline void _int_mask_set(struct spu *spu, int class, u64 mask)29{30spu->shadow_int_mask_RW[class] = mask;31beat_set_irq_mask_for_spe(spu->spe_id, class, mask);32}3334static inline u64 _int_mask_get(struct spu *spu, int class)35{36return spu->shadow_int_mask_RW[class];37}3839static void int_mask_set(struct spu *spu, int class, u64 mask)40{41_int_mask_set(spu, class, mask);42}4344static u64 int_mask_get(struct spu *spu, int class)45{46return _int_mask_get(spu, class);47}4849static void int_mask_and(struct spu *spu, int class, u64 mask)50{51u64 old_mask;52old_mask = _int_mask_get(spu, class);53_int_mask_set(spu, class, old_mask & mask);54}5556static void int_mask_or(struct spu *spu, int class, u64 mask)57{58u64 old_mask;59old_mask = _int_mask_get(spu, class);60_int_mask_set(spu, class, old_mask | mask);61}6263static void int_stat_clear(struct spu *spu, int class, u64 stat)64{65beat_clear_interrupt_status_of_spe(spu->spe_id, class, stat);66}6768static u64 int_stat_get(struct spu *spu, int class)69{70u64 int_stat;71beat_get_interrupt_status_of_spe(spu->spe_id, class, &int_stat);72return int_stat;73}7475static void cpu_affinity_set(struct spu *spu, int cpu)76{77return;78}7980static u64 mfc_dar_get(struct spu *spu)81{82u64 dar;83beat_get_spe_privileged_state_1_registers(84spu->spe_id,85offsetof(struct spu_priv1, mfc_dar_RW), &dar);86return dar;87}8889static u64 mfc_dsisr_get(struct spu *spu)90{91u64 dsisr;92beat_get_spe_privileged_state_1_registers(93spu->spe_id,94offsetof(struct spu_priv1, mfc_dsisr_RW), &dsisr);95return dsisr;96}9798static void mfc_dsisr_set(struct spu *spu, u64 dsisr)99{100beat_set_spe_privileged_state_1_registers(101spu->spe_id,102offsetof(struct spu_priv1, mfc_dsisr_RW), dsisr);103}104105static void mfc_sdr_setup(struct spu *spu)106{107return;108}109110static void mfc_sr1_set(struct spu *spu, u64 sr1)111{112beat_set_spe_privileged_state_1_registers(113spu->spe_id,114offsetof(struct spu_priv1, mfc_sr1_RW), sr1);115}116117static u64 mfc_sr1_get(struct spu *spu)118{119u64 sr1;120beat_get_spe_privileged_state_1_registers(121spu->spe_id,122offsetof(struct spu_priv1, mfc_sr1_RW), &sr1);123return sr1;124}125126static void mfc_tclass_id_set(struct spu *spu, u64 tclass_id)127{128beat_set_spe_privileged_state_1_registers(129spu->spe_id,130offsetof(struct spu_priv1, mfc_tclass_id_RW), tclass_id);131}132133static u64 mfc_tclass_id_get(struct spu *spu)134{135u64 tclass_id;136beat_get_spe_privileged_state_1_registers(137spu->spe_id,138offsetof(struct spu_priv1, mfc_tclass_id_RW), &tclass_id);139return tclass_id;140}141142static void tlb_invalidate(struct spu *spu)143{144beat_set_spe_privileged_state_1_registers(145spu->spe_id,146offsetof(struct spu_priv1, tlb_invalidate_entry_W), 0ul);147}148149static void resource_allocation_groupID_set(struct spu *spu, u64 id)150{151beat_set_spe_privileged_state_1_registers(152spu->spe_id,153offsetof(struct spu_priv1, resource_allocation_groupID_RW),154id);155}156157static u64 resource_allocation_groupID_get(struct spu *spu)158{159u64 id;160beat_get_spe_privileged_state_1_registers(161spu->spe_id,162offsetof(struct spu_priv1, resource_allocation_groupID_RW),163&id);164return id;165}166167static void resource_allocation_enable_set(struct spu *spu, u64 enable)168{169beat_set_spe_privileged_state_1_registers(170spu->spe_id,171offsetof(struct spu_priv1, resource_allocation_enable_RW),172enable);173}174175static u64 resource_allocation_enable_get(struct spu *spu)176{177u64 enable;178beat_get_spe_privileged_state_1_registers(179spu->spe_id,180offsetof(struct spu_priv1, resource_allocation_enable_RW),181&enable);182return enable;183}184185const struct spu_priv1_ops spu_priv1_beat_ops = {186.int_mask_and = int_mask_and,187.int_mask_or = int_mask_or,188.int_mask_set = int_mask_set,189.int_mask_get = int_mask_get,190.int_stat_clear = int_stat_clear,191.int_stat_get = int_stat_get,192.cpu_affinity_set = cpu_affinity_set,193.mfc_dar_get = mfc_dar_get,194.mfc_dsisr_get = mfc_dsisr_get,195.mfc_dsisr_set = mfc_dsisr_set,196.mfc_sdr_setup = mfc_sdr_setup,197.mfc_sr1_set = mfc_sr1_set,198.mfc_sr1_get = mfc_sr1_get,199.mfc_tclass_id_set = mfc_tclass_id_set,200.mfc_tclass_id_get = mfc_tclass_id_get,201.tlb_invalidate = tlb_invalidate,202.resource_allocation_groupID_set = resource_allocation_groupID_set,203.resource_allocation_groupID_get = resource_allocation_groupID_get,204.resource_allocation_enable_set = resource_allocation_enable_set,205.resource_allocation_enable_get = resource_allocation_enable_get,206};207208209