Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
beat_wrapper.h
Go to the documentation of this file.
1 /*
2  * Beat hypervisor call I/F
3  *
4  * (C) Copyright 2007 TOSHIBA CORPORATION
5  *
6  * This code is based on arch/powerpc/platforms/pseries/plpar_wrapper.h.
7  *
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.
12  *
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.
17  *
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.
21  */
22 #ifndef BEAT_HCALL
23 #include <linux/string.h>
24 #include "beat_syscall.h"
25 
26 /* defined in hvCall.S */
27 extern s64 beat_hcall_norets(u64 opcode, ...);
29  u64 arg4, u64 arg5, u64 arg6, u64 arg7, u64 arg8);
30 extern s64 beat_hcall1(u64 opcode, u64 retbuf[1], ...);
31 extern s64 beat_hcall2(u64 opcode, u64 retbuf[2], ...);
32 extern s64 beat_hcall3(u64 opcode, u64 retbuf[3], ...);
33 extern s64 beat_hcall4(u64 opcode, u64 retbuf[4], ...);
34 extern s64 beat_hcall5(u64 opcode, u64 retbuf[5], ...);
35 extern s64 beat_hcall6(u64 opcode, u64 retbuf[6], ...);
36 
37 static inline s64 beat_downcount_of_interrupt(u64 plug_id)
38 {
40 }
41 
42 static inline s64 beat_set_interrupt_mask(u64 index,
43  u64 val0, u64 val1, u64 val2, u64 val3)
44 {
46  val0, val1, val2, val3);
47 }
48 
49 static inline s64 beat_destruct_irq_plug(u64 plug_id)
50 {
51  return beat_hcall_norets(HV_destruct_irq_plug, plug_id);
52 }
53 
54 static inline s64 beat_construct_and_connect_irq_plug(u64 plug_id,
55  u64 outlet_id)
56 {
58  outlet_id);
59 }
60 
61 static inline s64 beat_detect_pending_interrupts(u64 index, u64 *retbuf)
62 {
63  return beat_hcall4(HV_detect_pending_interrupts, retbuf, index);
64 }
65 
66 static inline s64 beat_pause(u64 style)
67 {
68  return beat_hcall_norets(HV_pause, style);
69 }
70 
71 static inline s64 beat_read_htab_entries(u64 htab_id, u64 index, u64 *retbuf)
72 {
73  return beat_hcall5(HV_read_htab_entries, retbuf, htab_id, index);
74 }
75 
76 static inline s64 beat_insert_htab_entry(u64 htab_id, u64 group,
77  u64 bitmask, u64 hpte_v, u64 hpte_r, u64 *slot)
78 {
79  u64 dummy[3];
80  s64 ret;
81 
82  ret = beat_hcall3(HV_insert_htab_entry, dummy, htab_id, group,
83  bitmask, hpte_v, hpte_r);
84  *slot = dummy[0];
85  return ret;
86 }
87 
88 static inline s64 beat_write_htab_entry(u64 htab_id, u64 slot,
89  u64 hpte_v, u64 hpte_r, u64 mask_v, u64 mask_r,
90  u64 *ret_v, u64 *ret_r)
91 {
92  u64 dummy[2];
93  s64 ret;
94 
95  ret = beat_hcall2(HV_write_htab_entry, dummy, htab_id, slot,
96  hpte_v, hpte_r, mask_v, mask_r);
97  *ret_v = dummy[0];
98  *ret_r = dummy[1];
99  return ret;
100 }
101 
102 static inline s64 beat_insert_htab_entry3(u64 htab_id, u64 group,
103  u64 hpte_v, u64 hpte_r, u64 mask_v, u64 value_v, u64 *slot)
104 {
105  u64 dummy[1];
106  s64 ret;
107 
108  ret = beat_hcall1(HV_insert_htab_entry3, dummy, htab_id, group,
109  hpte_v, hpte_r, mask_v, value_v);
110  *slot = dummy[0];
111  return ret;
112 }
113 
114 static inline s64 beat_invalidate_htab_entry3(u64 htab_id, u64 group,
115  u64 va, u64 pss)
116 {
118  htab_id, group, va, pss);
119 }
120 
121 static inline s64 beat_update_htab_permission3(u64 htab_id, u64 group,
122  u64 va, u64 pss, u64 ptel_mask, u64 ptel_value)
123 {
125  htab_id, group, va, pss, ptel_mask, ptel_value);
126 }
127 
128 static inline s64 beat_clear_htab3(u64 htab_id)
129 {
130  return beat_hcall_norets(HV_clear_htab3, htab_id);
131 }
132 
133 static inline void beat_shutdown_logical_partition(u64 code)
134 {
136 }
137 
138 static inline s64 beat_rtc_write(u64 time_from_epoch)
139 {
140  return beat_hcall_norets(HV_rtc_write, time_from_epoch);
141 }
142 
143 static inline s64 beat_rtc_read(u64 *time_from_epoch)
144 {
145  u64 dummy[1];
146  s64 ret;
147 
148  ret = beat_hcall1(HV_rtc_read, dummy);
149  *time_from_epoch = dummy[0];
150  return ret;
151 }
152 
153 #define BEAT_NVRW_CNT (sizeof(u64) * 6)
154 
155 static inline s64 beat_eeprom_write(u64 index, u64 length, u8 *buffer)
156 {
157  u64 b[6];
158 
159  if (length > BEAT_NVRW_CNT)
160  return -1;
161  memcpy(b, buffer, sizeof(b));
162  return beat_hcall_norets8(HV_eeprom_write, index, length,
163  b[0], b[1], b[2], b[3], b[4], b[5]);
164 }
165 
166 static inline s64 beat_eeprom_read(u64 index, u64 length, u8 *buffer)
167 {
168  u64 b[6];
169  s64 ret;
170 
171  if (length > BEAT_NVRW_CNT)
172  return -1;
173  ret = beat_hcall6(HV_eeprom_read, b, index, length);
174  memcpy(buffer, b, length);
175  return ret;
176 }
177 
178 static inline s64 beat_set_dabr(u64 value, u64 style)
179 {
180  return beat_hcall_norets(HV_set_dabr, value, style);
181 }
182 
183 static inline s64 beat_get_characters_from_console(u64 termno, u64 *len,
184  u8 *buffer)
185 {
186  u64 dummy[3];
187  s64 ret;
188 
189  ret = beat_hcall3(HV_get_characters_from_console, dummy, termno, len);
190  *len = dummy[0];
191  memcpy(buffer, dummy + 1, *len);
192  return ret;
193 }
194 
195 static inline s64 beat_put_characters_to_console(u64 termno, u64 len,
196  u8 *buffer)
197 {
198  u64 b[2];
199 
200  memcpy(b, buffer, len);
202  b[0], b[1]);
203 }
204 
205 static inline s64 beat_get_spe_privileged_state_1_registers(
206  u64 id, u64 offsetof, u64 *value)
207 {
208  u64 dummy[1];
209  s64 ret;
210 
212  offsetof);
213  *value = dummy[0];
214  return ret;
215 }
216 
217 static inline s64 beat_set_irq_mask_for_spe(u64 id, u64 class, u64 mask)
218 {
219  return beat_hcall_norets(HV_set_irq_mask_for_spe, id, class, mask);
220 }
221 
222 static inline s64 beat_clear_interrupt_status_of_spe(u64 id, u64 class,
223  u64 mask)
224 {
226  id, class, mask);
227 }
228 
229 static inline s64 beat_set_spe_privileged_state_1_registers(
230  u64 id, u64 offsetof, u64 value)
231 {
233  id, offsetof, value);
234 }
235 
236 static inline s64 beat_get_interrupt_status_of_spe(u64 id, u64 class, u64 *val)
237 {
238  u64 dummy[1];
239  s64 ret;
240 
241  ret = beat_hcall1(HV_get_interrupt_status_of_spe, dummy, id, class);
242  *val = dummy[0];
243  return ret;
244 }
245 
246 static inline s64 beat_put_iopte(u64 ioas_id, u64 io_addr, u64 real_addr,
247  u64 ioid, u64 flags)
248 {
249  return beat_hcall_norets(HV_put_iopte, ioas_id, io_addr, real_addr,
250  ioid, flags);
251 }
252 
253 static inline s64 beat_construct_event_receive_port(u64 *port)
254 {
255  u64 dummy[1];
256  s64 ret;
257 
259  *port = dummy[0];
260  return ret;
261 }
262 
263 static inline s64 beat_destruct_event_receive_port(u64 port)
264 {
265  s64 ret;
266 
268  return ret;
269 }
270 
271 static inline s64 beat_create_repository_node(u64 path[4], u64 data[2])
272 {
273  s64 ret;
274 
276  path[0], path[1], path[2], path[3], data[0], data[1]);
277  return ret;
278 }
279 
280 static inline s64 beat_get_repository_node_value(u64 lpid, u64 path[4],
281  u64 data[2])
282 {
283  s64 ret;
284 
286  lpid, path[0], path[1], path[2], path[3]);
287  return ret;
288 }
289 
290 #endif