From 1c424d26975345dec30e525319056cdb2280b170 Mon Sep 17 00:00:00 2001
From: Michal Simek <michal.simek@xilinx.com>
Date: Mon, 26 Jan 2015 14:32:23 +0100
Subject: [PATCH] microblaze: Show return address from exception

Show also return address from exception which should
suggest where the problem is.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
 arch/microblaze/cpu/exception.c   | 2 ++
 arch/microblaze/include/asm/asm.h | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/arch/microblaze/cpu/exception.c b/arch/microblaze/cpu/exception.c
index 227842f6a4..45729331f3 100644
--- a/arch/microblaze/cpu/exception.c
+++ b/arch/microblaze/cpu/exception.c
@@ -18,6 +18,8 @@ void _hw_exception_handler (void)
 	/* loading excetpion state register ESR */
 	MFS (state, resr);
 	printf ("Hardware exception at 0x%x address\n", address);
+	R17(address);
+	printf("Return address from exception 0x%x\n", address);
 	switch (state & 0x1f) {	/* mask on exception cause */
 	case 0x1:
 		puts ("Unaligned data access exception\n");
diff --git a/arch/microblaze/include/asm/asm.h b/arch/microblaze/include/asm/asm.h
index c1c3b03985..11f3dd0f0e 100644
--- a/arch/microblaze/include/asm/asm.h
+++ b/arch/microblaze/include/asm/asm.h
@@ -43,6 +43,10 @@
 #define R14(val) \
 	__asm__ __volatile__ ("addi %0, r14, 0":"=r" (val));
 
+/* get return address from interrupt */
+#define R17(val) \
+	__asm__ __volatile__ ("addi %0, r17, 0" : "=r" (val));
+
 #define NOP	__asm__ __volatile__ ("nop");
 
 /* use machine status registe USE_MSR_REG */
-- 
2.39.5