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 cpu_has_hv; 14 15 static inline uint64_t mfspr(int nr) 16 { 17 uint64_t ret; 18 19 asm volatile("mfspr %0,%1" : "=r"(ret) : "i"(nr) : "memory"); 20 21 return ret; 22 } 23 24 static inline void mtspr(int nr, uint64_t val) 25 { 26 asm volatile("mtspr %0,%1" : : "i"(nr), "r"(val) : "memory"); 27 } 28 29 static inline uint64_t mfmsr(void) 30 { 31 uint64_t msr; 32 33 asm volatile ("mfmsr %[msr]" : [msr] "=r" (msr) :: "memory"); 34 35 return msr; 36 } 37 38 static inline void mtmsr(uint64_t msr) 39 { 40 asm volatile ("mtmsrd %[msr]" :: [msr] "r" (msr) : "memory"); 41 } 42 43 /* 44 * This returns true on PowerNV / OPAL machines which run in hypervisor 45 * mode. False on pseries / PAPR machines that run in guest mode. 46 */ 47 static inline bool machine_is_powernv(void) 48 { 49 return cpu_has_hv; 50 } 51 52 /* 53 * This returns true on pseries / PAPR / KVM machines which run under a 54 * hypervisor or QEMU pseries machine. False for PowerNV / OPAL. 55 */ 56 static inline bool machine_is_pseries(void) 57 { 58 return !machine_is_powernv(); 59 } 60 61 void enable_mcheck(void); 62 void disable_mcheck(void); 63 64 #endif /* _ASMPOWERPC_PROCESSOR_H_ */ 65