[Efi332] GNU errors

David Eicher sailors3
Sun Mar 13 04:49:06 UTC 2005


Hi Andrei,

I guess I got a little too excited too soon! 8-(

While it is true that using this technique does get the macros expanded,
when the assembler runs it complains about all the "tmp" and "reg"
parameters that are being passed into these functions:

Inline void archWriteEIBADR(UWord32 register reg)
{
	Asm ("mtspr  %0,reg"
		:
		: "g" (ARCH_EIBADR));

}
Inline UWord32 archReadEIBADR(void)
{
	Register UWord32 tmp;

	Asm  ("mfspr tmp,%0"
		:
		: "g" (ARCH_EIBADR));
	Return (tmp);
}

This code triggers these errors from GNU assembler:

5xx_board_init.s:516: Error: unsupported relocation against reg
5xx_board_init.s:524: Error: unsupported relocation against tmp

The assembly code looks like this in the 5xx_board_init.s file:


	.align 2
	.globl archWriteEIBADR
	.type	archWriteEIBADR, @function
archWriteEIBADR:
	mtspr 529,reg
	blr
	.size	archWriteEIBADR, .-archWriteEIBADR
	.align 2
	.globl archReadEIBADR
	.type	archReadEIBADR, @function
archReadEIBADR:
	stwu 1,-16(1)
	mfspr tmp,529
	lwz 0,8(1)
	mr 3,0
	addi 1,1,16
	blr
	.size	archReadEIBADR, .-archReadEIBADR

So, it appears the issue is related to declaring tmp and reg to be of type
"register". 

Here's the list file output for these two routines:

549              		.globl archWriteEIBADR
 550              		.type	archWriteEIBADR, @function
 551              	archWriteEIBADR:
 552 ???? 7C1183A6 		mtspr 529,reg
 553 ???? 4E800020 		blr
 554              		.size	archWriteEIBADR, .-archWriteEIBADR
 555              		.align 2
 556              		.globl archReadEIBADR
 557              		.type	archReadEIBADR, @function
 558              	archReadEIBADR:
 559 ???? 9421FFF0 		stwu 1,-16(1)
 560 ???? 7C1182A6 		mfspr tmp,529
 561 ???? 80010008 		lwz 0,8(1)
 562 ???? 7C030378 		mr 3,0
 563 ???? 38210010 		addi 1,1,16
 564 ???? 4E800020 		blr
 565              		.size	archReadEIBADR, .-archReadEIBADR

The assembler can't deal with "mfspr tmp,529", it needs "mfspr r5,529" for
example. So I understand what the problem is, but don?t know what to do
about it.

Suggestions?

Thanks much for your help so far!

Dave


----Original Message-----
From: Andrei Chichak [mailto:agchichak at compusmart.ab.ca] 
Sent: Friday, March 11, 2005 3:55 PM
To: David Eicher
Subject: RE: Re: [Efi332] GNU errors

Okay, assuming that the problem was the substitution of parameters into 
asm("blah") statements, the following will work

#define number 0x00001000
#define ARCH_ICTRL 0x00080000
#define ARCH_MSR_ME 0x00001000
#define ARCH_MSR_RI 0x00000002

void usr_init()
{
         int index;

         asm ("mfspr r5, %0" : : "g" (ARCH_ICTRL));
         index = (int) number;
         index = index + 5;

         asm ("ori       r5,r5,%0"
                 :
                 : "g" (ARCH_MSR_ME | ARCH_MSR_RI));
}

Since there isn't really a need to make r5 into a parameter, I encoded it 
right in the command. The stuff dealing with defines is taken care of using 
the positional parameter stuff.

That syntax is usually used to access variables in C. If you declared 
something register int fu, then you could use "r" (fu). But the existence 
of r5 is hidden from you by the compiler and by dropping down to assembly 
becomes available (sort of), but the asm structure with the parameter 
substitution seems to happen at the C level (where r5 isn't available) 
instead of at the assembler level (where it would be available).

I hope this helps,
Andrei


------------------------------
Andrei Chichak

4024-120 Street                         (780)434-6266
Edmonton, Alberta                       agchichak at compusmart.ab.ca
Canada
T6J 1X8

Lat: 53? 28' 40" N
Lon: 113? 32' 27" W  





More information about the Efi332 mailing list