On Mon, 21 Jul 2014 19:31:45 +0100
Ian Campbell <[email protected]> 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
_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to