microblaze: Improve checking mechanism for MSR instruction

It is more safe to use clear instead of msrset.
We save some instructions too.

Signed-off-by: Michal Simek <monstr@monstr.eu>
This commit is contained in:
Michal Simek 2009-08-31 16:24:56 +02:00
parent 2622434ee0
commit 9002062ff5
1 changed files with 5 additions and 8 deletions

View File

@ -54,19 +54,16 @@ ENTRY(_start)
mfs r1, rmsr mfs r1, rmsr
andi r1, r1, ~2 andi r1, r1, ~2
mts rmsr, r1 mts rmsr, r1
/* /*
* Here is checking mechanism which check if Microblaze has msr instructions * Here is checking mechanism which check if Microblaze has msr instructions
* We load msr and compare it with previous r1 value - if is the same, * We load msr and compare it with previous r1 value - if is the same,
* msr instructions works if not - cpu don't have them. * msr instructions works if not - cpu don't have them.
*/ */
or r8, r0, r0 /* 0 - I have msr instr, 1 - I don't have */ /* r8=0 - I have msr instr, 1 - I don't have them */
or r12, r0, r0 rsubi r0, r0, 1 /* set the carry bit */
msrset r12, 0 /* set nothing - just read msr for test */ msrclr r0, 0x4 /* try to clear it */
cmpu r12, r12, r1 /* read the carry bit, r8 will be '0' if msrclr exists */
beqi r12, 1f addik r8, r0, 0
ori r8, r0, 1 /* I don't have msr */
1:
/* r7 may point to an FDT, or there may be one linked in. /* r7 may point to an FDT, or there may be one linked in.
if it's in r7, we've got to save it away ASAP. if it's in r7, we've got to save it away ASAP.