Path: blob/master/arch/powerpc/platforms/cell/beat_wrapper.h
10818 views
/*1* Beat hypervisor call I/F2*3* (C) Copyright 2007 TOSHIBA CORPORATION4*5* This code is based on arch/powerpc/platforms/pseries/plpar_wrapper.h.6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License along18* with this program; if not, write to the Free Software Foundation, Inc.,19* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.20*/21#ifndef BEAT_HCALL22#include "beat_syscall.h"2324/* defined in hvCall.S */25extern s64 beat_hcall_norets(u64 opcode, ...);26extern s64 beat_hcall_norets8(u64 opcode, u64 arg1, u64 arg2, u64 arg3,27u64 arg4, u64 arg5, u64 arg6, u64 arg7, u64 arg8);28extern s64 beat_hcall1(u64 opcode, u64 retbuf[1], ...);29extern s64 beat_hcall2(u64 opcode, u64 retbuf[2], ...);30extern s64 beat_hcall3(u64 opcode, u64 retbuf[3], ...);31extern s64 beat_hcall4(u64 opcode, u64 retbuf[4], ...);32extern s64 beat_hcall5(u64 opcode, u64 retbuf[5], ...);33extern s64 beat_hcall6(u64 opcode, u64 retbuf[6], ...);3435static inline s64 beat_downcount_of_interrupt(u64 plug_id)36{37return beat_hcall_norets(HV_downcount_of_interrupt, plug_id);38}3940static inline s64 beat_set_interrupt_mask(u64 index,41u64 val0, u64 val1, u64 val2, u64 val3)42{43return beat_hcall_norets(HV_set_interrupt_mask, index,44val0, val1, val2, val3);45}4647static inline s64 beat_destruct_irq_plug(u64 plug_id)48{49return beat_hcall_norets(HV_destruct_irq_plug, plug_id);50}5152static inline s64 beat_construct_and_connect_irq_plug(u64 plug_id,53u64 outlet_id)54{55return beat_hcall_norets(HV_construct_and_connect_irq_plug, plug_id,56outlet_id);57}5859static inline s64 beat_detect_pending_interrupts(u64 index, u64 *retbuf)60{61return beat_hcall4(HV_detect_pending_interrupts, retbuf, index);62}6364static inline s64 beat_pause(u64 style)65{66return beat_hcall_norets(HV_pause, style);67}6869static inline s64 beat_read_htab_entries(u64 htab_id, u64 index, u64 *retbuf)70{71return beat_hcall5(HV_read_htab_entries, retbuf, htab_id, index);72}7374static inline s64 beat_insert_htab_entry(u64 htab_id, u64 group,75u64 bitmask, u64 hpte_v, u64 hpte_r, u64 *slot)76{77u64 dummy[3];78s64 ret;7980ret = beat_hcall3(HV_insert_htab_entry, dummy, htab_id, group,81bitmask, hpte_v, hpte_r);82*slot = dummy[0];83return ret;84}8586static inline s64 beat_write_htab_entry(u64 htab_id, u64 slot,87u64 hpte_v, u64 hpte_r, u64 mask_v, u64 mask_r,88u64 *ret_v, u64 *ret_r)89{90u64 dummy[2];91s64 ret;9293ret = beat_hcall2(HV_write_htab_entry, dummy, htab_id, slot,94hpte_v, hpte_r, mask_v, mask_r);95*ret_v = dummy[0];96*ret_r = dummy[1];97return ret;98}99100static inline s64 beat_insert_htab_entry3(u64 htab_id, u64 group,101u64 hpte_v, u64 hpte_r, u64 mask_v, u64 value_v, u64 *slot)102{103u64 dummy[1];104s64 ret;105106ret = beat_hcall1(HV_insert_htab_entry3, dummy, htab_id, group,107hpte_v, hpte_r, mask_v, value_v);108*slot = dummy[0];109return ret;110}111112static inline s64 beat_invalidate_htab_entry3(u64 htab_id, u64 group,113u64 va, u64 pss)114{115return beat_hcall_norets(HV_invalidate_htab_entry3,116htab_id, group, va, pss);117}118119static inline s64 beat_update_htab_permission3(u64 htab_id, u64 group,120u64 va, u64 pss, u64 ptel_mask, u64 ptel_value)121{122return beat_hcall_norets(HV_update_htab_permission3,123htab_id, group, va, pss, ptel_mask, ptel_value);124}125126static inline s64 beat_clear_htab3(u64 htab_id)127{128return beat_hcall_norets(HV_clear_htab3, htab_id);129}130131static inline void beat_shutdown_logical_partition(u64 code)132{133(void)beat_hcall_norets(HV_shutdown_logical_partition, code);134}135136static inline s64 beat_rtc_write(u64 time_from_epoch)137{138return beat_hcall_norets(HV_rtc_write, time_from_epoch);139}140141static inline s64 beat_rtc_read(u64 *time_from_epoch)142{143u64 dummy[1];144s64 ret;145146ret = beat_hcall1(HV_rtc_read, dummy);147*time_from_epoch = dummy[0];148return ret;149}150151#define BEAT_NVRW_CNT (sizeof(u64) * 6)152153static inline s64 beat_eeprom_write(u64 index, u64 length, u8 *buffer)154{155u64 b[6];156157if (length > BEAT_NVRW_CNT)158return -1;159memcpy(b, buffer, sizeof(b));160return beat_hcall_norets8(HV_eeprom_write, index, length,161b[0], b[1], b[2], b[3], b[4], b[5]);162}163164static inline s64 beat_eeprom_read(u64 index, u64 length, u8 *buffer)165{166u64 b[6];167s64 ret;168169if (length > BEAT_NVRW_CNT)170return -1;171ret = beat_hcall6(HV_eeprom_read, b, index, length);172memcpy(buffer, b, length);173return ret;174}175176static inline s64 beat_set_dabr(u64 value, u64 style)177{178return beat_hcall_norets(HV_set_dabr, value, style);179}180181static inline s64 beat_get_characters_from_console(u64 termno, u64 *len,182u8 *buffer)183{184u64 dummy[3];185s64 ret;186187ret = beat_hcall3(HV_get_characters_from_console, dummy, termno, len);188*len = dummy[0];189memcpy(buffer, dummy + 1, *len);190return ret;191}192193static inline s64 beat_put_characters_to_console(u64 termno, u64 len,194u8 *buffer)195{196u64 b[2];197198memcpy(b, buffer, len);199return beat_hcall_norets(HV_put_characters_to_console, termno, len,200b[0], b[1]);201}202203static inline s64 beat_get_spe_privileged_state_1_registers(204u64 id, u64 offsetof, u64 *value)205{206u64 dummy[1];207s64 ret;208209ret = beat_hcall1(HV_get_spe_privileged_state_1_registers, dummy, id,210offsetof);211*value = dummy[0];212return ret;213}214215static inline s64 beat_set_irq_mask_for_spe(u64 id, u64 class, u64 mask)216{217return beat_hcall_norets(HV_set_irq_mask_for_spe, id, class, mask);218}219220static inline s64 beat_clear_interrupt_status_of_spe(u64 id, u64 class,221u64 mask)222{223return beat_hcall_norets(HV_clear_interrupt_status_of_spe,224id, class, mask);225}226227static inline s64 beat_set_spe_privileged_state_1_registers(228u64 id, u64 offsetof, u64 value)229{230return beat_hcall_norets(HV_set_spe_privileged_state_1_registers,231id, offsetof, value);232}233234static inline s64 beat_get_interrupt_status_of_spe(u64 id, u64 class, u64 *val)235{236u64 dummy[1];237s64 ret;238239ret = beat_hcall1(HV_get_interrupt_status_of_spe, dummy, id, class);240*val = dummy[0];241return ret;242}243244static inline s64 beat_put_iopte(u64 ioas_id, u64 io_addr, u64 real_addr,245u64 ioid, u64 flags)246{247return beat_hcall_norets(HV_put_iopte, ioas_id, io_addr, real_addr,248ioid, flags);249}250251static inline s64 beat_construct_event_receive_port(u64 *port)252{253u64 dummy[1];254s64 ret;255256ret = beat_hcall1(HV_construct_event_receive_port, dummy);257*port = dummy[0];258return ret;259}260261static inline s64 beat_destruct_event_receive_port(u64 port)262{263s64 ret;264265ret = beat_hcall_norets(HV_destruct_event_receive_port, port);266return ret;267}268269static inline s64 beat_create_repository_node(u64 path[4], u64 data[2])270{271s64 ret;272273ret = beat_hcall_norets(HV_create_repository_node2,274path[0], path[1], path[2], path[3], data[0], data[1]);275return ret;276}277278static inline s64 beat_get_repository_node_value(u64 lpid, u64 path[4],279u64 data[2])280{281s64 ret;282283ret = beat_hcall2(HV_get_repository_node_value2, data,284lpid, path[0], path[1], path[2], path[3]);285return ret;286}287288#endif289290291