blob: d53bcf2558f50488b3debcdcfca2a64f6de8b6e7 [file] [log] [blame]
Hollis Blanchard75f74f02008-11-05 09:36:16 -06001/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 *
15 * Copyright IBM Corp. 2008
16 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */
19
20#ifndef __KVM_BOOKE_H__
21#define __KVM_BOOKE_H__
22
23#include <linux/types.h>
24#include <linux/kvm_host.h>
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060025#include <asm/kvm_ppc.h>
Hollis Blanchard73e75b42008-12-02 15:51:57 -060026#include "timing.h"
Hollis Blanchard75f74f02008-11-05 09:36:16 -060027
Hollis Blanchardd4cf3892008-11-05 09:36:23 -060028/* interrupt priortity ordering */
29#define BOOKE_IRQPRIO_DATA_STORAGE 0
30#define BOOKE_IRQPRIO_INST_STORAGE 1
31#define BOOKE_IRQPRIO_ALIGNMENT 2
32#define BOOKE_IRQPRIO_PROGRAM 3
33#define BOOKE_IRQPRIO_FP_UNAVAIL 4
Hollis Blanchardbb3a8a12009-01-03 16:23:13 -060034#define BOOKE_IRQPRIO_SPE_UNAVAIL 5
35#define BOOKE_IRQPRIO_SPE_FP_DATA 6
36#define BOOKE_IRQPRIO_SPE_FP_ROUND 7
37#define BOOKE_IRQPRIO_SYSCALL 8
38#define BOOKE_IRQPRIO_AP_UNAVAIL 9
39#define BOOKE_IRQPRIO_DTLB_MISS 10
40#define BOOKE_IRQPRIO_ITLB_MISS 11
41#define BOOKE_IRQPRIO_MACHINE_CHECK 12
42#define BOOKE_IRQPRIO_DEBUG 13
43#define BOOKE_IRQPRIO_CRITICAL 14
44#define BOOKE_IRQPRIO_WATCHDOG 15
45#define BOOKE_IRQPRIO_EXTERNAL 16
46#define BOOKE_IRQPRIO_FIT 17
47#define BOOKE_IRQPRIO_DECREMENTER 18
48#define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19
Alexander Grafc5335f12010-08-30 14:03:24 +020049/* Internal pseudo-irqprio for level triggered externals */
50#define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
Scott Woodd30f6e42011-12-20 15:34:43 +000051#define BOOKE_IRQPRIO_DBELL 21
52#define BOOKE_IRQPRIO_DBELL_CRIT 22
53#define BOOKE_IRQPRIO_MAX 23
54
55#define BOOKE_IRQMASK_EE ((1 << BOOKE_IRQPRIO_EXTERNAL_LEVEL) | \
56 (1 << BOOKE_IRQPRIO_PERFORMANCE_MONITOR) | \
57 (1 << BOOKE_IRQPRIO_DBELL) | \
58 (1 << BOOKE_IRQPRIO_DECREMENTER) | \
59 (1 << BOOKE_IRQPRIO_FIT) | \
60 (1 << BOOKE_IRQPRIO_EXTERNAL))
61
62#define BOOKE_IRQMASK_CE ((1 << BOOKE_IRQPRIO_DBELL_CRIT) | \
63 (1 << BOOKE_IRQPRIO_WATCHDOG) | \
64 (1 << BOOKE_IRQPRIO_CRITICAL))
Hollis Blanchardbb3a8a12009-01-03 16:23:13 -060065
66extern unsigned long kvmppc_booke_handlers;
Hollis Blanchardd4cf3892008-11-05 09:36:23 -060067
Scott Wood4cd35f62011-06-14 18:34:31 -050068void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
Liu Yudd9ebf1f2011-06-14 18:35:14 -050069void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
Hollis Blanchard75f74f02008-11-05 09:36:16 -060070
Scott Wooddfd4d472011-11-17 12:39:59 +000071void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
72void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
73void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
74
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060075int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
76 unsigned int inst, int *advance);
77int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt);
78int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs);
79
Scott Wood4cd35f62011-06-14 18:34:31 -050080/* low-level asm code to transfer guest state */
81void kvmppc_load_guest_spe(struct kvm_vcpu *vcpu);
82void kvmppc_save_guest_spe(struct kvm_vcpu *vcpu);
83
84/* high-level function, manages flags, host state */
85void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
86
Scott Wood94fa9d92011-12-20 15:34:22 +000087void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
88void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
89
Scott Woodd30f6e42011-12-20 15:34:43 +000090enum int_class {
91 INT_CLASS_NONCRIT,
92 INT_CLASS_CRIT,
93 INT_CLASS_MC,
94 INT_CLASS_DBG,
95};
96
97void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type);
98
Hollis Blanchard75f74f02008-11-05 09:36:16 -060099#endif /* __KVM_BOOKE_H__ */