From: Heinrich Schuchardt <xypron.g...@gmx.de>

Carve out a function except_msg() to handle the output for most type of
interrupts.

Consistently use 16 digits for printing the exception syndrome register
esr to match the register size.

Signed-off-by: Heinrich Schuchardt <heinrich.schucha...@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodi...@linaro.org>
---
 arch/arm/lib/interrupts_64.c | 62 ++++++++++++++++++--------------------------
 1 file changed, 25 insertions(+), 37 deletions(-)

diff --git a/arch/arm/lib/interrupts_64.c b/arch/arm/lib/interrupts_64.c
index 
b3024ba514ec363bfc3b957df203fc784278037e..d13ee8d9f81dc8c41ef4732167663b223ab6ab3b
 100644
--- a/arch/arm/lib/interrupts_64.c
+++ b/arch/arm/lib/interrupts_64.c
@@ -139,55 +139,55 @@ static bool smh_emulate_trap(struct pt_regs *regs)
        regs->elr += size;
        return true;
 }
 
+/**
+ * except_msg() - print exception message
+ *
+ * Print exception message, register contents, backtrace, loaded EFI images.
+ *
+ * @msg:       message describing exception type
+ * @pt_regs:   registers
+ */
+static void except_msg(const char *msg, struct pt_regs *pt_regs)
+{
+       efi_restore_gd();
+       printf("%s handler, esr 0x%016lx\n", msg, pt_regs->esr);
+       show_regs(pt_regs);
+       show_efi_loaded_images(pt_regs);
+       panic("Resetting CPU ...\n");
+}
+
 /*
  * do_bad_sync handles the impossible case in the Synchronous Abort vector.
  */
 void do_bad_sync(struct pt_regs *pt_regs)
 {
-       efi_restore_gd();
-       printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08lx\n",
-              pt_regs->esr);
-       show_regs(pt_regs);
-       show_efi_loaded_images(pt_regs);
-       panic("Resetting CPU ...\n");
+       except_msg("Bad mode in \"Synchronous Abort\"", pt_regs);
 }
 
 /*
  * do_bad_irq handles the impossible case in the Irq vector.
  */
 void do_bad_irq(struct pt_regs *pt_regs)
 {
-       efi_restore_gd();
-       printf("Bad mode in \"Irq\" handler, esr 0x%08lx\n", pt_regs->esr);
-       show_regs(pt_regs);
-       show_efi_loaded_images(pt_regs);
-       panic("Resetting CPU ...\n");
+       except_msg("Bad mode in \"Irq\"", pt_regs);
 }
 
 /*
  * do_bad_fiq handles the impossible case in the Fiq vector.
  */
 void do_bad_fiq(struct pt_regs *pt_regs)
 {
-       efi_restore_gd();
-       printf("Bad mode in \"Fiq\" handler, esr 0x%08lx\n", pt_regs->esr);
-       show_regs(pt_regs);
-       show_efi_loaded_images(pt_regs);
-       panic("Resetting CPU ...\n");
+       except_msg("Bad mode in \"Fiq\"", pt_regs);
 }
 
 /*
  * do_bad_error handles the impossible case in the Error vector.
  */
 void do_bad_error(struct pt_regs *pt_regs)
 {
-       efi_restore_gd();
-       printf("Bad mode in \"Error\" handler, esr 0x%08lx\n", pt_regs->esr);
-       show_regs(pt_regs);
-       show_efi_loaded_images(pt_regs);
-       panic("Resetting CPU ...\n");
+       except_msg("Bad mode in \"Error\"", pt_regs);
 }
 
 /*
  * do_sync handles the Synchronous Abort exception.
@@ -197,9 +197,9 @@ void do_sync(struct pt_regs *pt_regs)
        if (CONFIG_IS_ENABLED(SEMIHOSTING_FALLBACK) &&
            smh_emulate_trap(pt_regs))
                return;
        efi_restore_gd();
-       printf("\"Synchronous Abort\" handler, esr 0x%08lx", pt_regs->esr);
+       printf("\"Synchronous Abort\" handler, esr 0x%016lx", pt_regs->esr);
        dump_far(pt_regs->esr);
        printf("\n");
        show_regs(pt_regs);
        show_efi_loaded_images(pt_regs);
@@ -210,25 +210,17 @@ void do_sync(struct pt_regs *pt_regs)
  * do_irq handles the Irq exception.
  */
 void do_irq(struct pt_regs *pt_regs)
 {
-       efi_restore_gd();
-       printf("\"Irq\" handler, esr 0x%08lx\n", pt_regs->esr);
-       show_regs(pt_regs);
-       show_efi_loaded_images(pt_regs);
-       panic("Resetting CPU ...\n");
+       except_msg("\"Irq\"", pt_regs);
 }
 
 /*
  * do_fiq handles the Fiq exception.
  */
 void do_fiq(struct pt_regs *pt_regs)
 {
-       efi_restore_gd();
-       printf("\"Fiq\" handler, esr 0x%08lx\n", pt_regs->esr);
-       show_regs(pt_regs);
-       show_efi_loaded_images(pt_regs);
-       panic("Resetting CPU ...\n");
+       except_msg("\"Fiq\"", pt_regs);
 }
 
 /*
  * do_error handles the Error exception.
@@ -237,10 +229,6 @@ void do_fiq(struct pt_regs *pt_regs)
  * in processor specific code.
  */
 void __weak do_error(struct pt_regs *pt_regs)
 {
-       efi_restore_gd();
-       printf("\"Error\" handler, esr 0x%08lx\n", pt_regs->esr);
-       show_regs(pt_regs);
-       show_efi_loaded_images(pt_regs);
-       panic("Resetting CPU ...\n");
+       except_msg("\"Error\"", pt_regs);
 }

-- 
2.50.0

Reply via email to