1 #ifndef _ASMPOWERPC_PROCESSOR_H_ 2 #define _ASMPOWERPC_PROCESSOR_H_ 3 4 #include <libcflat.h> 5 #include <asm/ptrace.h> 6 #include <asm/reg.h> 7 8 #ifndef __ASSEMBLY__ 9 void handle_exception(int trap, void (*func)(struct pt_regs *, void *), void *); 10 void do_handle_exception(struct pt_regs *regs); 11 #endif /* __ASSEMBLY__ */ 12 13 extern bool host_is_tcg; 14 extern bool host_is_kvm; 15 16 extern bool cpu_has_hv; 17 extern bool cpu_has_power_mce; 18 extern bool cpu_has_siar; 19 extern bool cpu_has_heai; 20 extern bool cpu_has_prefix; 21 extern bool cpu_has_sc_lev; 22 extern bool cpu_has_pause_short; 23 24 static inline uint64_t mfspr(int nr) 25 { 26 uint64_t ret; 27 28 asm volatile("mfspr %0,%1" : "=r"(ret) : "i"(nr) : "memory"); 29 30 return ret; 31 } 32 33 static inline void mtspr(int nr, uint64_t val) 34 { 35 asm volatile("mtspr %0,%1" : : "i"(nr), "r"(val) : "memory"); 36 } 37 38 static inline uint64_t mfmsr(void) 39 { 40 uint64_t msr; 41 42 asm volatile ("mfmsr %[msr]" : [msr] "=r" (msr) :: "memory"); 43 44 return msr; 45 } 46 47 static inline void mtmsr(uint64_t msr) 48 { 49 asm volatile ("mtmsrd %[msr]" :: [msr] "r" (msr) : "memory"); 50 } 51 52 static inline void local_irq_enable(void) 53 { 54 unsigned long msr; 55 56 asm volatile( 57 " mfmsr %0 \n \ 58 ori %0,%0,%1 \n \ 59 mtmsrd %0,1 " 60 : "=r"(msr) : "i"(MSR_EE): "memory"); 61 } 62 63 static inline void local_irq_disable(void) 64 { 65 unsigned long msr; 66 67 asm volatile( 68 " mfmsr %0 \n \ 69 andc %0,%0,%1 \n \ 70 mtmsrd %0,1 " 71 : "=r"(msr) : "r"(MSR_EE): "memory"); 72 } 73 74 /* 75 * This returns true on PowerNV / OPAL machines which run in hypervisor 76 * mode. False on pseries / PAPR machines that run in guest mode. 77 */ 78 static inline bool machine_is_powernv(void) 79 { 80 return cpu_has_hv; 81 } 82 83 /* 84 * This returns true on pseries / PAPR / KVM machines which run under a 85 * hypervisor or QEMU pseries machine. False for PowerNV / OPAL. 86 */ 87 static inline bool machine_is_pseries(void) 88 { 89 return !machine_is_powernv(); 90 } 91 92 void enable_mcheck(void); 93 void disable_mcheck(void); 94 95 #endif /* _ASMPOWERPC_PROCESSOR_H_ */ 96