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