mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 8/8] ARM: some cleanup in interrupts.c
Date: Mon,  8 Aug 2011 08:46:43 +0200	[thread overview]
Message-ID: <1312786003-14734-9-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1312786003-14734-1-git-send-email-s.hauer@pengutronix.de>

- Don't call panic with "resetting CPU...". Depending on the
  configuration the system might also hang.
- panic does not return, so no need to call reset_cpu afterwards
- bundle show_regs and panic into a seperate functions to not have
  to call both functions from each exception handler

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/interrupts.c |   43 +++++++++++++++++++++----------------------
 1 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/arch/arm/cpu/interrupts.c b/arch/arm/cpu/interrupts.c
index 0c21bc1..3d2077f 100644
--- a/arch/arm/cpu/interrupts.c
+++ b/arch/arm/cpu/interrupts.c
@@ -30,15 +30,6 @@
 #include <asm/unwind.h>
 
 /**
- * FIXME
- */
-static void bad_mode (void)
-{
-	panic ("Resetting CPU ...\n");
-	reset_cpu (0);
-}
-
-/**
  * Display current register set content
  * @param[in] regs Guess what
  */
@@ -82,6 +73,13 @@ void show_regs (struct pt_regs *regs)
 #endif
 }
 
+static void __noreturn do_exception(struct pt_regs *pt_regs)
+{
+	show_regs(pt_regs);
+
+	panic("");
+}
+
 /**
  * The CPU runs into an undefined instruction. That really should not happen!
  * @param[in] pt_regs Register set content when the accident happens
@@ -89,8 +87,7 @@ void show_regs (struct pt_regs *regs)
 void do_undefined_instruction (struct pt_regs *pt_regs)
 {
 	printf ("undefined instruction\n");
-	show_regs (pt_regs);
-	bad_mode ();
+	do_exception(pt_regs);
 }
 
 /**
@@ -103,8 +100,7 @@ void do_undefined_instruction (struct pt_regs *pt_regs)
 void do_software_interrupt (struct pt_regs *pt_regs)
 {
 	printf ("software interrupt\n");
-	show_regs (pt_regs);
-	bad_mode ();
+	do_exception(pt_regs);
 }
 
 /**
@@ -116,8 +112,7 @@ void do_software_interrupt (struct pt_regs *pt_regs)
 void do_prefetch_abort (struct pt_regs *pt_regs)
 {
 	printf ("prefetch abort\n");
-	show_regs (pt_regs);
-	bad_mode ();
+	do_exception(pt_regs);
 }
 
 /**
@@ -128,9 +123,15 @@ void do_prefetch_abort (struct pt_regs *pt_regs)
  */
 void do_data_abort (struct pt_regs *pt_regs)
 {
-	printf ("data abort\n");
-	show_regs (pt_regs);
-	bad_mode ();
+	u32 far;
+
+	asm volatile ("mrc     p15, 0, %0, c6, c0, 0" : "=r" (far) : : "cc");
+
+	printf("unable to handle %s at address 0x%08x\n",
+			far < PAGE_SIZE ? "NULL pointer dereference" :
+			"paging request", far);
+
+	do_exception(pt_regs);
 }
 
 /**
@@ -142,8 +143,7 @@ void do_data_abort (struct pt_regs *pt_regs)
 void do_fiq (struct pt_regs *pt_regs)
 {
 	printf ("fast interrupt request\n");
-	show_regs (pt_regs);
-	bad_mode ();
+	do_exception(pt_regs);
 }
 
 /**
@@ -155,6 +155,5 @@ void do_fiq (struct pt_regs *pt_regs)
 void do_irq (struct pt_regs *pt_regs)
 {
 	printf ("interrupt request\n");
-	show_regs (pt_regs);
-	bad_mode ();
+	do_exception(pt_regs);
 }
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-08-08  6:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-08  6:46 ARM: use high vectors if possible Sascha Hauer
2011-08-08  6:46 ` [PATCH 1/8] ARM: add missing volatile in get_cr() Sascha Hauer
2011-08-08  6:46 ` [PATCH 2/8] ARM mmu: fix arm_create_pte Sascha Hauer
2011-08-08  6:46 ` [PATCH 3/8] ARM mmu: use high vectors if possible Sascha Hauer
2011-08-08  6:46 ` [PATCH 4/8] ARM: remove unused exception Sascha Hauer
2011-08-08  6:46 ` [PATCH 5/8] ARM: exceptions: remove unnecessary function declarations Sascha Hauer
2011-08-08  6:46 ` [PATCH 6/8] ARM: remove unused irq enable/disable functions Sascha Hauer
2011-08-08  6:46 ` [PATCH 7/8] ARM: fix comments in interrupts.c Sascha Hauer
2011-08-08  6:46 ` Sascha Hauer [this message]
2011-08-08  7:06 ` ARM: use high vectors if possible Jean-Christophe PLAGNIOL-VILLARD
2011-08-08  7:32   ` Sascha Hauer
2011-08-09  7:36     ` Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1312786003-14734-9-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox