kvm_ppc.h 5.9 KB
Newer Older
A
aurel32 已提交
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright 2008 IBM Corporation.
 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
 *
 * This work is licensed under the GNU GPL license version 2 or later.
 *
 */

#ifndef __KVM_PPC_H__
#define __KVM_PPC_H__

12 13
#define TYPE_HOST_POWERPC_CPU "host-" TYPE_POWERPC_CPU

A
aurel32 已提交
14 15
void kvmppc_init(void);

16 17
#ifdef CONFIG_KVM

18
uint32_t kvmppc_get_tbfreq(void);
19
uint64_t kvmppc_get_clockfreq(void);
20 21
uint32_t kvmppc_get_vmx(void);
uint32_t kvmppc_get_dfp(void);
22
int kvmppc_get_hasidle(CPUPPCState *env);
23
int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len);
24 25
int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level);
void kvmppc_set_papr(PowerPCCPU *cpu);
26
int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
27
void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
28
int kvmppc_smt_threads(void);
B
Bharat Bhushan 已提交
29 30 31 32
int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
int kvmppc_set_tcr(PowerPCCPU *cpu);
int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
D
David Gibson 已提交
33
#ifndef CONFIG_USER_ONLY
34
off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem);
35
bool kvmppc_spapr_use_multitce(void);
36 37
void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd,
                              bool vfio_accel);
38
int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
39 40
int kvmppc_reset_htab(int shift_hint);
uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift);
D
David Gibson 已提交
41
#endif /* !CONFIG_USER_ONLY */
42
bool kvmppc_has_cap_epr(void);
43
int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function);
44
bool kvmppc_has_cap_htab_fd(void);
45 46 47 48
int kvmppc_get_htab_fd(bool write);
int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns);
int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
                           uint16_t n_valid, uint16_t n_invalid);
49 50
uint64_t kvmppc_hash64_read_pteg(PowerPCCPU *cpu, target_ulong pte_index);
void kvmppc_hash64_free_pteg(uint64_t token);
51

52 53
void kvmppc_hash64_write_pte(CPUPPCState *env, target_ulong pte_index,
                             target_ulong pte0, target_ulong pte1);
54
bool kvmppc_has_cap_fixup_hcalls(void);
55

56 57 58 59 60 61 62 63 64 65 66 67
#else

static inline uint32_t kvmppc_get_tbfreq(void)
{
    return 0;
}

static inline uint64_t kvmppc_get_clockfreq(void)
{
    return 0;
}

68 69 70 71 72 73 74 75 76 77
static inline uint32_t kvmppc_get_vmx(void)
{
    return 0;
}

static inline uint32_t kvmppc_get_dfp(void)
{
    return 0;
}

78 79 80 81 82
static inline int kvmppc_get_hasidle(CPUPPCState *env)
{
    return 0;
}

83
static inline int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len)
84 85 86 87
{
    return -1;
}

88 89 90 91 92
static inline int kvmppc_read_segment_page_sizes(uint32_t *prop, int maxcells)
{
    return -1;
}

93
static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level)
94 95 96 97
{
    return -1;
}

98
static inline void kvmppc_set_papr(PowerPCCPU *cpu)
99 100 101
{
}

102 103 104 105 106
static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version)
{
    return 0;
}

107 108 109 110
static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
{
}

111 112 113 114 115
static inline int kvmppc_smt_threads(void)
{
    return 1;
}

B
Bharat Bhushan 已提交
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
{
    return 0;
}

static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
{
    return 0;
}

static inline int kvmppc_set_tcr(PowerPCCPU *cpu)
{
    return 0;
}

static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu)
{
    return -1;
}

D
David Gibson 已提交
136
#ifndef CONFIG_USER_ONLY
137 138 139 140 141
static inline off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem)
{
    return 0;
}

142 143 144 145 146
static inline bool kvmppc_spapr_use_multitce(void)
{
    return false;
}

147
static inline void *kvmppc_create_spapr_tce(uint32_t liobn,
148 149
                                            uint32_t window_size, int *fd,
                                            bool vfio_accel)
150 151 152 153 154
{
    return NULL;
}

static inline int kvmppc_remove_spapr_tce(void *table, int pfd,
155
                                          uint32_t nb_table)
156 157 158
{
    return -1;
}
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175

static inline int kvmppc_reset_htab(int shift_hint)
{
    return -1;
}

static inline uint64_t kvmppc_rma_size(uint64_t current_size,
                                       unsigned int hash_shift)
{
    return ram_size;
}

static inline int kvmppc_update_sdr1(CPUPPCState *env)
{
    return 0;
}

D
David Gibson 已提交
176
#endif /* !CONFIG_USER_ONLY */
177

178 179 180 181
static inline bool kvmppc_has_cap_epr(void)
{
    return false;
}
182

183 184 185 186 187 188
static inline int kvmppc_define_rtas_kernel_token(uint32_t token,
                                                  const char *function)
{
    return -1;
}

189 190 191 192 193
static inline bool kvmppc_has_cap_htab_fd(void)
{
    return false;
}

194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
static inline int kvmppc_get_htab_fd(bool write)
{
    return -1;
}

static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize,
                                   int64_t max_ns)
{
    abort();
}

static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
                                         uint16_t n_valid, uint16_t n_invalid)
{
    abort();
}

211 212 213 214 215 216 217 218 219 220 221
static inline uint64_t kvmppc_hash64_read_pteg(PowerPCCPU *cpu,
                                               target_ulong pte_index)
{
    abort();
}

static inline void kvmppc_hash64_free_pteg(uint64_t token)
{
    abort();
}

222 223 224 225 226 227 228
static inline void kvmppc_hash64_write_pte(CPUPPCState *env,
                                           target_ulong pte_index,
                                           target_ulong pte0, target_ulong pte1)
{
    abort();
}

229 230 231 232 233
static inline bool kvmppc_has_cap_fixup_hcalls(void)
{
    abort();
}

234 235
#endif

236 237 238 239 240 241 242 243 244 245 246
#ifndef CONFIG_KVM
#define kvmppc_eieio() do { } while (0)
#else
#define kvmppc_eieio() \
    do {                                          \
        if (kvm_enabled()) {                          \
            asm volatile("eieio" : : : "memory"); \
        } \
    } while (0)
#endif

247 248 249 250 251 252 253 254 255 256 257
#ifndef KVM_INTERRUPT_SET
#define KVM_INTERRUPT_SET -1
#endif

#ifndef KVM_INTERRUPT_UNSET
#define KVM_INTERRUPT_UNSET -2
#endif

#ifndef KVM_INTERRUPT_SET_LEVEL
#define KVM_INTERRUPT_SET_LEVEL -3
#endif
258

A
aurel32 已提交
259
#endif /* __KVM_PPC_H__ */