]> Git Repo - J-u-boot.git/blobdiff - arch/arm/lib/interrupts.c
arm: clean up v7 and v8 linker scripts for bss_start/end
[J-u-boot.git] / arch / arm / lib / interrupts.c
index 36299d6e54315d196db182e8110a02b3febf1ae1..9961472f69f76098faf61fc4b04faf6c6f22d7dc 100644 (file)
 #include <cpu_func.h>
 #include <efi_loader.h>
 #include <irq_func.h>
+#include <semihosting.h>
+#include <asm/global_data.h>
 #include <asm/proc-armv/ptrace.h>
+#include <asm/ptrace.h>
 #include <asm/u-boot-arm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -51,7 +54,7 @@ int disable_interrupts(void)
 void bad_mode (void)
 {
        panic ("Resetting CPU ...\n");
-       reset_cpu(0);
+       reset_cpu();
 }
 
 static void show_efi_loaded_images(struct pt_regs *regs)
@@ -133,6 +136,32 @@ static inline void fixup_pc(struct pt_regs *regs, int offset)
        regs->ARM_pc = pc | (regs->ARM_pc & PCMASK);
 }
 
+/*
+ * Try to "emulate" a semihosting call in the event that we don't have a
+ * debugger attached.
+ */
+static bool smh_emulate_trap(struct pt_regs *regs)
+{
+       if (regs->ARM_cpsr & T_BIT) {
+               u16 *insn = (u16 *)(regs->ARM_pc - 2);
+
+               if (*insn != SMH_T32_SVC)
+                       return false;
+       } else {
+               u32 *insn = (u32 *)(regs->ARM_pc - 4);
+
+               if (*insn != SMH_A32_SVC)
+                       return false;
+       }
+
+       /* Avoid future semihosting calls */
+       disable_semihosting();
+
+       /* Just pretend the call failed */
+       regs->ARM_r0 = -1;
+       return true;
+}
+
 void do_undefined_instruction (struct pt_regs *pt_regs)
 {
        efi_restore_gd();
@@ -145,6 +174,10 @@ void do_undefined_instruction (struct pt_regs *pt_regs)
 
 void do_software_interrupt (struct pt_regs *pt_regs)
 {
+       if (CONFIG_IS_ENABLED(SEMIHOSTING_FALLBACK) &&
+           smh_emulate_trap(pt_regs))
+               return;
+
        efi_restore_gd();
        printf ("software interrupt\n");
        fixup_pc(pt_regs, -4);
This page took 0.036346 seconds and 4 git commands to generate.