All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] Relocation confusion
@ 2009-04-22 15:59 Drasko DRASKOVIC
  2009-04-23  4:34 ` Po-Yu Chuang
  0 siblings, 1 reply; 2+ messages in thread
From: Drasko DRASKOVIC @ 2009-04-22 15:59 UTC (permalink / raw)
  To: u-boot

Hi all,
I have some questions regarding start.S code for arm926ejs. Looking at the
relocation code of u-boot:

relocate:                   /* relocate U-Boot to RAM        */
    adr    r0, _start            /* r0 <- current position of code   */
    ldr    r1, _TEXT_BASE        /* test if we run from flash or RAM */
    cmp     r0, r1          /* don't reloc during debug         */
    beq     stack_setup

    ldr    r2, _armboot_start
    ldr    r3, _bss_start
    sub    r2, r3, r2            /* r2 <- size of armboot            */
    add    r2, r0, r2            /* r2 <- source end address         */


1) What is exactly difference between _start and _armboot_start ? I can see
in the same file definition of _armboot_start :

.globl _armboot_start
_armboot_start:
    .word _start

So, I am confused there - it looks like they are the same thing.

2)  Line:
 sub    r2, r3, r2
is logical, but after we do :
add    r2, r0, r2      /* r2 <- source end address         */
to find source end address. But if _start and _armboot_start are the same,
we already have this source end address : it is _bss_start.

3) Based on this, if _armboot_start and _start are not the same thing, I
could guess that _start is pointing@0x0 of the flash (or SDRAM), i.e. it
is uP entry point after reset, and _armboot_start is the place where we
start to put u-boot instructions (TEXT section). That would mean that we
either have
a) some program uP will execute before u-boot. What could that ever be?
b) some section of u-boot that goes before TEXT section, and will never be
relocated to RAM _TEXT_BASE. What could that ever be?

Thanks for your answers.

Best regards,
Drasko DRASKOVIC

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [U-Boot] Relocation confusion
  2009-04-22 15:59 [U-Boot] Relocation confusion Drasko DRASKOVIC
@ 2009-04-23  4:34 ` Po-Yu Chuang
  0 siblings, 0 replies; 2+ messages in thread
From: Po-Yu Chuang @ 2009-04-23  4:34 UTC (permalink / raw)
  To: u-boot

Hi Drasko DRASKOVIC,


"adr" is to calculate a runtime address by PC+offset.
"adr r0, _start" is like:
"add r0, pc, #0x80" for example.

e.g. TEXT_BASE == 0x1000 0000 and you are using u-boot to boot from flash.

link address of _start probably equals to 0x1000 0000
the location _armboot_start stores the link address of _start

Therefore,
adr    r0, _start
you probably got r0 == 0.

ldr    r2, _armboot_start
you probably got r2 == 0x1000 0000.

It is just some assembly tricks.


regards

Po-Yu Chuang

2009/4/22 Drasko DRASKOVIC <drasko.draskovic@gmail.com>
>
> Hi all,
> I have some questions regarding start.S code for arm926ejs. Looking at the
> relocation code of u-boot:
>
> relocate: ? ? ? ? ? ? ? ? ? /* relocate U-Boot to RAM ? ? ? ?*/
> ? ?adr ? ?r0, _start ? ? ? ? ? ?/* r0 <- current position of code ? */
> ? ?ldr ? ?r1, _TEXT_BASE ? ? ? ?/* test if we run from flash or RAM */
> ? ?cmp ? ? r0, r1 ? ? ? ? ?/* don't reloc during debug ? ? ? ? */
> ? ?beq ? ? stack_setup
>
> ? ?ldr ? ?r2, _armboot_start
> ? ?ldr ? ?r3, _bss_start
> ? ?sub ? ?r2, r3, r2 ? ? ? ? ? ?/* r2 <- size of armboot ? ? ? ? ? ?*/
> ? ?add ? ?r2, r0, r2 ? ? ? ? ? ?/* r2 <- source end address ? ? ? ? */
>
>
> 1) What is exactly difference between _start and _armboot_start ? I can see
> in the same file definition of _armboot_start :
>
> .globl _armboot_start
> _armboot_start:
> ? ?.word _start
>
> So, I am confused there - it looks like they are the same thing.
>
> 2) ?Line:
> ?sub ? ?r2, r3, r2
> is logical, but after we do :
> add ? ?r2, r0, r2 ? ? ?/* r2 <- source end address ? ? ? ? */
> to find source end address. But if _start and _armboot_start are the same,
> we already have this source end address : it is _bss_start.
>
> 3) Based on this, if _armboot_start and _start are not the same thing, I
> could guess that _start is pointing at 0x0 of the flash (or SDRAM), i.e. it
> is uP entry point after reset, and _armboot_start is the place where we
> start to put u-boot instructions (TEXT section). That would mean that we
> either have
> a) some program uP will execute before u-boot. What could that ever be?
> b) some section of u-boot that goes before TEXT section, and will never be
> relocated to RAM _TEXT_BASE. What could that ever be?
>
> Thanks for your answers.
>
> Best regards,
> Drasko DRASKOVIC
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-23  4:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-22 15:59 [U-Boot] Relocation confusion Drasko DRASKOVIC
2009-04-23  4:34 ` Po-Yu Chuang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.