[PATCH 10/11] powerpc: Add helper functions for synthesising instructions at runtime

Segher Boessenkool segher at kernel.crashing.org
Tue Oct 18 00:44:29 EST 2005


> +typedef enum {
> +	BRANCH_RELATIVE,
> +	BRANCH_RELATIVE_LINK,
> +	BRANCH_ABSOLUTE,
> +	BRANCH_ABSOLUTE_LINK
> +} branch_t;

Why not say BRANCH_RELATIVE = 0, BRANCH_RELATIVE_LINK = 1, etc.,
and then later just or this value into the insn?

> +	asm ("dcbst 0, %0; sync; icbi 0,%0; isync" : : "r" (p));

sequence should be  dcbst; sync; icbi; sync; isync  to ensure
the insn cache invalidation is global before continuing.

> +	if (BRANCH_ABSOLUTE == type || BRANCH_ABSOLUTE_LINK == type)
> +		instruction |= 0x02;	/* set AA (absolute address) */
> +	else
> +		target = target - addr;
> +
> +	if (BRANCH_RELATIVE_LINK == type || BRANCH_ABSOLUTE_LINK == type)
> +		instruction |= 0x01;	/* set LK (set link register) */

This would be


instruction |= type;
if ((type & 2) == 0)
	target -= addr;


Segher




More information about the Linuxppc64-dev mailing list