Using Power PC MPC5775B, how do I read the core Machine State Register from a C routine? Other compilers have had intrinsic functions like __mfmsr() that returned the MSR value. But I can't find the equivalent in S32DS. I want to check the state of the EE bit (external interrupt disable).
Hi @ronjaeger
I used this in the past:
#define MFMSR() ({unsigned int rval; __asm__ volatile("mfmsr %0" : "=r" (rval)); rval;})
#define MTMSR(v) __asm__ volatile("mtmsr %0" : : "r"(v))
and then:
temp = MFMSR();
MTMSR(0x8000);
Regards,
Lukas
Actually, when I use MFMSR(), it compiles without actual error, but I get this warning:
"warning (etoa:5848): GNU-style inline assembly detected. This feature is not supported."
Should I be concerned about this or just ignore the warning?
That's interesting, I can't see such error on my side. If it works, there's probably no problem.
And I found one more version which can be used to access any SPR register, not only MSR:
#define stringify(s) tostring(s)
#define tostring(s) #s
#define mfspr(rn) ({unsigned int rval; __asm__ volatile("mfspr %0," stringify(rn) : "=r" (rval)); rval;})
#define mtspr(rn, v) __asm__ volatile("mtspr " stringify(rn) ",%0" : : "r" (v))
And then:
mtspr(570, content_of_MCSRR0);
mtspr(572, 0xFFFFFFFF); //clear all flags in MCSR register
Regards,
Lukas
Thanks. That seems to work. (But see post about warning...)