public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/6] common/cmd_boot: keep ARM v7M in thumb mode during do_go_exec()
Date: Tue, 21 Apr 2015 13:05:24 -0500	[thread overview]
Message-ID: <20150421180524.GD7166@saruman.tx.rr.com> (raw)
In-Reply-To: <20150421180131.GP21096@beef>

On Tue, Apr 21, 2015 at 02:01:31PM -0400, Matt Porter wrote:
> On Tue, Apr 21, 2015 at 12:47:24PM -0500, Felipe Balbi wrote:
> > On Tue, Apr 21, 2015 at 01:36:54PM -0400, Matt Porter wrote:
> > > On ARM v7M, the processor will return to ARM mode when executing
> > > a blx instruction with bit 0 of the address == 0. Always set it
> > 
> > but that's what the 'x' is for, right ? eXchange the CPU mode.
> 
> Yes.
> 
> > > to 1 to stay in thumb mode.
> > > 
> > > Signed-off-by: Matt Porter <mporter@konsulko.com>
> > > ---
> > >  common/cmd_boot.c | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > > 
> > > diff --git a/common/cmd_boot.c b/common/cmd_boot.c
> > > index 8f2e070..20ce652 100644
> > > --- a/common/cmd_boot.c
> > > +++ b/common/cmd_boot.c
> > > @@ -38,6 +38,10 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> > >  	 * pass address parameter as argv[0] (aka command name),
> > >  	 * and all remaining args
> > >  	 */
> > > +#ifdef CONFIG_CPU_V7M
> > > +	/* For ARM V7M, set bit zero to stay in Thumb mode */
> > > +	addr++;
> > > +#endif
> > 
> > what if we were in ARM state when we reached this point ? You're now
> > telling CPU to always switch to Thumb. Is this really what we want ?
> 
> We have no ARM state on this core so that's not possible.
> 
> > From ARM's instruction manual:
> > 
> > 
> > 
> > "
> > The BX and BLX instructions can change the processor state from ARM to
> > Thumb, or from Thumb to ARM.
> > 
> > BLX label always changes the state.
> > 
> > BX Rm and BLX Rm derive the target state from bit[0] of Rm:
> > 
> >     if bit[0] of Rm is 0, the processor changes to, or remains in, ARM
> >     state
> > 
> >     if bit[0] of Rm is 1, the processor changes to, or remains in, Thumb
> >     state.
> 
> Correct. The last statement is why this patch exists. There is no ARM
> mode on M3, we immediately fault. Having bit[0]=0 for BX/BLX is not
> permitted on V7M...something not covered in the generic description
> of these instructions.

it just seems weird that bit0 wouldn't just be assume 1 by the core
itself. I suppose as a consequence we can't use blx label with v7m
either ? :-s

cheers

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150421/6da24df5/attachment.sig>

  reply	other threads:[~2015-04-21 18:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 17:36 [U-Boot] [PATCH v2 0/6] Add ARMv7M STM32F1 and STM3210E-EVAL board support Matt Porter
2015-04-21 17:36 ` [U-Boot] [PATCH v2 1/6] image: fix build when CONFIG_NR_DRAM_BANKS is disabled on ARM Matt Porter
2015-04-21 17:36 ` [U-Boot] [PATCH v2 2/6] common/cmd_boot: keep ARM v7M in thumb mode during do_go_exec() Matt Porter
2015-04-21 17:47   ` Felipe Balbi
2015-04-21 17:54     ` Felipe Balbi
2015-04-21 17:57       ` Felipe Balbi
2015-04-21 18:06         ` Matt Porter
2015-04-21 18:01     ` Matt Porter
2015-04-21 18:05       ` Felipe Balbi [this message]
2015-04-21 18:22         ` Matt Porter
2015-04-21 19:07         ` Tom Rini
2015-04-21 20:09           ` Felipe Balbi
2015-04-21 17:36 ` [U-Boot] [PATCH v2 3/6] ARMv7M: add STM32F1 support Matt Porter
2015-04-21 17:36 ` [U-Boot] [PATCH v2 4/6] gpio: stm32: add stm32f1 support Matt Porter
2015-04-21 17:36 ` [U-Boot] [PATCH v2 5/6] serial: " Matt Porter
2015-04-21 17:36 ` [U-Boot] [PATCH v2 6/6] board: add stm3210e-eval board support Matt Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150421180524.GD7166@saruman.tx.rr.com \
    --to=balbi@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox