[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] PVR



I don't think that your code is the best for U-BOOT.

I tried this macro. EDK compiled this code.

#define getpvr(pvrid, val) asm volatile ("mfs\t%0,rpvr" stringify(pvrid) "\n\t" : "=d" (val))

volatile unsigned int a=0;
getpvr(0,a);

Dump instr.
174: 12610000  addk r19, r1, r0
178: f813001c  swi r0, r19, 28
17c: 9460a000  mfs r3, rpvr0
180: f873001c  swi r3, r19, 28
184: e873001c  lwi r3, r19, 28

I will compile new linux toolchain.

Best regards,
Michal Simek

On Tue, May 08, 2007 at 03:08:33PM +0200, Michal Simek wrote:
Hi,

I tried to add Processor Version Register to U-BOOT but I hit againts a
small problem.
I don't know how to write asembler instruction for PVR.

I worked around this problem by writing the MTS instruction in machine
code. The machine code for copying special purpose register X into
register r3, "mts r3, X", is ( 0x94608000 | X ). Include this in
inline assembly using .long.

Here is a sample C function that reads the value of an arbitrary SPR.
It is more complex than it would need to be in order to read a
specific SPR, because it uses self-modifying code to generate the
MTS instruction with and must therefore disable the cache as it runs.
Shame that Xilinx didn't allow the SPR number to be specified using
a register.

   unsigned Get_SPR ( unsigned number )
   {
       unsigned v = ( number ) & 0x3fff ;
       unsigned out = 0 ;

       asm volatile (
"msrclr r31, 0xa2\n" /* caches, interrupts disabled (if used) */
           "addik  r3, r0, 0x94608000\n"
           "or     r3, r3, %1\n"
           "swi    r3, r0, 0f\n" /* do modification */
           "or     r3, r0, r0\n"
           "or     r3, r0, r0\n" /* NOPs for fetch buffer and pipeline */
           "or     r3, r0, r0\n"
           "or     r3, r0, r0\n"
           "or     r3, r0, r0\n"
           "or     r3, r0, r0\n"
           "0:\n"
           ".long 0xffffffff\n" /* Code that gets modified */
           "addk %0, r3, r0\n"
           "mts    rmsr, r31\n" /* MSR setting restored */
           : "=r"(out) : "r"(v) : "r3", "r31" ) ;
       return out ;
   }

Use Get_SPR ( 0x2000 ) to read PVR0.




--
Jack Whitham
jack@xxxxxxxxxxxxx

___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.467 / Virus Database: 269.6.5/793 - Release Date: 7.5.2007 14:55


___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/