e1000: remove old compatibility code
[qemu/kevin.git] / target / ppc / kvm_ppc.h
blob6a4dd9c5608baffcef292aa5e564cf4ab76272cc
1 /*
2 * Copyright 2008 IBM Corporation.
3 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
5 * This work is licensed under the GNU GPL license version 2 or later.
7 */
9 #ifndef KVM_PPC_H
10 #define KVM_PPC_H
12 #include "sysemu/kvm.h"
13 #include "exec/hwaddr.h"
14 #include "cpu.h"
16 #ifdef CONFIG_KVM
18 uint32_t kvmppc_get_tbfreq(void);
19 uint64_t kvmppc_get_clockfreq(void);
20 bool kvmppc_get_host_model(char **buf);
21 bool kvmppc_get_host_serial(char **buf);
22 int kvmppc_get_hasidle(CPUPPCState *env);
23 int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len);
24 int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level);
25 void kvmppc_enable_logical_ci_hcalls(void);
26 void kvmppc_enable_set_mode_hcall(void);
27 void kvmppc_enable_clear_ref_mod_hcalls(void);
28 void kvmppc_enable_h_page_init(void);
29 void kvmppc_enable_h_rpt_invalidate(void);
30 void kvmppc_set_papr(PowerPCCPU *cpu);
31 int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr);
32 void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
33 bool kvmppc_get_fwnmi(void);
34 int kvmppc_set_fwnmi(PowerPCCPU *cpu);
35 int kvmppc_smt_threads(void);
36 void kvmppc_error_append_smt_possible_hint(Error *const *errp);
37 int kvmppc_set_smt_threads(int smt);
38 int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
39 int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
40 int kvmppc_set_tcr(PowerPCCPU *cpu);
41 int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
42 target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
43 bool radix, bool gtse,
44 uint64_t proc_tbl);
45 bool kvmppc_spapr_use_multitce(void);
46 int kvmppc_spapr_enable_inkernel_multitce(void);
47 void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift,
48 uint64_t bus_offset, uint32_t nb_table,
49 int *pfd, bool need_vfio);
50 int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
51 int kvmppc_reset_htab(int shift_hint);
52 uint64_t kvmppc_vrma_limit(unsigned int hash_shift);
53 bool kvmppc_has_cap_spapr_vfio(void);
54 bool kvmppc_has_cap_epr(void);
55 int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function);
56 int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp);
57 int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns);
58 int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
59 uint16_t n_valid, uint16_t n_invalid, Error **errp);
60 void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n);
61 void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1);
62 bool kvmppc_has_cap_fixup_hcalls(void);
63 bool kvmppc_has_cap_htm(void);
64 bool kvmppc_has_cap_mmu_radix(void);
65 bool kvmppc_has_cap_mmu_hash_v3(void);
66 bool kvmppc_has_cap_xive(void);
67 int kvmppc_get_cap_safe_cache(void);
68 int kvmppc_get_cap_safe_bounds_check(void);
69 int kvmppc_get_cap_safe_indirect_branch(void);
70 int kvmppc_get_cap_count_cache_flush_assist(void);
71 bool kvmppc_has_cap_nested_kvm_hv(void);
72 int kvmppc_set_cap_nested_kvm_hv(int enable);
73 int kvmppc_get_cap_large_decr(void);
74 int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable);
75 int kvmppc_has_cap_rpt_invalidate(void);
76 bool kvmppc_supports_ail_3(void);
77 int kvmppc_enable_hwrng(void);
78 int kvmppc_put_books_sregs(PowerPCCPU *cpu);
79 PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void);
80 void kvmppc_check_papr_resize_hpt(Error **errp);
81 int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shift);
82 int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift);
83 bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu);
85 bool kvmppc_hpt_needs_host_contiguous_pages(void);
86 void kvm_check_mmu(PowerPCCPU *cpu, Error **errp);
87 void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online);
88 void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset);
90 int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);
92 #define kvmppc_eieio() \
93 do { \
94 if (kvm_enabled()) { \
95 asm volatile("eieio" : : : "memory"); \
96 } \
97 } while (0)
99 /* Store data cache blocks back to memory */
100 static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
102 uint8_t *p;
104 for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) {
105 asm volatile("dcbst 0,%0" : : "r"(p) : "memory");
109 /* Invalidate instruction cache blocks */
110 static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
112 uint8_t *p;
114 for (p = addr; p < addr + len; p += cpu->env.icache_line_size) {
115 asm volatile("icbi 0,%0" : : "r"(p));
119 #else /* !CONFIG_KVM */
121 static inline uint32_t kvmppc_get_tbfreq(void)
123 return 0;
126 static inline bool kvmppc_get_host_model(char **buf)
128 return false;
131 static inline bool kvmppc_get_host_serial(char **buf)
133 return false;
136 static inline uint64_t kvmppc_get_clockfreq(void)
138 return 0;
141 static inline uint32_t kvmppc_get_vmx(void)
143 return 0;
146 static inline uint32_t kvmppc_get_dfp(void)
148 return 0;
151 static inline int kvmppc_get_hasidle(CPUPPCState *env)
153 return 0;
156 static inline int kvmppc_get_hypercall(CPUPPCState *env,
157 uint8_t *buf, int buf_len)
159 return -1;
162 static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level)
164 return -1;
167 static inline void kvmppc_enable_logical_ci_hcalls(void)
171 static inline void kvmppc_enable_set_mode_hcall(void)
175 static inline void kvmppc_enable_clear_ref_mod_hcalls(void)
179 static inline void kvmppc_enable_h_page_init(void)
183 static inline void kvmppc_enable_h_rpt_invalidate(void)
185 g_assert_not_reached();
188 static inline void kvmppc_set_papr(PowerPCCPU *cpu)
192 static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr)
194 return 0;
197 static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
201 static inline bool kvmppc_get_fwnmi(void)
203 return false;
206 static inline int kvmppc_set_fwnmi(PowerPCCPU *cpu)
208 return -1;
211 static inline int kvmppc_smt_threads(void)
213 return 1;
216 static inline void kvmppc_error_append_smt_possible_hint(Error *const *errp)
218 return;
221 static inline int kvmppc_set_smt_threads(int smt)
223 return 0;
226 static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
228 return 0;
231 static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
233 return 0;
236 static inline int kvmppc_set_tcr(PowerPCCPU *cpu)
238 return 0;
241 static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu)
243 return -1;
246 static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
247 bool radix, bool gtse,
248 uint64_t proc_tbl)
250 return 0;
253 static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu,
254 unsigned int online)
256 return;
259 static inline void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset)
263 static inline bool kvmppc_spapr_use_multitce(void)
265 return false;
268 static inline int kvmppc_spapr_enable_inkernel_multitce(void)
270 return -1;
273 static inline void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift,
274 uint64_t bus_offset,
275 uint32_t nb_table,
276 int *pfd, bool need_vfio)
278 return NULL;
281 static inline int kvmppc_remove_spapr_tce(void *table, int pfd,
282 uint32_t nb_table)
284 return -1;
287 static inline int kvmppc_reset_htab(int shift_hint)
289 return 0;
292 static inline uint64_t kvmppc_vrma_limit(unsigned int hash_shift)
294 g_assert_not_reached();
297 static inline bool kvmppc_hpt_needs_host_contiguous_pages(void)
299 return false;
302 static inline void kvm_check_mmu(PowerPCCPU *cpu, Error **errp)
306 static inline bool kvmppc_has_cap_spapr_vfio(void)
308 return false;
311 static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes,
312 hwaddr ptex, int n)
314 abort();
317 static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1)
319 abort();
322 static inline bool kvmppc_has_cap_epr(void)
324 return false;
327 static inline int kvmppc_define_rtas_kernel_token(uint32_t token,
328 const char *function)
330 return -1;
333 static inline int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp)
335 return -1;
338 static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize,
339 int64_t max_ns)
341 abort();
344 static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
345 uint16_t n_valid, uint16_t n_invalid,
346 Error **errp)
348 abort();
351 static inline bool kvmppc_has_cap_fixup_hcalls(void)
353 abort();
356 static inline bool kvmppc_has_cap_htm(void)
358 return false;
361 static inline bool kvmppc_has_cap_mmu_radix(void)
363 return false;
366 static inline bool kvmppc_has_cap_mmu_hash_v3(void)
368 return false;
371 static inline bool kvmppc_has_cap_xive(void)
373 return false;
376 static inline int kvmppc_get_cap_safe_cache(void)
378 return 0;
381 static inline int kvmppc_get_cap_safe_bounds_check(void)
383 return 0;
386 static inline int kvmppc_get_cap_safe_indirect_branch(void)
388 return 0;
391 static inline int kvmppc_get_cap_count_cache_flush_assist(void)
393 return 0;
396 static inline bool kvmppc_has_cap_nested_kvm_hv(void)
398 return false;
401 static inline int kvmppc_set_cap_nested_kvm_hv(int enable)
403 return -1;
406 static inline int kvmppc_get_cap_large_decr(void)
408 return 0;
411 static inline int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable)
413 return -1;
416 static inline int kvmppc_has_cap_rpt_invalidate(void)
418 return false;
421 static inline bool kvmppc_supports_ail_3(void)
423 return false;
426 static inline int kvmppc_enable_hwrng(void)
428 return -1;
431 static inline int kvmppc_put_books_sregs(PowerPCCPU *cpu)
433 abort();
436 static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
438 return NULL;
441 static inline void kvmppc_check_papr_resize_hpt(Error **errp)
443 return;
446 static inline int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu,
447 target_ulong flags, int shift)
449 return -ENOSYS;
452 static inline int kvmppc_resize_hpt_commit(PowerPCCPU *cpu,
453 target_ulong flags, int shift)
455 return -ENOSYS;
458 static inline bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu)
460 return false;
463 #define kvmppc_eieio() do { } while (0)
465 static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
469 static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
473 #endif /* CONFIG_KVM */
475 #endif /* KVM_PPC_H */