Linux 2.6.21
[linux/fpc-iii.git] / arch / powerpc / platforms / celleb / beat_wrapper.h
blob76ea0a6a90118802785e10b9b571e3f30f9b47f9
1 /*
2 * Beat hypervisor call I/F
4 * (C) Copyright 2007 TOSHIBA CORPORATION
6 * This code is based on arch/powerpc/platforms/pseries/plpar_wrapper.h.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef BEAT_HCALL
23 #include "beat_syscall.h"
25 /* defined in hvCall.S */
26 extern s64 beat_hcall_norets(u64 opcode, ...);
27 extern s64 beat_hcall_norets8(u64 opcode, u64 arg1, u64 arg2, u64 arg3,
28 u64 arg4, u64 arg5, u64 arg6, u64 arg7, u64 arg8);
29 extern s64 beat_hcall1(u64 opcode, u64 retbuf[1], ...);
30 extern s64 beat_hcall2(u64 opcode, u64 retbuf[2], ...);
31 extern s64 beat_hcall3(u64 opcode, u64 retbuf[3], ...);
32 extern s64 beat_hcall4(u64 opcode, u64 retbuf[4], ...);
33 extern s64 beat_hcall5(u64 opcode, u64 retbuf[5], ...);
34 extern s64 beat_hcall6(u64 opcode, u64 retbuf[6], ...);
36 static inline s64 beat_downcount_of_interrupt(u64 plug_id)
38 return beat_hcall_norets(HV_downcount_of_interrupt, plug_id);
41 static inline s64 beat_set_interrupt_mask(u64 index,
42 u64 val0, u64 val1, u64 val2, u64 val3)
44 return beat_hcall_norets(HV_set_interrupt_mask, index,
45 val0, val1, val2, val3);
48 static inline s64 beat_destruct_irq_plug(u64 plug_id)
50 return beat_hcall_norets(HV_destruct_irq_plug, plug_id);
53 static inline s64 beat_construct_and_connect_irq_plug(u64 plug_id,
54 u64 outlet_id)
56 return beat_hcall_norets(HV_construct_and_connect_irq_plug, plug_id,
57 outlet_id);
60 static inline s64 beat_detect_pending_interrupts(u64 index, u64 *retbuf)
62 return beat_hcall4(HV_detect_pending_interrupts, retbuf, index);
65 static inline s64 beat_pause(u64 style)
67 return beat_hcall_norets(HV_pause, style);
70 static inline s64 beat_read_htab_entries(u64 htab_id, u64 index, u64 *retbuf)
72 return beat_hcall5(HV_read_htab_entries, retbuf, htab_id, index);
75 static inline s64 beat_insert_htab_entry(u64 htab_id, u64 group,
76 u64 bitmask, u64 hpte_v, u64 hpte_r, u64 *slot)
78 u64 dummy[3];
79 s64 ret;
81 ret = beat_hcall3(HV_insert_htab_entry, dummy, htab_id, group,
82 bitmask, hpte_v, hpte_r);
83 *slot = dummy[0];
84 return ret;
87 static inline s64 beat_write_htab_entry(u64 htab_id, u64 slot,
88 u64 hpte_v, u64 hpte_r, u64 mask_v, u64 mask_r,
89 u64 *ret_v, u64 *ret_r)
91 u64 dummy[2];
92 s64 ret;
94 ret = beat_hcall2(HV_write_htab_entry, dummy, htab_id, slot,
95 hpte_v, hpte_r, mask_v, mask_r);
96 *ret_v = dummy[0];
97 *ret_r = dummy[1];
98 return ret;
101 static inline void beat_shutdown_logical_partition(u64 code)
103 (void)beat_hcall_norets(HV_shutdown_logical_partition, code);
106 static inline s64 beat_rtc_write(u64 time_from_epoch)
108 return beat_hcall_norets(HV_rtc_write, time_from_epoch);
111 static inline s64 beat_rtc_read(u64 *time_from_epoch)
113 u64 dummy[1];
114 s64 ret;
116 ret = beat_hcall1(HV_rtc_read, dummy);
117 *time_from_epoch = dummy[0];
118 return ret;
121 #define BEAT_NVRW_CNT (sizeof(u64) * 6)
123 static inline s64 beat_eeprom_write(u64 index, u64 length, u8 *buffer)
125 u64 b[6];
127 if (length > BEAT_NVRW_CNT)
128 return -1;
129 memcpy(b, buffer, sizeof(b));
130 return beat_hcall_norets8(HV_eeprom_write, index, length,
131 b[0], b[1], b[2], b[3], b[4], b[5]);
134 static inline s64 beat_eeprom_read(u64 index, u64 length, u8 *buffer)
136 u64 b[6];
137 s64 ret;
139 if (length > BEAT_NVRW_CNT)
140 return -1;
141 ret = beat_hcall6(HV_eeprom_read, b, index, length);
142 memcpy(buffer, b, length);
143 return ret;
146 static inline s64 beat_set_dabr(u64 value, u64 style)
148 return beat_hcall_norets(HV_set_dabr, value, style);
151 static inline s64 beat_get_characters_from_console(u64 termno, u64 *len,
152 u8 *buffer)
154 u64 dummy[3];
155 s64 ret;
157 ret = beat_hcall3(HV_get_characters_from_console, dummy, termno, len);
158 *len = dummy[0];
159 memcpy(buffer, dummy + 1, *len);
160 return ret;
163 static inline s64 beat_put_characters_to_console(u64 termno, u64 len,
164 u8 *buffer)
166 u64 b[2];
168 memcpy(b, buffer, len);
169 return beat_hcall_norets(HV_put_characters_to_console, termno, len, b[0], b[1]);
172 static inline s64 beat_get_spe_privileged_state_1_registers(
173 u64 id, u64 offsetof, u64 *value)
175 u64 dummy[1];
176 s64 ret;
178 ret = beat_hcall1(HV_get_spe_privileged_state_1_registers, dummy, id,
179 offsetof);
180 *value = dummy[0];
181 return ret;
184 static inline s64 beat_set_irq_mask_for_spe(u64 id, u64 class, u64 mask)
186 return beat_hcall_norets(HV_set_irq_mask_for_spe, id, class, mask);
189 static inline s64 beat_clear_interrupt_status_of_spe(u64 id, u64 class,
190 u64 mask)
192 return beat_hcall_norets(HV_clear_interrupt_status_of_spe,
193 id, class, mask);
196 static inline s64 beat_set_spe_privileged_state_1_registers(
197 u64 id, u64 offsetof, u64 value)
199 return beat_hcall_norets(HV_set_spe_privileged_state_1_registers,
200 id, offsetof, value);
203 static inline s64 beat_get_interrupt_status_of_spe(u64 id, u64 class, u64 *val)
205 u64 dummy[1];
206 s64 ret;
208 ret = beat_hcall1(HV_get_interrupt_status_of_spe, dummy, id, class);
209 *val = dummy[0];
210 return ret;
213 static inline s64 beat_put_iopte(u64 ioas_id, u64 io_addr, u64 real_addr,
214 u64 ioid, u64 flags)
216 return beat_hcall_norets(HV_put_iopte, ioas_id, io_addr, real_addr,
217 ioid, flags);
220 #endif