[PATCH 5/6] powerpc/boot: Add mfdcrx

David Laight David.Laight at ACULAB.COM
Thu Dec 1 05:10:23 EST 2011


 
> > +#define mfdcrx(rn) \
> > +	({	\
> > +		unsigned long rval; \
> > +		asm volatile("mfdcrx %0,%1" : "=r"(rval) : "g"(rn)); \
> > +		rval; \
> > +	})
> 
> "g" is never correct on PowerPC, you want "r" here.  You can write
> this as a static inline btw, you only need the #define stuff when
> there is an "i" constraint involved.

I think you can still use static inlines even when a
constraint is one that requires a compile time constant.
eg (not ppc, but the "n" become part of the instruction
word):

static __inline__ uint32_t
custom_inic(const uint32_t op, uint32_t a, const uint32_t b)
{
    uint32_t result;

    __asm__ ( "custom\t%1, %0, %2, c%3"
        : "=r" (result) : "n" (op), "r" (a), "n" (b));
    return result;
}

	David




More information about the Linuxppc-dev mailing list