1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * (C) Copyright 2008-2011
3*4882a593Smuzhiyun * Graeme Russ, <graeme.russ@gmail.com>
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * (C) Copyright 2002
6*4882a593Smuzhiyun * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * (C) Copyright 2002
9*4882a593Smuzhiyun * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
10*4882a593Smuzhiyun *
11*4882a593Smuzhiyun * (C) Copyright 2002
12*4882a593Smuzhiyun * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
13*4882a593Smuzhiyun * Marius Groeger <mgroeger@sysgo.de>
14*4882a593Smuzhiyun *
15*4882a593Smuzhiyun * Copyright 2015 ATS Advanced Telematics Systems GmbH
16*4882a593Smuzhiyun * Copyright 2015 Konsulko Group, Matt Porter <mporter@konsulko.com>
17*4882a593Smuzhiyun *
18*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+
19*4882a593Smuzhiyun */
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun #include <common.h>
22*4882a593Smuzhiyun #include <command.h>
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun DECLARE_GLOBAL_DATA_PTR;
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun /*
27*4882a593Smuzhiyun * ARMv7M does not support ARM instruction mode. However, the
28*4882a593Smuzhiyun * interworking BLX and BX instructions do encode the ARM/Thumb
29*4882a593Smuzhiyun * field in bit 0. This means that when executing any Branch
30*4882a593Smuzhiyun * and eXchange instruction we must set bit 0 to one to guarantee
31*4882a593Smuzhiyun * that we keep the processor in Thumb instruction mode. From The
32*4882a593Smuzhiyun * ARMv7-M Instruction Set A4.1.1:
33*4882a593Smuzhiyun * "ARMv7-M only supports the Thumb instruction execution state,
34*4882a593Smuzhiyun * therefore the value of address bit [0] must be 1 in interworking
35*4882a593Smuzhiyun * instructions, otherwise a fault occurs."
36*4882a593Smuzhiyun */
do_go_exec(ulong (* entry)(int,char * const[]),int argc,char * const argv[])37*4882a593Smuzhiyun unsigned long do_go_exec(ulong (*entry)(int, char * const []),
38*4882a593Smuzhiyun int argc, char * const argv[])
39*4882a593Smuzhiyun {
40*4882a593Smuzhiyun ulong addr = (ulong)entry | 1;
41*4882a593Smuzhiyun entry = (void *)addr;
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun return entry(argc, argv);
44*4882a593Smuzhiyun }
45