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_radix; 21 extern bool cpu_has_prefix; 22 extern bool cpu_has_sc_lev; 23 extern bool cpu_has_pause_short; 24 25 static inline uint64_t mfspr(int nr) 26 { 27 uint64_t ret; 28 29 asm volatile("mfspr %0,%1" : "=r"(ret) : "i"(nr) : "memory"); 30 31 return ret; 32 } 33 34 static inline void mtspr(int nr, uint64_t val) 35 { 36 asm volatile("mtspr %0,%1" : : "i"(nr), "r"(val) : "memory"); 37 } 38 39 static inline uint64_t mfmsr(void) 40 { 41 uint64_t msr; 42 43 asm volatile ("mfmsr %[msr]" : [msr] "=r" (msr) :: "memory"); 44 45 return msr; 46 } 47 48 static inline void mtmsr(uint64_t msr) 49 { 50 asm volatile ("mtmsrd %[msr]" :: [msr] "r" (msr) : "memory"); 51 } 52 53 static inline void local_irq_enable(void) 54 { 55 unsigned long msr; 56 57 asm volatile( 58 " mfmsr %0 \n \ 59 ori %0,%0,%1 \n \ 60 mtmsrd %0,1 " 61 : "=r"(msr) : "i"(MSR_EE): "memory"); 62 } 63 64 static inline void local_irq_disable(void) 65 { 66 unsigned long msr; 67 68 asm volatile( 69 " mfmsr %0 \n \ 70 andc %0,%0,%1 \n \ 71 mtmsrd %0,1 " 72 : "=r"(msr) : "r"(MSR_EE): "memory"); 73 } 74 75 /* 76 * This returns true on PowerNV / OPAL machines which run in hypervisor 77 * mode. False on pseries / PAPR machines that run in guest mode. 78 */ 79 static inline bool machine_is_powernv(void) 80 { 81 return cpu_has_hv; 82 } 83 84 /* 85 * This returns true on pseries / PAPR / KVM machines which run under a 86 * hypervisor or QEMU pseries machine. False for PowerNV / OPAL. 87 */ 88 static inline bool machine_is_pseries(void) 89 { 90 return !machine_is_powernv(); 91 } 92 93 void enable_mcheck(void); 94 void disable_mcheck(void); 95 96 #endif /* _ASMPOWERPC_PROCESSOR_H_ */ 97