All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] Most ARM CPU's have buggy clear_bss?
@ 2010-10-27  7:26 Darius Augulis
  2010-10-27  8:01 ` Sughosh Ganu
                   ` (3 more replies)
  0 siblings, 4 replies; 56+ messages in thread
From: Darius Augulis @ 2010-10-27  7:26 UTC (permalink / raw)
  To: u-boot

Hi list,

the code for clearing bss section for most ARM cores looks like this
or very similar:

clear_bss:
#ifndef CONFIG_PRELOADER
        ldr     r0, _bss_start_ofs
        ldr     r1, _bss_end_ofs
        ldr     r3, _TEXT_BASE          /* Text base */
        mov     r4, r7                  /* reloc addr */
        add     r0, r0, r4
        add     r1, r1, r4
        mov     r2, #0x00000000         /* clear                            */

clbss_l:str     r2, [r0]                /* clear loop...                    */
        add     r0, r0, #4
        cmp     r0, r1
        bne     clbss_l
#endif  /* #ifndef CONFIG_PRELOADER */


IMO, if relocation is skipped, r4 should be loaded with value of
_TEXT_BASE, not reloc address?
It seems like r3 is prepared for this but, it's somehow missing? It's
not used at all.
Maybe it could be reason why I'm facing strange problem, when after
relocating uboot with nand_spl no one command is not working.
I debugged that command table is empty. I think this ASM code clears
not bss area but something else.

Also relocation code looks a bit strange:

        .globl  relocate_code
relocate_code:
        mov     r4, r0  /* save addr_sp */
        mov     r5, r1  /* save addr of gd */
        mov     r6, r2  /* save addr of destination */
        mov     r7, r2  /* save addr of destination */

        /* Set up the stack                                                 */
stack_setup:
        mov     sp, r4

        adr     r0, _start
        ldr     r2, _TEXT_BASE
        ldr     r3, _bss_start_ofs
        add     r2, r0, r3              /* r2 <- source end address         */
        cmp     r0, r6
        beq     clear_bss

r0 is compared to r6, which contains reloc address. All instructions
between loading r0 and comparison are confusing, because they do not
impact comparison result.
Also they do not matter in clear_bss so I think would be great to
change code like this:

        mov     sp, r4

        adr     r0, _start
        cmp     r0, r6
        beq     clear_bss
        ldr     r2, _TEXT_BASE
        ldr     r3, _bss_start_ofs
        add     r2, r0, r3              /* r2 <- source end address         */

Any comments are welcome!

Regards,
Darius.

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

end of thread, other threads:[~2010-10-29 16:56 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-27  7:26 [U-Boot] Most ARM CPU's have buggy clear_bss? Darius Augulis
2010-10-27  8:01 ` Sughosh Ganu
2010-10-27  8:22   ` Darius Augulis
2010-10-27  8:54     ` Sughosh Ganu
2010-10-27  8:58       ` Darius Augulis
2010-10-27  9:09         ` Sughosh Ganu
2010-10-27 10:10           ` Darius Augulis
2010-10-27 10:40             ` Wolfgang Denk
2010-10-27 10:59               ` Darius Augulis
2010-10-27 11:41                 ` Wolfgang Denk
2010-10-27 15:12 ` Eric Cooper
2010-10-27 18:11   ` Darius Augulis
2010-10-28  5:50     ` Heiko Schocher
2010-10-28  6:09       ` Reinhard Meyer
2010-10-28  6:17         ` Heiko Schocher
2010-10-28  6:20           ` Reinhard Meyer
2010-10-28  6:23             ` Reinhard Meyer
2010-10-28  6:35               ` Heiko Schocher
2010-10-28  6:14 ` Heiko Schocher
2010-10-28  6:36   ` Reinhard Meyer
2010-10-28  6:56     ` Darius Augulis
2010-10-28  8:36       ` Wolfgang Denk
2010-10-28  8:31     ` Wolfgang Denk
2010-10-28  8:39   ` Wolfgang Denk
2010-10-28  8:53     ` Heiko Schocher
2010-10-28 10:23     ` Alexander Holler
2010-10-28 11:16       ` Reinhard Meyer
2010-10-28 11:38         ` Wolfgang Denk
2010-10-28 11:55           ` Reinhard Meyer
2010-10-29  9:29           ` Albert ARIBAUD
2010-10-28 11:46         ` [U-Boot] CONFIG_SKIP_RELOCATE_UBOOT still used? Alexander Holler
2010-10-29  9:32           ` Albert ARIBAUD
2010-10-29 11:32             ` Alexander Holler
2010-10-29 11:43               ` Albert ARIBAUD
2010-10-29 11:48                 ` Wolfgang Denk
2010-10-28  9:03 ` [U-Boot] Most ARM CPU's have buggy clear_bss? Alexander Holler
2010-10-28  9:31   ` Alexander Holler
2010-10-29  8:50     ` Alexander Holler
2010-10-29  9:19       ` Albert ARIBAUD
2010-10-29 11:56         ` Alexander Holler
2010-10-29 12:08           ` Albert ARIBAUD
2010-10-29 12:31             ` Alexander Holler
2010-10-29 13:37               ` Albert ARIBAUD
2010-10-29 13:50                 ` Alexander Holler
2010-10-29 14:04                   ` Albert ARIBAUD
2010-10-29 14:37                 ` Alexander Holler
2010-10-29 14:44                   ` Wolfgang Denk
2010-10-29 14:50                     ` Alexander Holler
2010-10-29 14:50                   ` Reinhard Meyer
2010-10-29 14:58                     ` Alexander Holler
2010-10-29 14:54                   ` Albert ARIBAUD
2010-10-29 15:05                     ` Alexander Holler
2010-10-29 15:23                       ` Albert ARIBAUD
2010-10-29 15:32                         ` Alexander Holler
2010-10-29 15:38                           ` Albert ARIBAUD
2010-10-29 16:56                             ` Alexander Holler

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.