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