public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Siarhei Siamashka <siarhei.siamashka@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] sunxi: Use Thumb2 and move stack to gain more SRAM space in FEL mode
Date: Fri, 25 Jul 2014 04:01:43 +0300	[thread overview]
Message-ID: <20140725040143.30fc3eb9@i7> (raw)
In-Reply-To: <1405967505.27009.58.camel@dagon.hellion.org.uk>

On Mon, 21 Jul 2014 19:31:45 +0100
Ian Campbell <ijc@hellion.org.uk> wrote:

> On Fri, 2014-07-18 at 20:09 +0300, Siarhei Siamashka wrote:
> 
> > 
> > http://lists.phcomp.co.uk/pipermail/arm-netbook/2012-June/004341.html
> 
> I think a better reference is
> https://github.com/hno/Allwinner-Info/blob/master/FEL-usb/USB-protocol.txt

Yes, very likely. Except that I'm a little bit concerned about the
long term availability of this link (which is a personal repository
on github).

I have quoted the relevant parts of the memory map information in the
commit message. But now I wonder if we should replicate the Allwinner
FEL mode memory map information somewhere in the u-boot documentation?

> > +.syntax unified
> > +.text
> > +.arm
> > +.arch armv7a
> > +.p2align 2
> > +
> > +.globl _start_fel
> 
> Is there any reason not to use ENTRY() for this?

Yes, we can use it. Thanks for the hint.

> > +.globl s_init
> > +.globl __bss_start
> > +.globl __bss_end
> 
> I don't think you need .globl to access external symbols, all .globl
> does is control the visibility of things defined in this file. IOW you
> can drop all 3 of these AFAICT.

You are right, "info as" indeed says that "`as' treats all undefined
symbols as external"

> [...]
> > +	/* Pass control to the 's_init()' function */
> > +	b	s_init
> 
> Since this code is in arm mode and s_init will, I think, be in Thumb
> mode after this patch shouldn't this be a bx?

Since this branch instruction refers to an external symbol, the linker
has all the necessary information and takes care of handling Thumb
interworking whenever it is necessary.

And GCC is normally using 'b' and 'bl' instructions in such cases. For
example, let's have a look at the following C source code:

   extern int bar(void);
   int foo(int (*baz)(void)) { return bar() + baz(); }

If we compile it as "-march=armv7-a -O2 -marm", then we get the
following code in the object file:

00000000 <foo>:
   0:	e92d4038 	push	{r3, r4, r5, lr}
   4:	e1a05000 	mov	r5, r0
   8:	ebfffffe 	bl	0 <bar>
   c:	e1a04000 	mov	r4, r0
  10:	e12fff35 	blx	r5
  14:	e0840000 	add	r0, r4, r0
  18:	e8bd8038 	pop	{r3, r4, r5, pc}

However if we link the very same object file into an executable
(with the 'bar' function compiled in Thumb2 mode), the linker
does the 'bl' -> 'blx' conversion automatically:

00008440 <bar>:
    8440:	2001      	movs	r0, #1
    8442:	4770      	bx	lr

00008444 <foo>:
    8444:	e92d4038 	push	{r3, r4, r5, lr}
    8448:	e1a05000 	mov	r5, r0
    844c:	fafffffb 	blx	8440 <bar>
    8450:	e1a04000 	mov	r4, r0
    8454:	e12fff35 	blx	r5
    8458:	e0840000 	add	r0, r4, r0
    845c:	e8bd8038 	pop	{r3, r4, r5, pc}

-- 
Best regards,
Siarhei Siamashka

  reply	other threads:[~2014-07-25  1:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18 17:09 [U-Boot] [PATCH 0/2] sunxi: FEL boot mode improvements Siarhei Siamashka
2014-07-18 17:09 ` [U-Boot] [PATCH 1/2] sunxi: Use Thumb2 and move stack to gain more SRAM space in FEL mode Siarhei Siamashka
2014-07-19 11:19   ` Hans de Goede
2014-07-21 18:31   ` Ian Campbell
2014-07-25  1:01     ` Siarhei Siamashka [this message]
2014-07-25  1:03       ` [U-Boot] [linux-sunxi] " Julian Calaby
2014-07-25  4:11         ` Julian Calaby
2014-07-25  6:56       ` [U-Boot] " Ian Campbell
2014-07-25  1:14   ` Siarhei Siamashka
2014-07-18 17:09 ` [U-Boot] [PATCH 2/2] sunxi: Set the AUXCR L2EN bit for sun4i/sun5i in FEL boot mode Siarhei Siamashka
2014-07-18 18:47   ` Jeroen Hofstee
2014-07-21 20:07     ` Ian Campbell
2014-07-21 20:39       ` Jeroen Hofstee
2014-07-21 20:59         ` Ian Campbell
2014-07-25  0:21           ` Siarhei Siamashka
2014-07-25  6:55             ` Ian Campbell
2014-07-19 11:20   ` Hans de Goede
2014-07-21 18:39     ` Ian Campbell
2014-07-21 20:34       ` Ian Campbell

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=20140725040143.30fc3eb9@i7 \
    --to=siarhei.siamashka@gmail.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