booke.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  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. #ifndef __KVM_BOOKE_H__
  20. #define __KVM_BOOKE_H__
  21. #include <linux/types.h>
  22. #include <linux/kvm_host.h>
  23. #include <asm/kvm_ppc.h>
  24. #include <asm/switch_to.h>
  25. #include "timing.h"
  26. /* interrupt priortity ordering */
  27. #define BOOKE_IRQPRIO_DATA_STORAGE 0
  28. #define BOOKE_IRQPRIO_INST_STORAGE 1
  29. #define BOOKE_IRQPRIO_ALIGNMENT 2
  30. #define BOOKE_IRQPRIO_PROGRAM 3
  31. #define BOOKE_IRQPRIO_FP_UNAVAIL 4
  32. #ifdef CONFIG_SPE_POSSIBLE
  33. #define BOOKE_IRQPRIO_SPE_UNAVAIL 5
  34. #define BOOKE_IRQPRIO_SPE_FP_DATA 6
  35. #define BOOKE_IRQPRIO_SPE_FP_ROUND 7
  36. #endif
  37. #ifdef CONFIG_PPC_E500MC
  38. #define BOOKE_IRQPRIO_ALTIVEC_UNAVAIL 5
  39. #define BOOKE_IRQPRIO_ALTIVEC_ASSIST 6
  40. #endif
  41. #define BOOKE_IRQPRIO_SYSCALL 8
  42. #define BOOKE_IRQPRIO_AP_UNAVAIL 9
  43. #define BOOKE_IRQPRIO_DTLB_MISS 10
  44. #define BOOKE_IRQPRIO_ITLB_MISS 11
  45. #define BOOKE_IRQPRIO_MACHINE_CHECK 12
  46. #define BOOKE_IRQPRIO_DEBUG 13
  47. #define BOOKE_IRQPRIO_CRITICAL 14
  48. #define BOOKE_IRQPRIO_WATCHDOG 15
  49. #define BOOKE_IRQPRIO_EXTERNAL 16
  50. #define BOOKE_IRQPRIO_FIT 17
  51. #define BOOKE_IRQPRIO_DECREMENTER 18
  52. #define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19
  53. /* Internal pseudo-irqprio for level triggered externals */
  54. #define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
  55. #define BOOKE_IRQPRIO_DBELL 21
  56. #define BOOKE_IRQPRIO_DBELL_CRIT 22
  57. #define BOOKE_IRQPRIO_MAX 23
  58. #define BOOKE_IRQMASK_EE ((1 << BOOKE_IRQPRIO_EXTERNAL_LEVEL) | \
  59. (1 << BOOKE_IRQPRIO_PERFORMANCE_MONITOR) | \
  60. (1 << BOOKE_IRQPRIO_DBELL) | \
  61. (1 << BOOKE_IRQPRIO_DECREMENTER) | \
  62. (1 << BOOKE_IRQPRIO_FIT) | \
  63. (1 << BOOKE_IRQPRIO_EXTERNAL))
  64. #define BOOKE_IRQMASK_CE ((1 << BOOKE_IRQPRIO_DBELL_CRIT) | \
  65. (1 << BOOKE_IRQPRIO_WATCHDOG) | \
  66. (1 << BOOKE_IRQPRIO_CRITICAL))
  67. extern unsigned long kvmppc_booke_handlers;
  68. extern unsigned long kvmppc_booke_handler_addr[];
  69. void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
  70. void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
  71. void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr);
  72. void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
  73. void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
  74. void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
  75. int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
  76. unsigned int inst, int *advance);
  77. int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val);
  78. int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val);
  79. /* low-level asm code to transfer guest state */
  80. void kvmppc_load_guest_spe(struct kvm_vcpu *vcpu);
  81. void kvmppc_save_guest_spe(struct kvm_vcpu *vcpu);
  82. /* high-level function, manages flags, host state */
  83. void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
  84. void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
  85. void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
  86. enum int_class {
  87. INT_CLASS_NONCRIT,
  88. INT_CLASS_CRIT,
  89. INT_CLASS_MC,
  90. INT_CLASS_DBG,
  91. };
  92. void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type);
  93. extern void kvmppc_mmu_destroy_e500(struct kvm_vcpu *vcpu);
  94. extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
  95. struct kvm_vcpu *vcpu,
  96. unsigned int inst, int *advance);
  97. extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
  98. ulong spr_val);
  99. extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
  100. ulong *spr_val);
  101. extern void kvmppc_mmu_destroy_e500(struct kvm_vcpu *vcpu);
  102. extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
  103. struct kvm_vcpu *vcpu,
  104. unsigned int inst, int *advance);
  105. extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
  106. ulong spr_val);
  107. extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
  108. ulong *spr_val);
  109. static inline void kvmppc_clear_dbsr(void)
  110. {
  111. mtspr(SPRN_DBSR, mfspr(SPRN_DBSR));
  112. }
  113. #endif /* __KVM_BOOKE_H__ */