Ishizaki Kou | b8a590c | 2007-02-02 16:36:27 +0900 | [diff] [blame] | 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 "beat_syscall.h" |
| 24 | |
| 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], ...); |
| 35 | |
| 36 | static inline s64 beat_downcount_of_interrupt(u64 plug_id) |
| 37 | { |
| 38 | return beat_hcall_norets(HV_downcount_of_interrupt, plug_id); |
| 39 | } |
| 40 | |
| 41 | static inline s64 beat_set_interrupt_mask(u64 index, |
| 42 | u64 val0, u64 val1, u64 val2, u64 val3) |
| 43 | { |
| 44 | return beat_hcall_norets(HV_set_interrupt_mask, index, |
| 45 | val0, val1, val2, val3); |
| 46 | } |
| 47 | |
| 48 | static inline s64 beat_destruct_irq_plug(u64 plug_id) |
| 49 | { |
| 50 | return beat_hcall_norets(HV_destruct_irq_plug, plug_id); |
| 51 | } |
| 52 | |
| 53 | static inline s64 beat_construct_and_connect_irq_plug(u64 plug_id, |
| 54 | u64 outlet_id) |
| 55 | { |
| 56 | return beat_hcall_norets(HV_construct_and_connect_irq_plug, plug_id, |
| 57 | outlet_id); |
| 58 | } |
| 59 | |
| 60 | static inline s64 beat_detect_pending_interrupts(u64 index, u64 *retbuf) |
| 61 | { |
| 62 | return beat_hcall4(HV_detect_pending_interrupts, retbuf, index); |
| 63 | } |
| 64 | |
| 65 | static inline s64 beat_pause(u64 style) |
| 66 | { |
| 67 | return beat_hcall_norets(HV_pause, style); |
| 68 | } |
| 69 | |
| 70 | static inline s64 beat_read_htab_entries(u64 htab_id, u64 index, u64 *retbuf) |
| 71 | { |
| 72 | return beat_hcall5(HV_read_htab_entries, retbuf, htab_id, index); |
| 73 | } |
| 74 | |
| 75 | static inline s64 beat_insert_htab_entry(u64 htab_id, u64 group, |
| 76 | u64 bitmask, u64 hpte_v, u64 hpte_r, u64 *slot) |
| 77 | { |
| 78 | u64 dummy[3]; |
| 79 | s64 ret; |
| 80 | |
| 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; |
| 85 | } |
| 86 | |
| 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) |
| 90 | { |
| 91 | u64 dummy[2]; |
| 92 | s64 ret; |
| 93 | |
| 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; |
| 99 | } |
| 100 | |
Ishizaki Kou | 7f2c857 | 2007-10-02 18:23:46 +1000 | [diff] [blame] | 101 | static inline s64 beat_insert_htab_entry3(u64 htab_id, u64 group, |
| 102 | u64 hpte_v, u64 hpte_r, u64 mask_v, u64 value_v, u64 *slot) |
| 103 | { |
| 104 | u64 dummy[1]; |
| 105 | s64 ret; |
| 106 | |
| 107 | ret = beat_hcall1(HV_insert_htab_entry3, dummy, htab_id, group, |
| 108 | hpte_v, hpte_r, mask_v, value_v); |
| 109 | *slot = dummy[0]; |
| 110 | return ret; |
| 111 | } |
| 112 | |
| 113 | static inline s64 beat_invalidate_htab_entry3(u64 htab_id, u64 group, |
| 114 | u64 va, u64 pss) |
| 115 | { |
| 116 | return beat_hcall_norets(HV_invalidate_htab_entry3, |
| 117 | htab_id, group, va, pss); |
| 118 | } |
| 119 | |
| 120 | static inline s64 beat_update_htab_permission3(u64 htab_id, u64 group, |
| 121 | u64 va, u64 pss, u64 ptel_mask, u64 ptel_value) |
| 122 | { |
| 123 | return beat_hcall_norets(HV_update_htab_permission3, |
| 124 | htab_id, group, va, pss, ptel_mask, ptel_value); |
| 125 | } |
| 126 | |
| 127 | static inline s64 beat_clear_htab3(u64 htab_id) |
| 128 | { |
| 129 | return beat_hcall_norets(HV_clear_htab3, htab_id); |
| 130 | } |
| 131 | |
Ishizaki Kou | b8a590c | 2007-02-02 16:36:27 +0900 | [diff] [blame] | 132 | static inline void beat_shutdown_logical_partition(u64 code) |
| 133 | { |
| 134 | (void)beat_hcall_norets(HV_shutdown_logical_partition, code); |
| 135 | } |
| 136 | |
| 137 | static inline s64 beat_rtc_write(u64 time_from_epoch) |
| 138 | { |
| 139 | return beat_hcall_norets(HV_rtc_write, time_from_epoch); |
| 140 | } |
| 141 | |
| 142 | static inline s64 beat_rtc_read(u64 *time_from_epoch) |
| 143 | { |
| 144 | u64 dummy[1]; |
| 145 | s64 ret; |
| 146 | |
| 147 | ret = beat_hcall1(HV_rtc_read, dummy); |
| 148 | *time_from_epoch = dummy[0]; |
| 149 | return ret; |
| 150 | } |
| 151 | |
| 152 | #define BEAT_NVRW_CNT (sizeof(u64) * 6) |
| 153 | |
| 154 | static inline s64 beat_eeprom_write(u64 index, u64 length, u8 *buffer) |
| 155 | { |
| 156 | u64 b[6]; |
| 157 | |
| 158 | if (length > BEAT_NVRW_CNT) |
| 159 | return -1; |
| 160 | memcpy(b, buffer, sizeof(b)); |
| 161 | return beat_hcall_norets8(HV_eeprom_write, index, length, |
| 162 | b[0], b[1], b[2], b[3], b[4], b[5]); |
| 163 | } |
| 164 | |
| 165 | static inline s64 beat_eeprom_read(u64 index, u64 length, u8 *buffer) |
| 166 | { |
| 167 | u64 b[6]; |
| 168 | s64 ret; |
| 169 | |
| 170 | if (length > BEAT_NVRW_CNT) |
| 171 | return -1; |
| 172 | ret = beat_hcall6(HV_eeprom_read, b, index, length); |
| 173 | memcpy(buffer, b, length); |
| 174 | return ret; |
| 175 | } |
| 176 | |
| 177 | static inline s64 beat_set_dabr(u64 value, u64 style) |
| 178 | { |
| 179 | return beat_hcall_norets(HV_set_dabr, value, style); |
| 180 | } |
| 181 | |
| 182 | static inline s64 beat_get_characters_from_console(u64 termno, u64 *len, |
| 183 | u8 *buffer) |
| 184 | { |
| 185 | u64 dummy[3]; |
| 186 | s64 ret; |
| 187 | |
| 188 | ret = beat_hcall3(HV_get_characters_from_console, dummy, termno, len); |
| 189 | *len = dummy[0]; |
| 190 | memcpy(buffer, dummy + 1, *len); |
| 191 | return ret; |
| 192 | } |
| 193 | |
| 194 | static inline s64 beat_put_characters_to_console(u64 termno, u64 len, |
| 195 | u8 *buffer) |
| 196 | { |
| 197 | u64 b[2]; |
| 198 | |
| 199 | memcpy(b, buffer, len); |
Ishizaki Kou | 2fe37a6 | 2008-03-14 23:19:34 +1100 | [diff] [blame] | 200 | return beat_hcall_norets(HV_put_characters_to_console, termno, len, |
| 201 | b[0], b[1]); |
Ishizaki Kou | b8a590c | 2007-02-02 16:36:27 +0900 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | static inline s64 beat_get_spe_privileged_state_1_registers( |
| 205 | u64 id, u64 offsetof, u64 *value) |
| 206 | { |
| 207 | u64 dummy[1]; |
| 208 | s64 ret; |
| 209 | |
| 210 | ret = beat_hcall1(HV_get_spe_privileged_state_1_registers, dummy, id, |
| 211 | offsetof); |
| 212 | *value = dummy[0]; |
| 213 | return ret; |
| 214 | } |
| 215 | |
| 216 | static inline s64 beat_set_irq_mask_for_spe(u64 id, u64 class, u64 mask) |
| 217 | { |
| 218 | return beat_hcall_norets(HV_set_irq_mask_for_spe, id, class, mask); |
| 219 | } |
| 220 | |
| 221 | static inline s64 beat_clear_interrupt_status_of_spe(u64 id, u64 class, |
| 222 | u64 mask) |
| 223 | { |
| 224 | return beat_hcall_norets(HV_clear_interrupt_status_of_spe, |
| 225 | id, class, mask); |
| 226 | } |
| 227 | |
| 228 | static inline s64 beat_set_spe_privileged_state_1_registers( |
| 229 | u64 id, u64 offsetof, u64 value) |
| 230 | { |
| 231 | return beat_hcall_norets(HV_set_spe_privileged_state_1_registers, |
| 232 | id, offsetof, value); |
| 233 | } |
| 234 | |
| 235 | static inline s64 beat_get_interrupt_status_of_spe(u64 id, u64 class, u64 *val) |
| 236 | { |
| 237 | u64 dummy[1]; |
| 238 | s64 ret; |
| 239 | |
| 240 | ret = beat_hcall1(HV_get_interrupt_status_of_spe, dummy, id, class); |
| 241 | *val = dummy[0]; |
| 242 | return ret; |
| 243 | } |
| 244 | |
| 245 | static inline s64 beat_put_iopte(u64 ioas_id, u64 io_addr, u64 real_addr, |
| 246 | u64 ioid, u64 flags) |
| 247 | { |
| 248 | return beat_hcall_norets(HV_put_iopte, ioas_id, io_addr, real_addr, |
| 249 | ioid, flags); |
| 250 | } |
| 251 | |
Ishizaki Kou | 7f2c857 | 2007-10-02 18:23:46 +1000 | [diff] [blame] | 252 | static inline s64 beat_construct_event_receive_port(u64 *port) |
| 253 | { |
| 254 | u64 dummy[1]; |
| 255 | s64 ret; |
| 256 | |
| 257 | ret = beat_hcall1(HV_construct_event_receive_port, dummy); |
| 258 | *port = dummy[0]; |
| 259 | return ret; |
| 260 | } |
| 261 | |
| 262 | static inline s64 beat_destruct_event_receive_port(u64 port) |
| 263 | { |
| 264 | s64 ret; |
| 265 | |
| 266 | ret = beat_hcall_norets(HV_destruct_event_receive_port, port); |
| 267 | return ret; |
| 268 | } |
| 269 | |
| 270 | static inline s64 beat_create_repository_node(u64 path[4], u64 data[2]) |
| 271 | { |
| 272 | s64 ret; |
| 273 | |
| 274 | ret = beat_hcall_norets(HV_create_repository_node2, |
| 275 | path[0], path[1], path[2], path[3], data[0], data[1]); |
| 276 | return ret; |
| 277 | } |
| 278 | |
| 279 | static inline s64 beat_get_repository_node_value(u64 lpid, u64 path[4], |
| 280 | u64 data[2]) |
| 281 | { |
| 282 | s64 ret; |
| 283 | |
| 284 | ret = beat_hcall2(HV_get_repository_node_value2, data, |
| 285 | lpid, path[0], path[1], path[2], path[3]); |
| 286 | return ret; |
| 287 | } |
| 288 | |
Ishizaki Kou | b8a590c | 2007-02-02 16:36:27 +0900 | [diff] [blame] | 289 | #endif |