summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r--arch/arm/cpu/cpu.c27
-rw-r--r--arch/arm/cpu/exceptions.S1
-rw-r--r--arch/arm/cpu/start.c1
3 files changed, 29 insertions, 0 deletions
diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
index cf31e8bb2e..71ef8c06d6 100644
--- a/arch/arm/cpu/cpu.c
+++ b/arch/arm/cpu/cpu.c
@@ -26,6 +26,7 @@
*/
#include <common.h>
+#include <init.h>
#include <command.h>
#include <cache.h>
#include <asm/mmu.h>
@@ -89,3 +90,29 @@ void arch_shutdown(void)
);
#endif
}
+
+#ifdef CONFIG_THUMB2_BAREBOX
+static void thumb2_execute(void *func, int argc, char *argv[])
+{
+ /*
+ * Switch back to arm mode before executing external
+ * programs.
+ */
+ __asm__ __volatile__ (
+ "mov r0, #0\n"
+ "mov r1, %0\n"
+ "mov r2, %1\n"
+ "bx %2\n"
+ :
+ : "r" (argc - 1), "r" (&argv[1]), "r" (func)
+ : "r0", "r1", "r2"
+ );
+}
+
+static int execute_init(void)
+{
+ do_execute = thumb2_execute;
+ return 0;
+}
+postcore_initcall(execute_init);
+#endif
diff --git a/arch/arm/cpu/exceptions.S b/arch/arm/cpu/exceptions.S
index 6f35d408f4..c08537a405 100644
--- a/arch/arm/cpu/exceptions.S
+++ b/arch/arm/cpu/exceptions.S
@@ -106,6 +106,7 @@ _STACK_START:
* exception handlers
*/
.section ".text","ax"
+ .arm
.align 5
.globl undefined_instruction
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 89aff1dc05..f65b46d1d1 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -36,6 +36,7 @@ void __naked __section(.text_entry) start(void)
void __naked __section(.text_exceptions) exception_vectors(void)
{
__asm__ __volatile__ (
+ ".arm\n"
"b reset\n" /* reset */
#ifdef CONFIG_ARM_EXCEPTIONS
"ldr pc, =undefined_instruction\n" /* undefined instruction */