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