[U-Boot] [PATCH] Blackfin: adjust asm constraints with NMI workaround

Mike Frysinger vapier at gentoo.org
Tue Jul 31 11:45:28 CEST 2012


Newer gcc versions will sometimes use a Preg when "r" constraints, but
that'll fail if we use an Ireg in the assignment.  So force the code
to always use a Dreg.

This also fixes early boot crashes for older Blackfin parts when compiled
with gcc-4.5.  This version ends up selecting the same register for the
input and output variables which corrupts the output assignment triggering
an exception.
	P2 = 0xffe02008;	/* EVT2 */
	R0 = RETS;
	CALL 1f;
	RTN;
1:	P2 = RETS;	<-- BAD
	RETS = R0;
	[P2] = P2;	<-- BAD

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 arch/blackfin/cpu/initcode.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/blackfin/cpu/initcode.c b/arch/blackfin/cpu/initcode.c
index 243f4f3..3c10adc 100644
--- a/arch/blackfin/cpu/initcode.c
+++ b/arch/blackfin/cpu/initcode.c
@@ -130,7 +130,8 @@ program_nmi_handler(void)
 		"%1 = RETS;" /* Load addr of NMI handler */
 		"RETS = %0;" /* Restore RETS */
 		"[%2] = %1;" /* Write NMI handler */
-		: "=r"(tmp1), "=r"(tmp2) : "ab"(EVT2)
+		: "=d"(tmp1), "=d"(tmp2)
+		: "ab"(EVT2)
 	);
 }
 
-- 
1.7.9.7



More information about the U-Boot mailing list