All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
@ 2010-08-11 18:15 Heiko Schocher
  2010-08-11 20:00 ` Ben Gardiner
                   ` (3 more replies)
  0 siblings, 4 replies; 60+ messages in thread
From: Heiko Schocher @ 2010-08-11 18:15 UTC (permalink / raw)
  To: u-boot

This patch series add full relocation and cache support for arm
based boards. I test this for arm1136, arm_cortexa8 and arm926ejs
based boards.

Relocation support:

!! This change is not compatible to old code !!

If you want to compile in old style, you can set

CONFIG_SYS_ARM_WITHOUT_RELOC

but this possibility will be removed soon, so please
adapt your board(s)

changed arch/arm/lib/board.c to get inline with arch/powerpc/lib/board.c
maybe it is possible to snyc them to one arch/generic/lib/board.c?

This approach is similiar to powerpc, so there is a need for
an initial stack pointer addr defined through CONFIG_SYS_INIT_SP_ADDR.

Please also read doc/README.arm-relocation There is more
info what is done, and maybe should be done.

Cache support:

I used the patches from Alessandro Rubini:
http://lists.denx.de/pipermail/u-boot/2010-January/067099.html

and rebased them to actual code. Also, in case of full relocation,
the position of the TLB can not be set on compile time, instead
it is calculated in board_init_f() and stored in gd. Also added
cache support for arm_cortexa8 and arm1136.

Heiko Schocher (26):
      arm: get rid of bi_env
      ARM: flush cache for arm926
      ARM: cp15: setup mmu and enable dcache
      ARM V7 (OMAP): add data cache support, test on Beagle board
      ARM (ARM11): add data cache support, test on Qong board
      relocation: fixup cmdtable
      common: move TOTAL_MALLOC_LEN to include/common.h
      i2c: fix command usage help
      disk/part.c: fix relocation fixup
      i2c, omap24xx: set bus_initialized only after relocation.
      nand_boot_fsl_nfc.c: make "nfc" a "static const" pointer
      ARM: add relocation support
      ARM: implement relocation for ARM11
      ARM: implement relocation for ARM V7 (OMAP)
      ARM: implement relocation for ARM926
      ARM: implement relocation for ARM920
      ARM: implement relocation for ARM925
      ARM: implement relocation for ARM946
      ARM: implement relocation for pxa
      ARM: implement relocation for ixp
      ARM: implement relocation for sa1100
      ARM: implement relocation for s3c44b0
      ARM: implement relocation for lh7a40x
      ARM: implement relocation for arm_intcm
      ARM: implement relocation for arm720t
      ARM: implement relocation for arm1176

 arch/arm/config.mk                    |    8 +
 arch/arm/cpu/arm1136/start.S          |  206 +++++++++++++++
 arch/arm/cpu/arm1136/u-boot.lds       |   14 +-
 arch/arm/cpu/arm1176/start.S          |  286 ++++++++++++++++++++
 arch/arm/cpu/arm1176/u-boot.lds       |   14 +-
 arch/arm/cpu/arm720t/start.S          |  170 ++++++++++++
 arch/arm/cpu/arm720t/u-boot.lds       |   14 +-
 arch/arm/cpu/arm920t/start.S          |  225 ++++++++++++++++-
 arch/arm/cpu/arm920t/u-boot.lds       |   14 +-
 arch/arm/cpu/arm925t/start.S          |  204 ++++++++++++++-
 arch/arm/cpu/arm925t/u-boot.lds       |   14 +-
 arch/arm/cpu/arm926ejs/orion5x/dram.c |   24 ++-
 arch/arm/cpu/arm926ejs/start.S        |  172 ++++++++++++-
 arch/arm/cpu/arm926ejs/u-boot.lds     |   14 +-
 arch/arm/cpu/arm946es/start.S         |  168 ++++++++++++-
 arch/arm/cpu/arm946es/u-boot.lds      |   14 +-
 arch/arm/cpu/arm_intcm/start.S        |  166 ++++++++++++
 arch/arm/cpu/arm_intcm/u-boot.lds     |   14 +-
 arch/arm/cpu/armv7/mx51/u-boot.lds    |   14 +-
 arch/arm/cpu/armv7/omap3/cache.S      |   82 ++++++
 arch/arm/cpu/armv7/omap3/emif4.c      |   34 +++
 arch/arm/cpu/armv7/omap3/sdrc.c       |   38 +++
 arch/arm/cpu/armv7/start.S            |  191 +++++++++++++-
 arch/arm/cpu/armv7/u-boot.lds         |   14 +-
 arch/arm/cpu/ixp/start.S              |  280 ++++++++++++++++++++
 arch/arm/cpu/ixp/u-boot.lds           |   14 +-
 arch/arm/cpu/lh7a40x/start.S          |  187 +++++++++++++-
 arch/arm/cpu/lh7a40x/u-boot.lds       |   14 +-
 arch/arm/cpu/pxa/start.S              |  168 ++++++++++++
 arch/arm/cpu/pxa/u-boot.lds           |   14 +-
 arch/arm/cpu/s3c44b0/start.S          |  174 ++++++++++++
 arch/arm/cpu/s3c44b0/u-boot.lds       |   14 +-
 arch/arm/cpu/sa1100/start.S           |  162 ++++++++++++
 arch/arm/cpu/sa1100/u-boot.lds        |   14 +-
 arch/arm/include/asm/config.h         |    3 +-
 arch/arm/include/asm/global_data.h    |   11 +
 arch/arm/include/asm/u-boot-arm.h     |   14 +-
 arch/arm/include/asm/u-boot.h         |    4 -
 arch/arm/lib/board.c                  |  468 ++++++++++++++++++++++++++++++++-
 arch/arm/lib/cache-cp15.c             |   82 ++++++
 arch/arm/lib/cache.c                  |   13 +-
 arch/arm/lib/interrupts.c             |   19 ++-
 arch/avr32/include/asm/u-boot.h       |    1 -
 arch/avr32/lib/board.c                |   25 +--
 arch/i386/include/asm/u-boot.h        |    4 -
 arch/m68k/lib/board.c                 |   35 +---
 arch/mips/include/asm/u-boot.h        |    2 -
 arch/mips/lib/board.c                 |   36 +---
 arch/powerpc/lib/board.c              |   10 -
 arch/sparc/lib/board.c                |   28 +--
 board/davedenx/qong/config.mk         |    4 +-
 board/davedenx/qong/qong.c            |   87 ++++---
 board/karo/tx25/config.mk             |    4 +-
 board/karo/tx25/tx25.c                |   11 +-
 board/keymile/km_arm/km_arm.c         |   24 ++
 board/logicpd/imx27lite/config.mk     |    2 +-
 board/logicpd/imx27lite/imx27lite.c   |   15 +-
 board/ti/beagle/config.mk             |    2 +-
 common/cmd_bdinfo.c                   |   12 +-
 common/cmd_bmp.c                      |    6 +
 common/cmd_i2c.c                      |    9 +
 common/command.c                      |   37 +++
 disk/part.c                           |   11 +-
 doc/README.arm-relocation             |  321 ++++++++++++++++++++++
 drivers/i2c/omap24xx_i2c.c            |    4 +-
 include/command.h                     |    3 +
 include/common.h                      |    9 +
 include/configs/da850evm.h            |    6 +-
 include/configs/imx27lite-common.h    |    5 +
 include/configs/km_arm.h              |    4 +
 include/configs/omap3_beagle.h        |    6 +
 include/configs/qong.h                |   11 +
 include/configs/tx25.h                |   13 +-
 nand_spl/board/karo/tx25/u-boot.lds   |   14 +-
 nand_spl/nand_boot.c                  |    7 +
 nand_spl/nand_boot_fsl_nfc.c          |   13 +-
 76 files changed, 4320 insertions(+), 230 deletions(-)
 create mode 100644 doc/README.arm-relocation

- changes since previous patch set
  - add CONFIG_SYS_ARM_WITHOUT_RELOC
  - changed order of patches -> cache patches are independent
    from relocation patches
  - add missing cpu types:
    arm1176  arm720t  arm920t  arm925t  arm946es  arm_intcm
    ixp  lh7a40x  pxa  s3c44b0  sa1100
  - only converted boards which I had tested
  - rebased againt current top of tree
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-11 18:15 [U-Boot] [PATCH 00/26] arm: add full relocation / cache support Heiko Schocher
@ 2010-08-11 20:00 ` Ben Gardiner
  2010-08-11 20:36   ` Ben Gardiner
  2010-08-11 20:01 ` Wolfgang Denk
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 60+ messages in thread
From: Ben Gardiner @ 2010-08-11 20:00 UTC (permalink / raw)
  To: u-boot

On Wed, Aug 11, 2010 at 2:15 PM, Heiko Schocher <hs@denx.de> wrote:
> This patch series add full relocation and cache support for arm
> based boards. I test this for arm1136, arm_cortexa8 and arm926ejs
> based boards.

I pulled u-boot-testing/arm-reloc-and-cache-support and had to clobber
the old branch cause I forgot that it was a rebased branch, so don't
have the old series against which to perform any comparisons, sorry.

Tested 046be127bbccfafe8b84c656ed87e1873e8a63d4 of
git://git.denx.de/u-boot-testing.git with da850evm_config.

The board did not come up. I set a breakpoint in relocate_code and got
a register dump as requested in previous email threads.

(gdb) hbreak relocate_code
Hardware assisted breakpoint 1 at 0xc1080088: file start.S, line 218.
(gdb) c
Continuing.

Breakpoint 1, relocate_code () at start.S:219
219             mov     r5, r1  /* save addr of gd */
(gdb) info registers
r0             0xbfebdfa8       3219906472
r1             0xbfebdfac       3219906476
r2             0xbffd2000       3221037056
r3             0x3c     60
r4             0xbfebdfa8       3219906472
r5             0x0      0
r6             0xbfebdfa8       3219906472
r7             0xbfebdfac       3219906476
r8             0xc0000f80       3221229440
r9             0x0      0
r10            0xc1097014       3238621204
r11            0xe8e5134        244207924
r12            0xbfebdfe8       3219906536
sp             0xc0000f80       0xc0000f80
lr             0xc108076c       3238528876
pc             0xc1080088       0xc1080088 <relocate_code+4>
fps            0x0      0
cpsr           0x600000d3       1610612947

.. step to start.S:302 where we have 'move lr,r2'

(gdb) info registers
r0             0xbfebdfac       3219906476
r1             0xbffd2000       3221037056
r2             0xbffd2540       3221038400
r3             0xc1080000       3238526976
r4             0xbffd2000       3221037056
r5             0xbfebdfac       3219906476
r6             0xbffe9610       3221132816
r7             0xbffd2000       3221037056
r8             0xc06ffff0       3228565488
r9             0x0      0
r10            0xffbffef7       4290772727
r11            0xe8e5134        244207924
r12            0xbfebdfe8       3219906536
sp             0xbfebdfa8       0xbfebdfa8
lr             0xc108013c       3238527292
pc             0xc1080154       0xc1080154 <clbss_l+48>
fps            0x0      0
cpsr           0x600000d3       1610612947

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-11 18:15 [U-Boot] [PATCH 00/26] arm: add full relocation / cache support Heiko Schocher
  2010-08-11 20:00 ` Ben Gardiner
@ 2010-08-11 20:01 ` Wolfgang Denk
  2010-08-12  5:34   ` Heiko Schocher
  2010-08-12 20:49   ` Magnus Lilja
  2010-08-12 12:50 ` Shinya Kuribayashi
  2010-09-17 11:10 ` [U-Boot] [PATCH 00/26 v2][NEXT] " Heiko Schocher
  3 siblings, 2 replies; 60+ messages in thread
From: Wolfgang Denk @ 2010-08-11 20:01 UTC (permalink / raw)
  To: u-boot

Dear Heiko Schocher,

a few comments...

In message <4C62E8C3.8050006@denx.de> you wrote:
> This patch series add full relocation and cache support for arm
> based boards. I test this for arm1136, arm_cortexa8 and arm926ejs
> based boards.
> 
> Relocation support:
> 
> !! This change is not compatible to old code !!

To make it clear: only the relocation part will break all ports that
have not been adapted yet. One could try and use only the cache
support patches, and skip the reloc stuff for now.

> If you want to compile in old style, you can set
> 
> CONFIG_SYS_ARM_WITHOUT_RELOC
> 
> but this possibility will be removed soon, so please
> adapt your board(s)

The plan is as follows:

I will pull this stuff into the "next" branch about one week after I
released "rc1". I intend to keep this "CONFIG_SYS_ARM_WITHOUT_RELOC"
feature for a full release cycle. Early in the next branch for the
following release it will be removed. Any boards that are not yet
converted then will break. If the breakage does not get fixed by
board maintainers or interested users, we will remove these obviously
unmaintained boards, then.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Anyone who doesn't believe in miracles is not a realist.
                                                   - David Ben Gurion

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-11 20:00 ` Ben Gardiner
@ 2010-08-11 20:36   ` Ben Gardiner
  0 siblings, 0 replies; 60+ messages in thread
From: Ben Gardiner @ 2010-08-11 20:36 UTC (permalink / raw)
  To: u-boot

On Wed, Aug 11, 2010 at 4:00 PM, Ben Gardiner
<bengardiner@nanometrics.ca> wrote:
> On Wed, Aug 11, 2010 at 2:15 PM, Heiko Schocher <hs@denx.de> wrote:
>> This patch series add full relocation and cache support for arm
>> based boards. I test this for arm1136, arm_cortexa8 and arm926ejs
>> based boards.
>
> I pulled u-boot-testing/arm-reloc-and-cache-support and had to clobber
> the old branch cause I forgot that it was a rebased branch, so don't
> have the old series against which to perform any comparisons, sorry.
>
> Tested 046be127bbccfafe8b84c656ed87e1873e8a63d4 of
> git://git.denx.de/u-boot-testing.git with da850evm_config.
>
> The board did not come up. I set a breakpoint in relocate_code and got
> a register dump as requested in previous email threads.
>
> (gdb) hbreak relocate_code
> Hardware assisted breakpoint 1 at 0xc1080088: file start.S, line 218.
> (gdb) c
> Continuing.
>
> Breakpoint 1, relocate_code () at start.S:219
> 219 ? ? ? ? ? ? mov ? ? r5, r1 ?/* save addr of gd */
> (gdb) info registers
> r0 ? ? ? ? ? ? 0xbfebdfa8 ? ? ? 3219906472
> r1 ? ? ? ? ? ? 0xbfebdfac ? ? ? 3219906476
> r2 ? ? ? ? ? ? 0xbffd2000 ? ? ? 3221037056
> r3 ? ? ? ? ? ? 0x3c ? ? 60
> r4 ? ? ? ? ? ? 0xbfebdfa8 ? ? ? 3219906472
> r5 ? ? ? ? ? ? 0x0 ? ? ?0
> r6 ? ? ? ? ? ? 0xbfebdfa8 ? ? ? 3219906472
> r7 ? ? ? ? ? ? 0xbfebdfac ? ? ? 3219906476
> r8 ? ? ? ? ? ? 0xc0000f80 ? ? ? 3221229440
> r9 ? ? ? ? ? ? 0x0 ? ? ?0
> r10 ? ? ? ? ? ?0xc1097014 ? ? ? 3238621204
> r11 ? ? ? ? ? ?0xe8e5134 ? ? ? ?244207924
> r12 ? ? ? ? ? ?0xbfebdfe8 ? ? ? 3219906536
> sp ? ? ? ? ? ? 0xc0000f80 ? ? ? 0xc0000f80
> lr ? ? ? ? ? ? 0xc108076c ? ? ? 3238528876
> pc ? ? ? ? ? ? 0xc1080088 ? ? ? 0xc1080088 <relocate_code+4>
> fps ? ? ? ? ? ?0x0 ? ? ?0
> cpsr ? ? ? ? ? 0x600000d3 ? ? ? 1610612947
>
> .. step to start.S:302 where we have 'move lr,r2'
>
> (gdb) info registers
> r0 ? ? ? ? ? ? 0xbfebdfac ? ? ? 3219906476
> r1 ? ? ? ? ? ? 0xbffd2000 ? ? ? 3221037056
> r2 ? ? ? ? ? ? 0xbffd2540 ? ? ? 3221038400
> r3 ? ? ? ? ? ? 0xc1080000 ? ? ? 3238526976
> r4 ? ? ? ? ? ? 0xbffd2000 ? ? ? 3221037056
> r5 ? ? ? ? ? ? 0xbfebdfac ? ? ? 3219906476
> r6 ? ? ? ? ? ? 0xbffe9610 ? ? ? 3221132816
> r7 ? ? ? ? ? ? 0xbffd2000 ? ? ? 3221037056
> r8 ? ? ? ? ? ? 0xc06ffff0 ? ? ? 3228565488
> r9 ? ? ? ? ? ? 0x0 ? ? ?0
> r10 ? ? ? ? ? ?0xffbffef7 ? ? ? 4290772727
> r11 ? ? ? ? ? ?0xe8e5134 ? ? ? ?244207924
> r12 ? ? ? ? ? ?0xbfebdfe8 ? ? ? 3219906536
> sp ? ? ? ? ? ? 0xbfebdfa8 ? ? ? 0xbfebdfa8
> lr ? ? ? ? ? ? 0xc108013c ? ? ? 3238527292
> pc ? ? ? ? ? ? 0xc1080154 ? ? ? 0xc1080154 <clbss_l+48>
> fps ? ? ? ? ? ?0x0 ? ? ?0
> cpsr ? ? ? ? ? 0x600000d3 ? ? ? 1610612947

Sorry, I forgot that you also wanted gd->ram_size. Which is probably a
problem since it is 0:
(gdb) p gd->ram_size
$1 = 0

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
+1 (613) 592-6776 x239
http://www.nanometrics.ca

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-11 20:01 ` Wolfgang Denk
@ 2010-08-12  5:34   ` Heiko Schocher
  2010-08-12 20:49   ` Magnus Lilja
  1 sibling, 0 replies; 60+ messages in thread
From: Heiko Schocher @ 2010-08-12  5:34 UTC (permalink / raw)
  To: u-boot

Hello Wolfgang,

Wolfgang Denk wrote:
> Dear Heiko Schocher,
> 
> a few comments...
> 
> In message <4C62E8C3.8050006@denx.de> you wrote:
>> This patch series add full relocation and cache support for arm
>> based boards. I test this for arm1136, arm_cortexa8 and arm926ejs
>> based boards.
>>
>> Relocation support:
>>
>> !! This change is not compatible to old code !!
> 
> To make it clear: only the relocation part will break all ports that
> have not been adapted yet. One could try and use only the cache
> support patches, and skip the reloc stuff for now.

Yep, thats right. Or he/she can set "CONFIG_SYS_ARM_WITHOUT_RELOC"

>> If you want to compile in old style, you can set
>>
>> CONFIG_SYS_ARM_WITHOUT_RELOC
>>
>> but this possibility will be removed soon, so please
>> adapt your board(s)
> 
> The plan is as follows:
> 
> I will pull this stuff into the "next" branch about one week after I
> released "rc1". I intend to keep this "CONFIG_SYS_ARM_WITHOUT_RELOC"
> feature for a full release cycle. Early in the next branch for the
> following release it will be removed. Any boards that are not yet
> converted then will break. If the breakage does not get fixed by
> board maintainers or interested users, we will remove these obviously
> unmaintained boards, then.

Ok. Thanks for the clarification.

bye
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-11 18:15 [U-Boot] [PATCH 00/26] arm: add full relocation / cache support Heiko Schocher
  2010-08-11 20:00 ` Ben Gardiner
  2010-08-11 20:01 ` Wolfgang Denk
@ 2010-08-12 12:50 ` Shinya Kuribayashi
  2010-08-12 12:55   ` Shinya Kuribayashi
  2010-08-12 20:17   ` Wolfgang Denk
  2010-09-17 11:10 ` [U-Boot] [PATCH 00/26 v2][NEXT] " Heiko Schocher
  3 siblings, 2 replies; 60+ messages in thread
From: Shinya Kuribayashi @ 2010-08-12 12:50 UTC (permalink / raw)
  To: u-boot

On 08/12/2010 03:15 AM, Heiko Schocher wrote:
> This patch series add full relocation and cache support for arm
> based boards. I test this for arm1136, arm_cortexa8 and arm926ejs
> based boards.
> 
> Relocation support:
> 
> !! This change is not compatible to old code !!
> 
> If you want to compile in old style, you can set
> 
> CONFIG_SYS_ARM_WITHOUT_RELOC
> 
> but this possibility will be removed soon, so please
> adapt your board(s)
> 
> changed arch/arm/lib/board.c to get inline with arch/powerpc/lib/board.c
> maybe it is possible to snyc them to one arch/generic/lib/board.c?
> 
> This approach is similiar to powerpc, so there is a need for
> an initial stack pointer addr defined through CONFIG_SYS_INIT_SP_ADDR.
> 
> Please also read doc/README.arm-relocation There is more
> info what is done, and maybe should be done.
 
It would be gratefull if someone could expalain a bit about this big
change.  What's the primary motivation for full relocation?  I found
a Wiki page (below), is this the one?

http://elinux.org/CELF_Project_Proposal/Rework_ARM_architecture_support_in_U-Boot

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-12 12:50 ` Shinya Kuribayashi
@ 2010-08-12 12:55   ` Shinya Kuribayashi
  2010-08-12 20:19     ` Wolfgang Denk
  2010-08-12 20:17   ` Wolfgang Denk
  1 sibling, 1 reply; 60+ messages in thread
From: Shinya Kuribayashi @ 2010-08-12 12:55 UTC (permalink / raw)
  To: u-boot

On 08/12/2010 09:50 PM, Shinya Kuribayashi wrote:
> It would be gratefull if someone could expalain a bit about this big
> change.  What's the primary motivation for full relocation?

Forgot to mention; the reason why I'd like to know is, because I'm
an ARM newbie, and interested in such topics.

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-12 12:50 ` Shinya Kuribayashi
  2010-08-12 12:55   ` Shinya Kuribayashi
@ 2010-08-12 20:17   ` Wolfgang Denk
  2010-08-13 14:36     ` Shinya Kuribayashi
  1 sibling, 1 reply; 60+ messages in thread
From: Wolfgang Denk @ 2010-08-12 20:17 UTC (permalink / raw)
  To: u-boot

Dear Shinya Kuribayashi,

In message <4C63EE15.4060207@pobox.com> you wrote:
>
> > Please also read doc/README.arm-relocation There is more
> > info what is done, and maybe should be done.
>  
> It would be gratefull if someone could expalain a bit about this big
> change.  What's the primary motivation for full relocation?  I found

The fundamental problems of the ARM implementation (and others, like
MIPS etc.) have been discussed here on the list many times before.

> a Wiki page (below), is this the one?
> 
> http://elinux.org/CELF_Project_Proposal/Rework_ARM_architecture_support_in_U-Boot

Yes, this is the one. Actually all these commits were supposed to
include this message:

        Portions of this work were supported by funding from the CE
        Linux Forum.

Unfortunately it seems Heiko has forgotten to add this to the commit
messages; I'll ping him again.


If you read the thread you can see that both Heikos tests and other
testers who tried that code see dramatic speed improvements due to
enabling the cache; in addition to that we win all the flexibility of
RAM usage we are used to from other architectures.

So the last big remaining thing that needs to be added is to add
device tree support and get rid of these stupid ATAGs and MACHIDs.
Fortunately work on this front in on the way as well.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
 The software required `Windows 95 or better', so I installed Linux.

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-12 12:55   ` Shinya Kuribayashi
@ 2010-08-12 20:19     ` Wolfgang Denk
  0 siblings, 0 replies; 60+ messages in thread
From: Wolfgang Denk @ 2010-08-12 20:19 UTC (permalink / raw)
  To: u-boot

Dear Shinya Kuribayashi,

In message <4C63EF34.7000906@pobox.com> you wrote:
> On 08/12/2010 09:50 PM, Shinya Kuribayashi wrote:
> > It would be gratefull if someone could expalain a bit about this big
> > change.  What's the primary motivation for full relocation?
> 
> Forgot to mention; the reason why I'd like to know is, because I'm
> an ARM newbie, and interested in such topics.

It may help to search the archives. In general, when you are looking
for examples how to do things, do NOT look at ARM, look at PowerPC
instead.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I have a theory that it's impossible to prove anything, but  I  can't
prove it.

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-11 20:01 ` Wolfgang Denk
  2010-08-12  5:34   ` Heiko Schocher
@ 2010-08-12 20:49   ` Magnus Lilja
  2010-08-13 10:01     ` Wolfgang Denk
  1 sibling, 1 reply; 60+ messages in thread
From: Magnus Lilja @ 2010-08-12 20:49 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> The plan is as follows:
> 
> I will pull this stuff into the "next" branch about one week after I
> released "rc1". I intend to keep this "CONFIG_SYS_ARM_WITHOUT_RELOC"
> feature for a full release cycle. Early in the next branch for the
> following release it will be removed. Any boards that are not yet
> converted then will break. If the breakage does not get fixed by
> board maintainers or interested users, we will remove these obviously
> unmaintained boards, then.

I thought the standard way was that when someone makes a change he's responsible for updating all code that's affected by the change. Anyway, I hope that either you or Heiko Schocher ping all the maintainers of affected boards. If I was one, I would certainly easily miss this (don't read all mail, only scan the subject lines).



Best regards, Magnus Lilja

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-12 20:49   ` Magnus Lilja
@ 2010-08-13 10:01     ` Wolfgang Denk
  0 siblings, 0 replies; 60+ messages in thread
From: Wolfgang Denk @ 2010-08-13 10:01 UTC (permalink / raw)
  To: u-boot

Dear Magnus Lilja,

In message <4C645E51.6020804@gmail.com> you wrote:
> Dear Wolfgang Denk,
> 
> > The plan is as follows:
> > 
> > I will pull this stuff into the "next" branch about one week after I
> > released "rc1". I intend to keep this "CONFIG_SYS_ARM_WITHOUT_RELOC"
> > feature for a full release cycle. Early in the next branch for the
> > following release it will be removed. Any boards that are not yet
> > converted then will break. If the breakage does not get fixed by
> > board maintainers or interested users, we will remove these obviously
> > unmaintained boards, then.
> 
> I thought the standard way was that when someone makes a change he's
> responsible for updating all code that's affected by the change.

Yes, that's the standard way.

But this is a non-standard situation: the change cannot be
implemented without knowledge about and not verified without access
to the hardware.  We depend on the help of the board maintainers
and/or users.

> Anyway, I hope that either you or Heiko Schocher ping all the
> maintainers of affected boards. If I was one, I would certainly

We can only try to Cc: those who are listed in the MAINTAINERS file.
There are some orphaned boards for which it is not clear if anybody
still cares about these, or who.

> easily miss this (don't read all mail, only scan the subject lines).

Well, you would probably notice when your board does not build any
more ? ;-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I came home the other night and tried to open the door  with  my  car
keys...and  the  building started up. So I took it out for a drive. A
cop pulled me over for speeding. He asked me where I  live...  "Right
here".                                                - Steven Wright

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

* [U-Boot] [PATCH 00/26] arm: add full relocation / cache support
  2010-08-12 20:17   ` Wolfgang Denk
@ 2010-08-13 14:36     ` Shinya Kuribayashi
  0 siblings, 0 replies; 60+ messages in thread
From: Shinya Kuribayashi @ 2010-08-13 14:36 UTC (permalink / raw)
  To: u-boot

On 8/13/10 5:17 AM, Wolfgang Denk wrote:
>> http://elinux.org/CELF_Project_Proposal/Rework_ARM_architecture_support_in_U-Boot
>
> Yes, this is the one.
[snip[
> If you read the thread you can see that both Heikos tests and other
> testers who tried that code see dramatic speed improvements due to
> enabling the cache; in addition to that we win all the flexibility of
> RAM usage we are used to from other architectures.

Thanks, I'll think about it

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

* [U-Boot] [PATCH 00/26 v2][NEXT] arm: add full relocation / cache support
  2010-08-11 18:15 [U-Boot] [PATCH 00/26] arm: add full relocation / cache support Heiko Schocher
                   ` (2 preceding siblings ...)
  2010-08-12 12:50 ` Shinya Kuribayashi
@ 2010-09-17 11:10 ` Heiko Schocher
  2010-09-17 11:10   ` [U-Boot] [PATCH 01/26 v2][NEXT] arm: get rid of bi_env Heiko Schocher
                     ` (2 more replies)
  3 siblings, 3 replies; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

This patch series add full relocation and cache support for arm
based boards. I test this for arm1136, arm_cortexa8 and arm926ejs
based boards.

Relocation support:

!! This change is not compatible to old code !!

If you want to compile in old style, you can set

CONFIG_SYS_ARM_WITHOUT_RELOC

but this possibility will be removed soon, so please
adapt your board(s)

changed arch/arm/lib/board.c to get inline with arch/powerpc/lib/board.c
maybe it is possible to snyc them to one arch/generic/lib/board.c?

This approach is similiar to powerpc, so there is a need for
an initial stack pointer addr defined through CONFIG_SYS_INIT_SP_ADDR.

Please also read doc/README.arm-relocation There is more
info what is done, and maybe should be done.

Cache support:

I used the patches from Alessandro Rubini:
http://lists.denx.de/pipermail/u-boot/2010-January/067099.html

and rebased them to actual code. Also, in case of full relocation,
the position of the TLB can not be set on compile time, instead
it is calculated in board_init_f() and stored in gd. Also added
cache support for arm_cortexa8 and arm1136.

changes since v1:

- missed to add statistics for enabling dcache to arm926ejs in
  commit message. Add also CACHE command to the tx25 and
  magnesium board. So I changed old patch
  "ARM: flush cache for arm926" to
  "ARM (ARM926ejs): add data cache support, tested on magnesium and tx25 board"
- set TEXT_BASE == relocation address for the tx25 board.
  -> in relocation_code() no need to copy code again for
  this board. This results in editing "ARM: implement relocation for ARM926"
  patch.

-> So actual next branch needs a rebase. Sorry for that!

Heiko Schocher (26):
  arm: get rid of bi_env
  ARM: cp15: setup mmu and enable dcache
  ARM (ARM926ejs): add data cache support, tested on magnesium and tx25
    board
  ARM V7 (OMAP): add data cache support, test on Beagle board
  ARM (ARM11): add data cache support, test on Qong board
  relocation: fixup cmdtable
  common: move TOTAL_MALLOC_LEN to include/common.h
  i2c: fix command usage help
  disk/part.c: fix relocation fixup
  i2c, omap24xx: set bus_initialized only after relocation.
  nand_boot_fsl_nfc.c: make "nfc" a "static const" pointer
  ARM: add relocation support
  ARM: implement relocation for ARM11
  ARM: implement relocation for ARM V7 (OMAP)
  ARM: implement relocation for ARM926
  ARM: implement relocation for ARM920
  ARM: implement relocation for ARM925
  ARM: implement relocation for ARM946
  ARM: implement relocation for pxa
  ARM: implement relocation for ixp
  ARM: implement relocation for sa1100
  ARM: implement relocation for s3c44b0
  ARM: implement relocation for lh7a40x
  ARM: implement relocation for arm_intcm
  ARM: implement relocation for arm720t
  ARM: implement relocation for arm1176

 arch/arm/config.mk                    |    8 +
 arch/arm/cpu/arm1136/start.S          |  206 +++++++++++++++
 arch/arm/cpu/arm1136/u-boot.lds       |   14 +-
 arch/arm/cpu/arm1176/start.S          |  286 ++++++++++++++++++++
 arch/arm/cpu/arm1176/u-boot.lds       |   14 +-
 arch/arm/cpu/arm720t/start.S          |  170 ++++++++++++
 arch/arm/cpu/arm720t/u-boot.lds       |   14 +-
 arch/arm/cpu/arm920t/start.S          |  225 ++++++++++++++++-
 arch/arm/cpu/arm920t/u-boot.lds       |   14 +-
 arch/arm/cpu/arm925t/start.S          |  204 ++++++++++++++-
 arch/arm/cpu/arm925t/u-boot.lds       |   14 +-
 arch/arm/cpu/arm926ejs/orion5x/dram.c |   24 ++-
 arch/arm/cpu/arm926ejs/start.S        |  172 ++++++++++++-
 arch/arm/cpu/arm926ejs/u-boot.lds     |   14 +-
 arch/arm/cpu/arm946es/start.S         |  168 ++++++++++++-
 arch/arm/cpu/arm946es/u-boot.lds      |   14 +-
 arch/arm/cpu/arm_intcm/start.S        |  166 ++++++++++++
 arch/arm/cpu/arm_intcm/u-boot.lds     |   14 +-
 arch/arm/cpu/armv7/mx51/u-boot.lds    |   14 +-
 arch/arm/cpu/armv7/omap3/cache.S      |   81 ++++++
 arch/arm/cpu/armv7/omap3/emif4.c      |   34 +++
 arch/arm/cpu/armv7/omap3/sdrc.c       |   38 +++
 arch/arm/cpu/armv7/start.S            |  191 +++++++++++++-
 arch/arm/cpu/armv7/u-boot.lds         |   14 +-
 arch/arm/cpu/ixp/start.S              |  280 ++++++++++++++++++++
 arch/arm/cpu/ixp/u-boot.lds           |   14 +-
 arch/arm/cpu/lh7a40x/start.S          |  187 +++++++++++++-
 arch/arm/cpu/lh7a40x/u-boot.lds       |   14 +-
 arch/arm/cpu/pxa/start.S              |  168 ++++++++++++
 arch/arm/cpu/pxa/u-boot.lds           |   14 +-
 arch/arm/cpu/s3c44b0/start.S          |  174 ++++++++++++
 arch/arm/cpu/s3c44b0/u-boot.lds       |   14 +-
 arch/arm/cpu/sa1100/start.S           |  162 ++++++++++++
 arch/arm/cpu/sa1100/u-boot.lds        |   14 +-
 arch/arm/include/asm/config.h         |    3 +-
 arch/arm/include/asm/global_data.h    |   11 +
 arch/arm/include/asm/u-boot-arm.h     |   14 +-
 arch/arm/include/asm/u-boot.h         |    4 -
 arch/arm/lib/board.c                  |  468 ++++++++++++++++++++++++++++++++-
 arch/arm/lib/cache-cp15.c             |   82 ++++++
 arch/arm/lib/cache.c                  |   13 +-
 arch/arm/lib/interrupts.c             |   19 ++-
 arch/avr32/include/asm/u-boot.h       |    1 -
 arch/avr32/lib/board.c                |   25 +--
 arch/i386/include/asm/u-boot.h        |    4 -
 arch/m68k/lib/board.c                 |   35 +---
 arch/mips/include/asm/u-boot.h        |    2 -
 arch/mips/lib/board.c                 |   36 +---
 arch/powerpc/lib/board.c              |   10 -
 arch/sparc/lib/board.c                |   28 +--
 board/davedenx/qong/config.mk         |    4 +-
 board/davedenx/qong/qong.c            |   87 ++++---
 board/karo/tx25/config.mk             |    4 +-
 board/karo/tx25/tx25.c                |   11 +-
 board/keymile/km_arm/km_arm.c         |   24 ++
 board/logicpd/imx27lite/config.mk     |    2 +-
 board/logicpd/imx27lite/imx27lite.c   |   15 +-
 board/ti/beagle/config.mk             |    2 +-
 common/cmd_bdinfo.c                   |   12 +-
 common/cmd_bmp.c                      |    6 +
 common/cmd_i2c.c                      |    9 +
 common/command.c                      |   37 +++
 disk/part.c                           |   11 +-
 doc/README.arm-relocation             |  344 ++++++++++++++++++++++++
 drivers/i2c/omap24xx_i2c.c            |    4 +-
 include/command.h                     |    3 +
 include/common.h                      |    9 +
 include/configs/da850evm.h            |    6 +-
 include/configs/imx27lite-common.h    |    6 +
 include/configs/km_arm.h              |    4 +
 include/configs/omap3_beagle.h        |    6 +
 include/configs/qong.h                |   11 +
 include/configs/tx25.h                |   14 +-
 nand_spl/board/karo/tx25/u-boot.lds   |   14 +-
 nand_spl/nand_boot.c                  |    7 +
 nand_spl/nand_boot_fsl_nfc.c          |   13 +-
 76 files changed, 4344 insertions(+), 230 deletions(-)
 create mode 100644 doc/README.arm-relocation

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

* [U-Boot] [PATCH 01/26 v2][NEXT] arm: get rid of bi_env
  2010-09-17 11:10 ` [U-Boot] [PATCH 00/26 v2][NEXT] " Heiko Schocher
@ 2010-09-17 11:10   ` Heiko Schocher
  2010-09-17 11:10     ` [U-Boot] [PATCH 02/26 v2][NEXT] ARM: cp15: setup mmu and enable dcache Heiko Schocher
  2010-09-18 23:19   ` [U-Boot] [PATCH 00/26 v2][NEXT] arm: add full relocation / cache support Wolfgang Denk
  2010-09-22 17:51   ` Ben Gardiner
  2 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

bi_env is nowhere used, so delete it!

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>

similar patch posted from Dirk Behme Tue Jul 27 18:36:09 CEST 2010
http://lists.denx.de/pipermail/u-boot/2010-July/074542.html

so this patch maybe obsolete
---
 arch/arm/include/asm/u-boot.h   |    4 ----
 arch/avr32/include/asm/u-boot.h |    1 -
 arch/i386/include/asm/u-boot.h  |    4 ----
 arch/mips/include/asm/u-boot.h  |    2 --
 common/cmd_bdinfo.c             |    1 -
 5 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/u-boot.h b/arch/arm/include/asm/u-boot.h
index cfd5a9b..ed33327 100644
--- a/arch/arm/include/asm/u-boot.h
+++ b/arch/arm/include/asm/u-boot.h
@@ -39,7 +39,6 @@
 typedef struct bd_info {
     int			bi_baudrate;	/* serial console baudrate */
     unsigned long	bi_ip_addr;	/* IP Address */
-    struct environment_s	       *bi_env;
     ulong	        bi_arch_number;	/* unique id for this board */
     ulong	        bi_boot_params;	/* where this board expects params */
     struct				/* RAM configuration */
@@ -49,7 +48,4 @@ typedef struct bd_info {
     }			bi_dram[CONFIG_NR_DRAM_BANKS];
 } bd_t;
 
-#define bi_env_data bi_env->data
-#define bi_env_crc  bi_env->crc
-
 #endif	/* _U_BOOT_H_ */
diff --git a/arch/avr32/include/asm/u-boot.h b/arch/avr32/include/asm/u-boot.h
index 7e4001f..8acd056 100644
--- a/arch/avr32/include/asm/u-boot.h
+++ b/arch/avr32/include/asm/u-boot.h
@@ -26,7 +26,6 @@ typedef struct bd_info {
 	unsigned long		bi_baudrate;
 	unsigned long		bi_ip_addr;
 	unsigned char		bi_phy_id[4];
-	struct environment_s	*bi_env;
 	unsigned long		bi_board_number;
 	void			*bi_boot_params;
 	struct {
diff --git a/arch/i386/include/asm/u-boot.h b/arch/i386/include/asm/u-boot.h
index 9a1eec0..a43b3aa 100644
--- a/arch/i386/include/asm/u-boot.h
+++ b/arch/i386/include/asm/u-boot.h
@@ -51,7 +51,6 @@ typedef struct bd_info {
 	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
 	unsigned int	bi_baudrate;	/* Console Baudrate */
 	unsigned long   bi_boot_params;	/* where this board expects params */
-	struct environment_s	       *bi_env;
 	struct				/* RAM configuration */
 	{
 		ulong start;
@@ -59,7 +58,4 @@ typedef struct bd_info {
 	}bi_dram[CONFIG_NR_DRAM_BANKS];
 } bd_t;
 
-#define bi_env_data bi_env->data
-#define bi_env_crc  bi_env->crc
-
 #endif	/* _U_BOOT_H_ */
diff --git a/arch/mips/include/asm/u-boot.h b/arch/mips/include/asm/u-boot.h
index d9c14ca..e839ca1 100644
--- a/arch/mips/include/asm/u-boot.h
+++ b/arch/mips/include/asm/u-boot.h
@@ -42,7 +42,5 @@ typedef struct bd_info {
 	unsigned long	bi_flashsize;	/* size  of FLASH memory */
 	unsigned long	bi_flashoffset;	/* reserved area for startup monitor */
 } bd_t;
-#define bi_env_data bi_env->data
-#define bi_env_crc  bi_env->crc
 
 #endif	/* _U_BOOT_H_ */
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index d43867f..2730fa9 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -330,7 +330,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	bd_t *bd = gd->bd;
 
 	print_num ("arch_number",	bd->bi_arch_number);
-	print_num ("env_t",		(ulong)bd->bi_env);
 	print_num ("boot_params",	(ulong)bd->bi_boot_params);
 
 	for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
-- 
1.6.2.5

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

* [U-Boot] [PATCH 02/26 v2][NEXT] ARM: cp15: setup mmu and enable dcache
  2010-09-17 11:10   ` [U-Boot] [PATCH 01/26 v2][NEXT] arm: get rid of bi_env Heiko Schocher
@ 2010-09-17 11:10     ` Heiko Schocher
  2010-09-17 11:10       ` [U-Boot] [PATCH 03/26 v2][NEXT] ARM (ARM926ejs): add data cache support, tested on magnesium and tx25 board Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

This has been tested on at91sam9263 and STN8815.
Again, I didn't check if it has bad effects
on non-arm926 cores.

Initially I had a "done" bit to only set up page tables
at the beginning. However, since the aligmnent requirement
was for the whole object file, this extra integer tool 16kB
in BSS, so I chose to remove it.

Also, note not all boards use PHYS_SDRAM, but it looks like
it's the most used name (more than CONFIG_SYS_DRAM_BASE for
example).

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/lib/cache-cp15.c |   51 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
index 62ed54f..b2811f3 100644
--- a/arch/arm/lib/cache-cp15.c
+++ b/arch/arm/lib/cache-cp15.c
@@ -25,6 +25,15 @@
 #include <asm/system.h>
 
 #if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE))
+
+#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
+#define CACHE_SETUP	0x1a
+#else
+#define CACHE_SETUP	0x1e
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
 static void cp_delay (void)
 {
 	volatile int i;
@@ -32,6 +41,40 @@ static void cp_delay (void)
 	/* copro seems to need some delay between reading and writing */
 	for (i = 0; i < 100; i++)
 		nop();
+	asm volatile("" : : : "memory");
+}
+
+/* to activate the MMU we need to set up virtual memory: use 1M areas in bss */
+static inline void mmu_setup(void)
+{
+	static u32 __attribute__((aligned(16384))) page_table[4096];
+	bd_t *bd = gd->bd;
+	int i, j;
+	u32 reg;
+
+	/* Set up an identity-mapping for all 4GB, rw for everyone */
+	for (i = 0; i < 4096; i++)
+		page_table[i] = i << 20 | (3 << 10) | 0x12;
+	/* Then, enable cacheable and bufferable for RAM only */
+	for (j = 0; j < CONFIG_NR_DRAM_BANKS; j++) {
+		for (i = bd->bi_dram[j].start >> 20;
+			i < (bd->bi_dram[j].start + bd->bi_dram[j].size) >> 20;
+			i++) {
+			page_table[i] = i << 20 | (3 << 10) | CACHE_SETUP;
+		}
+	}
+
+	/* Copy the page table address to cp15 */
+	asm volatile("mcr p15, 0, %0, c2, c0, 0"
+		     : : "r" (page_table) : "memory");
+	/* Set the access control to all-supervisor */
+	asm volatile("mcr p15, 0, %0, c3, c0, 0"
+		     : : "r" (~0));
+	/* and enable the mmu */
+	reg = get_cr();	/* get control reg. */
+	cp_delay();
+	set_cr(reg | CR_M);
+
 }
 
 /* cache_bit must be either CR_I or CR_C */
@@ -39,6 +82,9 @@ static void cache_enable(uint32_t cache_bit)
 {
 	uint32_t reg;
 
+	/* The data cache is not active unless the mmu is enabled too */
+	if (cache_bit == CR_C)
+		mmu_setup();
 	reg = get_cr();	/* get control reg. */
 	cp_delay();
 	set_cr(reg | cache_bit);
@@ -49,6 +95,11 @@ static void cache_disable(uint32_t cache_bit)
 {
 	uint32_t reg;
 
+	if (cache_bit == CR_C) {
+		/* if disabling data cache, disable mmu too */
+		cache_bit |= CR_M;
+		flush_cache(0, ~0);
+	}
 	reg = get_cr();
 	cp_delay();
 	set_cr(reg & ~cache_bit);
-- 
1.6.2.5

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

* [U-Boot] [PATCH 03/26 v2][NEXT] ARM (ARM926ejs): add data cache support, tested on magnesium and tx25 board
  2010-09-17 11:10     ` [U-Boot] [PATCH 02/26 v2][NEXT] ARM: cp15: setup mmu and enable dcache Heiko Schocher
@ 2010-09-17 11:10       ` Heiko Schocher
  2010-09-17 11:10         ` [U-Boot] [PATCH 04/26 v2][NEXT] ARM V7 (OMAP): add data cache support, test on Beagle board Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Enable "cache" command on tx25 and magnesium board and test performance.

    Test 1: Loading 127 MB of data from NAND flash into RAM:

    Instr. Cache        off     on      on
      Data Cache        off     off     on
    --------------------------------------------------
    magnesium           32,6s   22,5s   30s     = x 1,09
    tx25 (29MB only)    9,69s   5,05s   8,16s   = x 1,19

    Test 2: uncompressing a gzipped image from RAM to RAM
            (size compressed: 6.5 MiB, uncompressed: 35 MiB):

    Instr. Cache        off     on      on
      Data Cache        off     off     on
    --------------------------------------------------
    magnesium           4,25s   2,08s   1,72s   = x 2,47
    tx25                4,82s   2,04s   1,84s   = x 2,62

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Alessandro Rubini <rubini@gnudd.com>
---
 arch/arm/lib/cache.c               |    6 ++++++
 include/configs/imx27lite-common.h |    1 +
 include/configs/tx25.h             |    1 +
 3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index 61ee9d3..b36fd24 100644
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
@@ -32,5 +32,11 @@ void  flush_cache (unsigned long dummy1, unsigned long dummy2)
 
 	arm1136_cache_flush();
 #endif
+#ifdef CONFIG_ARM926EJS
+	/* test and clean, page 2-23 of arm926ejs manual */
+	asm("0: mrc p15, 0, r15, c7, c10, 3\n\t" "bne 0b\n" : : : "memory");
+	/* disable write buffer as well (page 2-22) */
+	asm("mcr p15, 0, %0, c7, c10, 4" : : "r" (0));
+#endif
 	return;
 }
diff --git a/include/configs/imx27lite-common.h b/include/configs/imx27lite-common.h
index 1da8602..33550ba 100644
--- a/include/configs/imx27lite-common.h
+++ b/include/configs/imx27lite-common.h
@@ -188,6 +188,7 @@
  */
 #include <config_cmd_default.h>
 #define CONFIG_CMD_ASKENV
+#define CONFIG_CMD_CACHE
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_DIAG
 #define CONFIG_CMD_FAT
diff --git a/include/configs/tx25.h b/include/configs/tx25.h
index c8188ca..013aa35 100644
--- a/include/configs/tx25.h
+++ b/include/configs/tx25.h
@@ -131,6 +131,7 @@
 /* U-Boot commands */
 #include <config_cmd_default.h>
 #define CONFIG_CMD_NAND
+#define CONFIG_CMD_CACHE
 
 /*
  * Ethernet
-- 
1.6.2.5

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

* [U-Boot] [PATCH 04/26 v2][NEXT] ARM V7 (OMAP): add data cache support, test on Beagle board
  2010-09-17 11:10       ` [U-Boot] [PATCH 03/26 v2][NEXT] ARM (ARM926ejs): add data cache support, tested on magnesium and tx25 board Heiko Schocher
@ 2010-09-17 11:10         ` Heiko Schocher
  2010-09-17 11:10           ` [U-Boot] [PATCH 05/26 v2][NEXT] ARM (ARM11): add data cache support, test on Qong board Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Add data cache support for ARM V7 systems. Used cache flush
functions from linux:arch/arm/mm/cache-v7.S developed from
Catalin Marinas.

Enable "cache" command on Beagle board and test performance.

    Test 1: Loading 127 MB of data from NAND flash into RAM:

    Instr. Cache	off	on	on
      Data Cache	off	off	on
    --------------------------------------------------
    Beagle (Cortex A8)	116s	106s	30.3s	= x 3.8

    Test 2: uncompressing a gzipped image from RAM to RAM
            (size compressed: 6.5 MiB, uncompressed: 35 MiB):

    Instr. Cache	off	on	on
      Data Cache	off	off	on
    --------------------------------------------------
    Beagle (Cortex A8)	1.84s	1.64s	0.12s	= x 15.3

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Ben Gardiner<bengardiner@nanometrics.ca>
---
 arch/arm/cpu/armv7/omap3/cache.S |   81 ++++++++++++++++++++++++++++++++++++++
 arch/arm/lib/cache.c             |    5 ++
 include/configs/omap3_beagle.h   |    1 +
 3 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap3/cache.S b/arch/arm/cpu/armv7/omap3/cache.S
index fdc1666..7f349dd 100644
--- a/arch/arm/cpu/armv7/omap3/cache.S
+++ b/arch/arm/cpu/armv7/omap3/cache.S
@@ -181,3 +181,84 @@ setup_auxcr:
 	orrlt	r0, r0, #1 << 27
 	.word 0xE1600070			@ SMC
 	bx	lr
+
+.align 5
+.global v7_flush_dcache_all
+.global v7_flush_cache_all
+
+/*
+ *	v7_flush_dcache_all()
+ *
+ *	Flush the whole D-cache.
+ *
+ *	Corrupted registers: r0-r7, r9-r11 (r6 only in Thumb mode)
+ *
+ *	- mm    - mm_struct describing address space
+ */
+v7_flush_dcache_all:
+#	dmb					@ ensure ordering with previous memory accesses
+	mrc	p15, 1, r0, c0, c0, 1		@ read clidr
+	ands	r3, r0, #0x7000000		@ extract loc from clidr
+	mov	r3, r3, lsr #23			@ left align loc bit field
+	beq	finished			@ if loc is 0, then no need to clean
+	mov	r10, #0				@ start clean at cache level 0
+loop1:
+	add	r2, r10, r10, lsr #1		@ work out 3x current cache level
+	mov	r1, r0, lsr r2			@ extract cache type bits from clidr
+	and	r1, r1, #7			@ mask of the bits for current cache only
+	cmp	r1, #2				@ see what cache we have@this level
+	blt	skip				@ skip if no cache, or just i-cache
+	mcr	p15, 2, r10, c0, c0, 0		@ select current cache level in cssr
+	mcr	p15, 0, r10, c7, c5, 4		@ flush prefetch buffer,
+						@ with armv7 this is 'isb',
+						@ but we compile with armv5
+	mrc	p15, 1, r1, c0, c0, 0		@ read the new csidr
+	and	r2, r1, #7			@ extract the length of the cache lines
+	add	r2, r2, #4			@ add 4 (line length offset)
+	ldr	r4, =0x3ff
+	ands	r4, r4, r1, lsr #3		@ find maximum number on the way size
+	clz	r5, r4				@ find bit position of way size increment
+	ldr	r7, =0x7fff
+	ands	r7, r7, r1, lsr #13		@ extract max number of the index size
+loop2:
+	mov	r9, r4				@ create working copy of max way size
+loop3:
+	orr	r11, r10, r9, lsl r5		@ factor way and cache number into r11
+	orr	r11, r11, r7, lsl r2		@ factor index number into r11
+	mcr	p15, 0, r11, c7, c14, 2		@ clean & invalidate by set/way
+	subs	r9, r9, #1			@ decrement the way
+	bge	loop3
+	subs	r7, r7, #1			@ decrement the index
+	bge	loop2
+skip:
+	add	r10, r10, #2			@ increment cache number
+	cmp	r3, r10
+	bgt	loop1
+finished:
+	mov	r10, #0				@ swith back to cache level 0
+	mcr	p15, 2, r10, c0, c0, 0		@ select current cache level in cssr
+#	dsb
+	mcr	p15, 0, r10, c7, c5, 4		@ flush prefetch buffer,
+						@ with armv7 this is 'isb',
+						@ but we compile with armv5
+	mov	pc, lr
+
+/*
+ *	v7_flush_cache_all()
+ *
+ *	Flush the entire cache system.
+ *  The data cache flush is now achieved using atomic clean / invalidates
+ *  working outwards from L1 cache. This is done using Set/Way based cache
+ *  maintainance instructions.
+ *  The instruction cache can still be invalidated back to the point of
+ *  unification in a single instruction.
+ *
+ */
+v7_flush_cache_all:
+	stmfd	sp!, {r0-r7, r9-r11, lr}
+	bl	v7_flush_dcache_all
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c5, 0		@ I+BTB cache invalidate
+	ldmfd	sp!, {r0-r7, r9-r11, lr}
+	mov	pc, lr
+
diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index b36fd24..3684cad 100644
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
@@ -38,5 +38,10 @@ void  flush_cache (unsigned long dummy1, unsigned long dummy2)
 	/* disable write buffer as well (page 2-22) */
 	asm("mcr p15, 0, %0, c7, c10, 4" : : "r" (0));
 #endif
+#ifdef CONFIG_ARMCORTEXA8
+	void v7_flush_cache_all(void);
+
+	v7_flush_cache_all();
+#endif
 	return;
 }
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index 71553f9..3f6e803 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -120,6 +120,7 @@
 /* commands to include */
 #include <config_cmd_default.h>
 
+#define CONFIG_CMD_CACHE
 #define CONFIG_CMD_EXT2		/* EXT2 Support			*/
 #define CONFIG_CMD_FAT		/* FAT support			*/
 #define CONFIG_CMD_JFFS2	/* JFFS2 Support		*/
-- 
1.6.2.5

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

* [U-Boot] [PATCH 05/26 v2][NEXT] ARM (ARM11): add data cache support, test on Qong board
  2010-09-17 11:10         ` [U-Boot] [PATCH 04/26 v2][NEXT] ARM V7 (OMAP): add data cache support, test on Beagle board Heiko Schocher
@ 2010-09-17 11:10           ` Heiko Schocher
  2010-09-17 11:10             ` [U-Boot] [PATCH 06/26 v2][NEXT] relocation: fixup cmdtable Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Add data cache support for arm1136 systems.

Enable "cache" command on Qong board and test performance.

    Test 1: Loading 127 MB of data from NAND flash into RAM:

    Instr. Cache	off	on	on
      Data Cache	off	off	on
    --------------------------------------------------
    QONG (ARM11)	177s	95s	43s	= x 4.1

    Test 2: uncompressing a gzipped image from RAM to RAM
            (size compressed: 6.5 MiB, uncompressed: 35 MiB):

    Instr. Cache	off	on	on
      Data Cache	off	off	on
    --------------------------------------------------
    QONG (ARM11)	1.54s	0.95s	0.18s	= x 8.6

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/arm1136/start.S |    5 +++++
 arch/arm/lib/cache.c         |    2 +-
 include/configs/qong.h       |    1 +
 3 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S
index 41eb82d..1c58abd 100644
--- a/arch/arm/cpu/arm1136/start.S
+++ b/arch/arm/cpu/arm1136/start.S
@@ -439,6 +439,11 @@ fiq:
 	.align 5
 .global arm1136_cache_flush
 arm1136_cache_flush:
+#if !defined(CONFIG_SYS_NO_ICACHE)
 		mcr	p15, 0, r1, c7, c5, 0	@ invalidate I cache
+#endif
+#if !defined(CONFIG_SYS_NO_DCACHE)
+		mcr	p15, 0, r1, c7, c14, 0	@ invalidate D cache
+#endif
 		mov	pc, lr			@ back to caller
 #endif	/* CONFIG_PRELOADER */
diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index 3684cad..55b633e 100644
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
@@ -27,7 +27,7 @@
 
 void  flush_cache (unsigned long dummy1, unsigned long dummy2)
 {
-#ifdef CONFIG_OMAP2420
+#if defined(CONFIG_OMAP2420) || defined(CONFIG_ARM1136)
 	void arm1136_cache_flush(void);
 
 	arm1136_cache_flush();
diff --git a/include/configs/qong.h b/include/configs/qong.h
index 100fa3f..4735b5e 100644
--- a/include/configs/qong.h
+++ b/include/configs/qong.h
@@ -104,6 +104,7 @@
 
 #include <config_cmd_default.h>
 
+#define CONFIG_CMD_CACHE
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_NET
-- 
1.6.2.5

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

* [U-Boot] [PATCH 06/26 v2][NEXT] relocation: fixup cmdtable
  2010-09-17 11:10           ` [U-Boot] [PATCH 05/26 v2][NEXT] ARM (ARM11): add data cache support, test on Qong board Heiko Schocher
@ 2010-09-17 11:10             ` Heiko Schocher
  2010-09-17 11:10               ` [U-Boot] [PATCH 07/26 v2][NEXT] common: move TOTAL_MALLOC_LEN to include/common.h Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

fixup_cmdtable() did all work for fixing up the cmdtable,
if CONFIG_RELOC_FIXUP_WORKS is not defined.

CONFIG_RELOC_FIXUP_WORKS is missing for i386! I talked
with Graeme Russ, and he will fix this soon.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/avr32/lib/board.c |   25 ++++---------------------
 arch/m68k/lib/board.c  |   27 ++++-----------------------
 arch/mips/lib/board.c  |   28 ++++------------------------
 arch/sparc/lib/board.c |   28 ++++------------------------
 common/command.c       |   37 +++++++++++++++++++++++++++++++++++++
 include/command.h      |    3 +++
 6 files changed, 56 insertions(+), 92 deletions(-)

diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
index aa589bb..e6b81cc 100644
--- a/arch/avr32/lib/board.c
+++ b/arch/avr32/lib/board.c
@@ -273,30 +273,13 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 
 	monitor_flash_len = _edata - _text;
 
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
 	/*
 	 * We have to relocate the command table manually
 	 */
-	for (cmdtp = &__u_boot_cmd_start;
-	     cmdtp !=  &__u_boot_cmd_end; cmdtp++) {
-		unsigned long addr;
-
-		addr = (unsigned long)cmdtp->cmd + gd->reloc_off;
-		cmdtp->cmd = (typeof(cmdtp->cmd))addr;
-
-		addr = (unsigned long)cmdtp->name + gd->reloc_off;
-		cmdtp->name = (typeof(cmdtp->name))addr;
-
-		if (cmdtp->usage) {
-			addr = (unsigned long)cmdtp->usage + gd->reloc_off;
-			cmdtp->usage = (typeof(cmdtp->usage))addr;
-		}
-#ifdef CONFIG_SYS_LONGHELP
-		if (cmdtp->help) {
-			addr = (unsigned long)cmdtp->help + gd->reloc_off;
-			cmdtp->help = (typeof(cmdtp->help))addr;
-		}
-#endif
-	}
+	fixup_cmdtable(&__u_boot_cmd_start,
+		(ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
 
 	/* there are some other pointer constants we must deal with */
 #ifndef CONFIG_ENV_IS_NOWHERE
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index b254079..acbdc58 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -433,33 +433,14 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 	monitor_flash_len = (ulong)&__init_end - dest_addr;
 
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
 	/*
 	 * We have to relocate the command table manually
 	 */
-	for (cmdtp = &__u_boot_cmd_start; cmdtp !=  &__u_boot_cmd_end; cmdtp++) {
-		ulong addr;
-		addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
-#if 0
-		printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
-				cmdtp->name, (ulong) (cmdtp->cmd), addr);
-#endif
-		cmdtp->cmd =
-			(int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
+	fixup_cmdtable(&__u_boot_cmd_start,
+		(ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
 
-		addr = (ulong)(cmdtp->name) + gd->reloc_off;
-		cmdtp->name = (char *)addr;
-
-		if (cmdtp->usage) {
-			addr = (ulong)(cmdtp->usage) + gd->reloc_off;
-			cmdtp->usage = (char *)addr;
-		}
-#ifdef	CONFIG_SYS_LONGHELP
-		if (cmdtp->help) {
-			addr = (ulong)(cmdtp->help) + gd->reloc_off;
-			cmdtp->help = (char *)addr;
-		}
-#endif
-	}
 	/* there are some other pointer constants we must deal with */
 #ifndef CONFIG_ENV_IS_NOWHERE
 	env_name_spec += gd->reloc_off;
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index ab4a17c..2f259cb 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -304,34 +304,14 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 	monitor_flash_len = (ulong)&uboot_end_data - dest_addr;
 
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
 	/*
 	 * We have to relocate the command table manually
 	 */
-	for (cmdtp = &__u_boot_cmd_start; cmdtp !=  &__u_boot_cmd_end; cmdtp++) {
-		ulong addr;
+	fixup_cmdtable(&__u_boot_cmd_start,
+		(ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
 
-		addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
-#if 0
-		printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
-				cmdtp->name, (ulong) (cmdtp->cmd), addr);
-#endif
-		cmdtp->cmd =
-			(int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
-
-		addr = (ulong)(cmdtp->name) + gd->reloc_off;
-		cmdtp->name = (char *)addr;
-
-		if (cmdtp->usage) {
-			addr = (ulong)(cmdtp->usage) + gd->reloc_off;
-			cmdtp->usage = (char *)addr;
-		}
-#ifdef	CONFIG_SYS_LONGHELP
-		if (cmdtp->help) {
-			addr = (ulong)(cmdtp->help) + gd->reloc_off;
-			cmdtp->help = (char *)addr;
-		}
-#endif
-	}
 	/* there are some other pointer constants we must deal with */
 #ifndef CONFIG_ENV_IS_NOWHERE
 	env_name_spec += gd->reloc_off;
diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
index 4f69709..d0890f6 100644
--- a/arch/sparc/lib/board.c
+++ b/arch/sparc/lib/board.c
@@ -252,33 +252,13 @@ void board_init_f(ulong bootflag)
 	post_run(NULL, POST_ROM | post_bootmode_get(0));
 #endif
 
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
 	/*
 	 * We have to relocate the command table manually
 	 */
-	for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
-		ulong addr;
-		addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
-#if DEBUG_COMMANDS
-		printf("Command \"%s\": 0x%08lx => 0x%08lx\n",
-		       cmdtp->name, (ulong) (cmdtp->cmd), addr);
-#endif
-		cmdtp->cmd =
-		    (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
-
-		addr = (ulong) (cmdtp->name) + gd->reloc_off;
-		cmdtp->name = (char *)addr;
-
-		if (cmdtp->usage) {
-			addr = (ulong) (cmdtp->usage) + gd->reloc_off;
-			cmdtp->usage = (char *)addr;
-		}
-#ifdef	CONFIG_SYS_LONGHELP
-		if (cmdtp->help) {
-			addr = (ulong) (cmdtp->help) + gd->reloc_off;
-			cmdtp->help = (char *)addr;
-		}
-#endif
-	}
+	fixup_cmdtable(&__u_boot_cmd_start,
+		(ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
 
 #if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
 	puts("AMBA:\n");
diff --git a/common/command.c b/common/command.c
index 72266c3..d47d719 100644
--- a/common/command.c
+++ b/common/command.c
@@ -465,3 +465,40 @@ int cmd_get_data_size(char* arg, int default_size)
 	return default_size;
 }
 #endif
+
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+DECLARE_GLOBAL_DATA_PTR;
+
+void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)
+{
+	int	i;
+
+	if (gd->reloc_off == 0)
+		return;
+
+	for (i = 0; i < size; i++) {
+		ulong addr;
+
+		addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
+#if DEBUG_COMMANDS
+		printf("Command \"%s\": 0x%08lx => 0x%08lx\n",
+		       cmdtp->name, (ulong) (cmdtp->cmd), addr);
+#endif
+		cmdtp->cmd =
+			(int (*)(struct cmd_tbl_s *, int, int, char * const []))addr;
+		addr = (ulong)(cmdtp->name) + gd->reloc_off;
+		cmdtp->name = (char *)addr;
+		if (cmdtp->usage) {
+			addr = (ulong)(cmdtp->usage) + gd->reloc_off;
+			cmdtp->usage = (char *)addr;
+		}
+#ifdef	CONFIG_SYS_LONGHELP
+		if (cmdtp->help) {
+			addr = (ulong)(cmdtp->help) + gd->reloc_off;
+			cmdtp->help = (char *)addr;
+		}
+#endif
+		cmdtp++;
+	}
+}
+#endif
diff --git a/include/command.h b/include/command.h
index 9144d69..5c14616 100644
--- a/include/command.h
+++ b/include/command.h
@@ -125,4 +125,7 @@ cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
 
 #endif	/* CONFIG_SYS_LONGHELP */
 
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);
+#endif
 #endif	/* __COMMAND_H */
-- 
1.6.2.5

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

* [U-Boot] [PATCH 07/26 v2][NEXT] common: move TOTAL_MALLOC_LEN to include/common.h
  2010-09-17 11:10             ` [U-Boot] [PATCH 06/26 v2][NEXT] relocation: fixup cmdtable Heiko Schocher
@ 2010-09-17 11:10               ` Heiko Schocher
  2010-09-17 11:10                 ` [U-Boot] [PATCH 08/26 v2][NEXT] i2c: fix command usage help Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/m68k/lib/board.c    |    8 --------
 arch/mips/lib/board.c    |    8 --------
 arch/powerpc/lib/board.c |   10 ----------
 include/common.h         |    9 +++++++++
 4 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index acbdc58..ae9478a 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -79,14 +79,6 @@ extern flash_info_t flash_info[];
 
 #include <environment.h>
 
-#if ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
-      (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
-    defined(CONFIG_ENV_IS_IN_NVRAM)
-#define	TOTAL_MALLOC_LEN	(CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
-#else
-#define	TOTAL_MALLOC_LEN	CONFIG_SYS_MALLOC_LEN
-#endif
-
 extern ulong __init_end;
 extern ulong _end;
 
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index 2f259cb..0044b19 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -39,14 +39,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
-      (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
-    defined(CONFIG_ENV_IS_IN_NVRAM)
-#define	TOTAL_MALLOC_LEN	(CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
-#else
-#define	TOTAL_MALLOC_LEN	CONFIG_SYS_MALLOC_LEN
-#endif
-
 #undef DEBUG
 
 extern int timer_init(void);
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index 6b1ff08..950680c 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -118,16 +118,6 @@ extern int board_start_ide(void);
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_ENV_IS_EMBEDDED)
-#define TOTAL_MALLOC_LEN	CONFIG_SYS_MALLOC_LEN
-#elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
-	(CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
-      defined(CONFIG_ENV_IS_IN_NVRAM)
-#define	TOTAL_MALLOC_LEN	(CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
-#else
-#define	TOTAL_MALLOC_LEN	CONFIG_SYS_MALLOC_LEN
-#endif
-
 #if !defined(CONFIG_SYS_MEM_TOP_HIDE)
 #define CONFIG_SYS_MEM_TOP_HIDE	0
 #endif
diff --git a/include/common.h b/include/common.h
index 7e647e6..cc96672 100644
--- a/include/common.h
+++ b/include/common.h
@@ -189,6 +189,15 @@ typedef void (interrupt_handler_t)(void *);
 #define MIN(x, y)  min(x, y)
 #define MAX(x, y)  max(x, y)
 
+#if defined(CONFIG_ENV_IS_EMBEDDED)
+#define TOTAL_MALLOC_LEN	CONFIG_SYS_MALLOC_LEN
+#elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
+	(CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
+      defined(CONFIG_ENV_IS_IN_NVRAM)
+#define	TOTAL_MALLOC_LEN	(CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
+#else
+#define	TOTAL_MALLOC_LEN	CONFIG_SYS_MALLOC_LEN
+#endif
 
 /**
  * container_of - cast a member of a structure out to the containing structure
-- 
1.6.2.5

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

* [U-Boot] [PATCH 08/26 v2][NEXT] i2c: fix command usage help
  2010-09-17 11:10               ` [U-Boot] [PATCH 07/26 v2][NEXT] common: move TOTAL_MALLOC_LEN to include/common.h Heiko Schocher
@ 2010-09-17 11:10                 ` Heiko Schocher
  2010-09-17 11:10                   ` [U-Boot] [PATCH 09/26 v2][NEXT] disk/part.c: fix relocation fixup Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 common/cmd_i2c.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 1283c82..a7b65ed 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -1288,6 +1288,9 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	cmd_tbl_t *c;
 
+	if (argc < 2)
+		return cmd_usage(cmdtp);
+
 	/* Strip off leading 'i2c' command argument */
 	argc--;
 	argv++;
-- 
1.6.2.5

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

* [U-Boot] [PATCH 09/26 v2][NEXT] disk/part.c: fix relocation fixup
  2010-09-17 11:10                 ` [U-Boot] [PATCH 08/26 v2][NEXT] i2c: fix command usage help Heiko Schocher
@ 2010-09-17 11:10                   ` Heiko Schocher
  2010-09-17 11:10                     ` [U-Boot] [PATCH 10/26 v2][NEXT] i2c, omap24xx: set bus_initialized only after relocation Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 disk/part.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 3ba88c7..8bcf2f8 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -78,13 +78,20 @@ block_dev_desc_t *get_dev(char* ifname, int dev)
 {
 	const struct block_drvr *drvr = block_drvr;
 	block_dev_desc_t* (*reloc_get_dev)(int dev);
+	char *name;
 
-	while (drvr->name) {
+	name = drvr->name;
+#ifndef CONFIG_RELOC_FIXUP_WORKS
+	name += gd->reloc_off;
+#endif
+	while (name) {
+		name = drvr->name;
 		reloc_get_dev = drvr->get_dev;
 #ifndef CONFIG_RELOC_FIXUP_WORKS
+		name += gd->reloc_off;
 		reloc_get_dev += gd->reloc_off;
 #endif
-		if (strncmp(ifname, drvr->name, strlen(drvr->name)) == 0)
+		if (strncmp(ifname, name, strlen(name)) == 0)
 			return reloc_get_dev(dev);
 		drvr++;
 	}
-- 
1.6.2.5

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

* [U-Boot] [PATCH 10/26 v2][NEXT] i2c, omap24xx: set bus_initialized only after relocation.
  2010-09-17 11:10                   ` [U-Boot] [PATCH 09/26 v2][NEXT] disk/part.c: fix relocation fixup Heiko Schocher
@ 2010-09-17 11:10                     ` Heiko Schocher
  2010-09-17 11:10                       ` [U-Boot] [PATCH 11/26 v2][NEXT] nand_boot_fsl_nfc.c: make "nfc" a "static const" pointer Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 drivers/i2c/omap24xx_i2c.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
index a7c4e69..3febd1f 100644
--- a/drivers/i2c/omap24xx_i2c.c
+++ b/drivers/i2c/omap24xx_i2c.c
@@ -40,6 +40,7 @@ static unsigned int current_bus;
 
 void i2c_init (int speed, int slaveadd)
 {
+	DECLARE_GLOBAL_DATA_PTR;
 	int psc, fsscll, fssclh;
 	int hsscll = 0, hssclh = 0;
 	u32 scll, sclh;
@@ -139,7 +140,8 @@ void i2c_init (int speed, int slaveadd)
 	writew (0xFFFF, &i2c_base->stat);
 	writew (0, &i2c_base->cnt);
 
-	bus_initialized[current_bus] = 1;
+	if (gd->flags & GD_FLG_RELOC)
+		bus_initialized[current_bus] = 1;
 }
 
 static int i2c_read_byte (u8 devaddr, u8 regoffset, u8 * value)
-- 
1.6.2.5

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

* [U-Boot] [PATCH 11/26 v2][NEXT] nand_boot_fsl_nfc.c: make "nfc" a "static const" pointer
  2010-09-17 11:10                     ` [U-Boot] [PATCH 10/26 v2][NEXT] i2c, omap24xx: set bus_initialized only after relocation Heiko Schocher
@ 2010-09-17 11:10                       ` Heiko Schocher
  2010-09-17 11:10                         ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

With -fPIC enabled, this variable needs an entry in the GOT, which
causes the image size to exceed 2 KiB which is the maximum allowed for
some systems. Making it a "static const" avoids the GOT entry and thus
reduces the image size to < 2 KiB.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
---
 nand_spl/nand_boot_fsl_nfc.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/nand_spl/nand_boot_fsl_nfc.c b/nand_spl/nand_boot_fsl_nfc.c
index bfae30e..ea3566b 100644
--- a/nand_spl/nand_boot_fsl_nfc.c
+++ b/nand_spl/nand_boot_fsl_nfc.c
@@ -34,7 +34,7 @@
 #include <asm/io.h>
 #include <fsl_nfc.h>
 
-struct fsl_nfc_regs *nfc;
+static struct fsl_nfc_regs *const nfc = (void *)NFC_BASE_ADDR;
 
 static void nfc_wait_ready(void)
 {
@@ -228,8 +228,6 @@ static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)
 	unsigned int maxpages = CONFIG_SYS_NAND_SIZE /
 				CONFIG_SYS_NAND_PAGE_SIZE;
 
-	nfc = (void *)NFC_BASE_ADDR;
-
 	nfc_nand_init();
 
 	/* Convert to page number */
@@ -274,8 +272,6 @@ void nand_boot(void)
 {
 	__attribute__((noreturn)) void (*uboot)(void);
 
-	nfc = (void *)NFC_BASE_ADDR;
-
 	/*
 	 * CONFIG_SYS_NAND_U_BOOT_OFFS and CONFIG_SYS_NAND_U_BOOT_SIZE must
 	 * be aligned to full pages
-- 
1.6.2.5

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-17 11:10                       ` [U-Boot] [PATCH 11/26 v2][NEXT] nand_boot_fsl_nfc.c: make "nfc" a "static const" pointer Heiko Schocher
@ 2010-09-17 11:10                         ` Heiko Schocher
  2010-09-17 11:10                           ` [U-Boot] [PATCH 13/26 v2][NEXT] ARM: implement relocation for ARM11 Heiko Schocher
                                             ` (4 more replies)
  0 siblings, 5 replies; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

!! This breaks support for all arm boards !!

To compile in old style, you must define
CONFIG_SYS_ARM_WITHOUT_RELOC or you can compile
with "CONFIG_SYS_ARM_WITHOUT_RELOC=1 ./MAKEALL board"

!! This define will be removed soon, so convert your
board to use relocation support

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/config.mk                 |    8 +
 arch/arm/include/asm/config.h      |    3 +-
 arch/arm/include/asm/global_data.h |   11 +
 arch/arm/include/asm/u-boot-arm.h  |   14 +-
 arch/arm/lib/board.c               |  468 +++++++++++++++++++++++++++++++++++-
 arch/arm/lib/cache-cp15.c          |   37 +++-
 arch/arm/lib/interrupts.c          |   19 ++-
 common/cmd_bdinfo.c                |   11 +-
 common/cmd_bmp.c                   |    6 +
 common/cmd_i2c.c                   |    6 +
 doc/README.arm-relocation          |  321 ++++++++++++++++++++++++
 nand_spl/nand_boot.c               |    7 +
 nand_spl/nand_boot_fsl_nfc.c       |    7 +
 13 files changed, 910 insertions(+), 8 deletions(-)
 create mode 100644 doc/README.arm-relocation

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index e10dafc..6923f6d 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -33,6 +33,14 @@ STANDALONE_LOAD_ADDR = 0xc100000
 endif
 endif
 
+ifndef CONFIG_SYS_ARM_WITHOUT_RELOC
+# needed for relocation
+PLATFORM_RELFLAGS += -fPIC
+endif
+
+ifdef CONFIG_SYS_ARM_WITHOUT_RELOC
+PLATFORM_CPPFLAGS += -DCONFIG_SYS_ARM_WITHOUT_RELOC
+endif
 PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
 
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
diff --git a/arch/arm/include/asm/config.h b/arch/arm/include/asm/config.h
index b76fd8e..4e8dfd7 100644
--- a/arch/arm/include/asm/config.h
+++ b/arch/arm/include/asm/config.h
@@ -21,7 +21,8 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 /* Relocation to SDRAM works on all ARM boards */
 #define CONFIG_RELOC_FIXUP_WORKS
-
+#endif
 #endif
diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index 0bc464a..6152f34 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -47,6 +47,17 @@ typedef	struct	global_data {
 #ifdef CONFIG_FSL_ESDHC
 	unsigned long	sdhc_clk;
 #endif
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+	unsigned long	relocaddr;	/* Start address of U-Boot in RAM */
+	phys_size_t	ram_size;	/* RAM size */
+	unsigned long	mon_len;	/* monitor len */
+	unsigned long	irq_sp;		/* irq stack pointer */
+	unsigned long	start_addr_sp;	/* start_addr_stackpointer */
+	unsigned long	reloc_off;
+#if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE))
+	unsigned long	tlb_addr;
+#endif
+#endif
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
 } gd_t;
diff --git a/arch/arm/include/asm/u-boot-arm.h b/arch/arm/include/asm/u-boot-arm.h
index 6d2f8bc..faf800a 100644
--- a/arch/arm/include/asm/u-boot-arm.h
+++ b/arch/arm/include/asm/u-boot-arm.h
@@ -30,11 +30,20 @@
 #define _U_BOOT_ARM_H_	1
 
 /* for the following variables, see start.S */
-extern ulong _armboot_start;	/* code start */
 extern ulong _bss_start;	/* code + data end == BSS start */
 extern ulong _bss_end;		/* BSS end */
 extern ulong IRQ_STACK_START;	/* top of IRQ stack */
 extern ulong FIQ_STACK_START;	/* top of FIQ stack */
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+extern ulong _armboot_start;	/* code start */
+#else
+extern ulong _TEXT_BASE;	/* code start */
+extern ulong _datarel_start;
+extern ulong _datarelrolocal_start;
+extern ulong _datarellocal_start;
+extern ulong _datarelro_start;
+extern ulong IRQ_STACK_START_IN;	/* 8 bytes in IRQ stack */
+#endif
 
 /* cpu/.../cpu.c */
 int	cpu_init(void);
@@ -47,6 +56,9 @@ int	arch_misc_init(void);
 /* board/.../... */
 int	board_init(void);
 int	dram_init (void);
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+void	dram_init_banksize (void);
+#endif
 void	setup_serial_tag (struct tag **params);
 void	setup_revision_tag (struct tag **params);
 
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 54519b0..88c6427 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -126,7 +126,12 @@ static int init_baudrate (void)
 {
 	char tmp[64];	/* long enough for environment variables */
 	int i = getenv_f("baudrate", tmp, sizeof (tmp));
+
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+	gd->baudrate = (i > 0)
+#else
 	gd->bd->bi_baudrate = gd->baudrate = (i > 0)
+#endif
 			? (int) simple_strtoul (tmp, NULL, 10)
 			: CONFIG_BAUDRATE;
 
@@ -137,7 +142,12 @@ static int display_banner (void)
 {
 	printf ("\n\n%s\n\n", version_string);
 	debug ("U-Boot code: %08lX -> %08lX  BSS: -> %08lX\n",
-	       _armboot_start, _bss_start, _bss_end);
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+	       _TEXT_BASE,
+#else
+	       _armboot_start,
+#endif
+	       _bss_start, _bss_end);
 #ifdef CONFIG_MODEM_SUPPORT
 	debug ("Modem Support enabled\n");
 #endif
@@ -180,6 +190,7 @@ static int display_dram_config (void)
 	return (0);
 }
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 #ifndef CONFIG_SYS_NO_FLASH
 static void display_flash_config (ulong size)
 {
@@ -187,6 +198,7 @@ static void display_flash_config (ulong size)
 	print_size (size, "\n");
 }
 #endif /* CONFIG_SYS_NO_FLASH */
+#endif
 
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 static int init_func_i2c (void)
@@ -234,6 +246,7 @@ typedef int (init_fnc_t) (void);
 
 int print_cpuinfo (void);
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 init_fnc_t *init_sequence[] = {
 #if defined(CONFIG_ARCH_CPU_INIT)
 	arch_cpu_init,		/* basic arch cpu dependent setup */
@@ -444,6 +457,459 @@ extern void davinci_eth_set_mac_addr (const u_int8_t *addr);
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
+#else
+void __dram_init_banksize(void)
+{
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+	gd->bd->bi_dram[0].size =  gd->ram_size;
+}
+void dram_init_banksize(void)
+	__attribute__((weak, alias("__dram_init_banksize")));
+
+init_fnc_t *init_sequence[] = {
+#if defined(CONFIG_ARCH_CPU_INIT)
+	arch_cpu_init,		/* basic arch cpu dependent setup */
+#endif
+#if defined(CONFIG_BOARD_EARLY_INIT_F)
+	board_early_init_f,
+#endif
+	timer_init,		/* initialize timer */
+#ifdef CONFIG_FSL_ESDHC
+	get_clocks,
+#endif
+	env_init,		/* initialize environment */
+	init_baudrate,		/* initialze baudrate settings */
+	serial_init,		/* serial communications setup */
+	console_init_f,		/* stage 1 init of console */
+	display_banner,		/* say that we are here */
+#if defined(CONFIG_DISPLAY_CPUINFO)
+	print_cpuinfo,		/* display cpu info (and speed) */
+#endif
+#if defined(CONFIG_DISPLAY_BOARDINFO)
+	checkboard,		/* display board info */
+#endif
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+	init_func_i2c,
+#endif
+	dram_init,		/* configure available RAM banks */
+#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
+	arm_pci_init,
+#endif
+	NULL,
+};
+
+void board_init_f (ulong bootflag)
+{
+	bd_t *bd;
+	init_fnc_t **init_fnc_ptr;
+	gd_t *id;
+	ulong addr, addr_sp;
+
+	/* Pointer is writable since we allocated a register for it */
+	gd = (gd_t *) (CONFIG_SYS_INIT_SP_ADDR);
+	/* compiler optimization barrier needed for GCC >= 3.4 */
+	__asm__ __volatile__("": : :"memory");
+
+	memset ((void*)gd, 0, sizeof (gd_t));
+
+	gd->mon_len = _bss_end - _TEXT_BASE;
+
+	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
+		if ((*init_fnc_ptr)() != 0) {
+			hang ();
+		}
+	}
+
+	debug ("monitor len: %08lX\n", gd->mon_len);
+	/*
+	 * Ram is setup, size stored in gd !!
+	 */
+	debug ("ramsize: %08lX\n", gd->ram_size);
+#if defined(CONFIG_SYS_MEM_TOP_HIDE)
+	/*
+	 * Subtract specified amount of memory to hide so that it won't
+	 * get "touched" at all by U-Boot. By fixing up gd->ram_size
+	 * the Linux kernel should now get passed the now "corrected"
+	 * memory size and won't touch it either. This should work
+	 * for arch/ppc and arch/powerpc. Only Linux board ports in
+	 * arch/powerpc with bootwrapper support, that recalculate the
+	 * memory size from the SDRAM controller setup will have to
+	 * get fixed.
+	 */
+	gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
+#endif
+
+	addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
+
+#ifdef CONFIG_LOGBUFFER
+#ifndef CONFIG_ALT_LB_ADDR
+	/* reserve kernel log buffer */
+	addr -= (LOGBUFF_RESERVE);
+	debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
+#endif
+#endif
+
+#ifdef CONFIG_PRAM
+	/*
+	 * reserve protected RAM
+	 */
+	i = getenv_r ("pram", (char *)tmp, sizeof (tmp));
+	reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM;
+	addr -= (reg << 10);		/* size is in kB */
+	debug ("Reserving %ldk for protected RAM@%08lx\n", reg, addr);
+#endif /* CONFIG_PRAM */
+
+#if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE))
+	/* reserve TLB table */
+	addr -= (4096 * 4);
+
+	/* round down to next 64 kB limit */
+	addr &= ~(0x10000 - 1);
+
+	gd->tlb_addr = addr;
+	debug ("TLB table at: %08lx\n", addr);
+#endif
+
+	/* round down to next 4 kB limit */
+	addr &= ~(4096 - 1);
+	debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
+
+#ifdef CONFIG_VFD
+#	ifndef PAGE_SIZE
+#	  define PAGE_SIZE 4096
+#	endif
+	/*
+	 * reserve memory for VFD display (always full pages)
+	 */
+	addr -= vfd_setmem (addr);
+	gd->fb_base = addr;
+#endif /* CONFIG_VFD */
+
+#ifdef CONFIG_LCD
+	/* reserve memory for LCD display (always full pages) */
+	addr = lcd_setmem (addr);
+	gd->fb_base = addr;
+#endif /* CONFIG_LCD */
+
+	/*
+	 * reserve memory for U-Boot code, data & bss
+	 * round down to next 4 kB limit
+	 */
+	addr -= gd->mon_len;
+	addr &= ~(4096 - 1);
+
+	debug ("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr);
+
+#ifndef CONFIG_PRELOADER
+	/*
+	 * reserve memory for malloc() arena
+	 */
+	addr_sp = addr - TOTAL_MALLOC_LEN;
+	debug ("Reserving %dk for malloc() at: %08lx\n",
+			TOTAL_MALLOC_LEN >> 10, addr_sp);
+	/*
+	 * (permanently) allocate a Board Info struct
+	 * and a permanent copy of the "global" data
+	 */
+	addr_sp -= sizeof (bd_t);
+	bd = (bd_t *) addr_sp;
+	gd->bd = bd;
+	debug ("Reserving %zu Bytes for Board Info at: %08lx\n",
+			sizeof (bd_t), addr_sp);
+	addr_sp -= sizeof (gd_t);
+	id = (gd_t *) addr_sp;
+	debug ("Reserving %zu Bytes for Global Data at: %08lx\n",
+			sizeof (gd_t), addr_sp);
+
+	/* setup stackpointer for exeptions */
+	gd->irq_sp = addr_sp;
+#ifdef CONFIG_USE_IRQ
+	addr_sp -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ);
+	debug ("Reserving %zu Bytes for IRQ stack at: %08lx\n",
+		CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp);
+#endif
+	/* leave 3 words for abort-stack    */
+	addr_sp -= 3;
+
+	/* 8-byte alignment for ABI compliance */
+	addr_sp &= ~0x07;
+#else
+	addr_sp += 128;	/* leave 32 words for abort-stack   */
+	gd->irq_sp = addr_sp;
+#endif
+
+	debug ("New Stack Pointer is: %08lx\n", addr_sp);
+
+#ifdef CONFIG_POST
+	post_bootmode_init();
+	post_run (NULL, POST_ROM | post_bootmode_get(0));
+#endif
+
+	gd->bd->bi_baudrate = gd->baudrate;
+	/* Ram ist board specific, so move it to board code ... */
+	dram_init_banksize();
+	display_dram_config();	/* and display it */
+
+	gd->relocaddr = addr;
+	gd->start_addr_sp = addr_sp;
+	gd->reloc_off = addr - _TEXT_BASE;
+	debug ("relocation Offset is: %08lx\n", gd->reloc_off);
+	memcpy (id, (void *)gd, sizeof (gd_t));
+
+	relocate_code (addr_sp, id, addr);
+
+	/* NOTREACHED - relocate_code() does not return */
+}
+
+#if !defined(CONFIG_SYS_NO_FLASH)
+static char *failed = "*** failed ***\n";
+#endif
+
+/************************************************************************
+ *
+ * This is the next part if the initialization sequence: we are now
+ * running from RAM and have a "normal" C environment, i. e. global
+ * data can be written, BSS has been cleared, the stack size in not
+ * that critical any more, etc.
+ *
+ ************************************************************************
+ */
+void board_init_r (gd_t *id, ulong dest_addr)
+{
+	char *s;
+	bd_t *bd;
+	ulong malloc_start;
+#if !defined(CONFIG_SYS_NO_FLASH)
+	ulong flash_size;
+#endif
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+	extern void malloc_bin_reloc (void);
+#if defined(CONFIG_CMD_BMP)
+	extern void bmp_reloc(void);
+#endif
+#if defined(CONFIG_CMD_I2C)
+	extern void i2c_reloc(void);
+#endif
+#endif
+
+	gd = id;
+	bd = gd->bd;
+
+	gd->flags |= GD_FLG_RELOC;	/* tell others: relocation done */
+
+	monitor_flash_len = _bss_start - _TEXT_BASE;
+	debug ("monitor flash len: %08lX\n", monitor_flash_len);
+	board_init();	/* Setup chipselects */
+
+#ifdef CONFIG_SERIAL_MULTI
+	serial_initialize();
+#endif
+
+	debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
+
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+	/*
+	 * We have to relocate the command table manually
+	 */
+	fixup_cmdtable(&__u_boot_cmd_start,
+		(ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
+#if defined(CONFIG_CMD_BMP)
+	bmp_reloc();
+#endif
+#if defined(CONFIG_CMD_I2C)
+	i2c_reloc();
+#endif
+#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
+
+#ifdef CONFIG_LOGBUFFER
+	logbuff_init_ptrs ();
+#endif
+#ifdef CONFIG_POST
+	post_output_backlog ();
+#ifndef CONFIG_RELOC_FIXUP_WORKS
+	post_reloc ();
+#endif
+#endif
+
+	/* The Malloc area is immediately below the monitor copy in DRAM */
+	malloc_start = dest_addr - TOTAL_MALLOC_LEN;
+	mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+	malloc_bin_reloc ();
+#endif
+
+#if !defined(CONFIG_SYS_NO_FLASH)
+	puts ("FLASH: ");
+
+	if ((flash_size = flash_init ()) > 0) {
+# ifdef CONFIG_SYS_FLASH_CHECKSUM
+		print_size (flash_size, "");
+		/*
+		 * Compute and print flash CRC if flashchecksum is set to 'y'
+		 *
+		 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
+		 */
+		s = getenv ("flashchecksum");
+		if (s && (*s == 'y')) {
+			printf ("  CRC: %08X",
+				crc32 (0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size)
+			);
+		}
+		putc ('\n');
+# else	/* !CONFIG_SYS_FLASH_CHECKSUM */
+		print_size (flash_size, "\n");
+# endif /* CONFIG_SYS_FLASH_CHECKSUM */
+	} else {
+		puts (failed);
+		hang ();
+	}
+#endif
+
+#if defined(CONFIG_CMD_NAND)
+	puts ("NAND:  ");
+	nand_init();		/* go init the NAND */
+#endif
+
+#if defined(CONFIG_CMD_ONENAND)
+	onenand_init();
+#endif
+
+#ifdef CONFIG_HAS_DATAFLASH
+	AT91F_DataflashInit();
+	dataflash_print_info();
+#endif
+
+	/* initialize environment */
+	env_relocate ();
+
+#ifdef CONFIG_VFD
+	/* must do this after the framebuffer is allocated */
+	drv_vfd_init();
+#endif /* CONFIG_VFD */
+
+	/* IP Address */
+	gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
+
+	stdio_init ();	/* get the devices list going. */
+
+	jumptable_init ();
+
+#if defined(CONFIG_API)
+	/* Initialize API */
+	api_init ();
+#endif
+
+	console_init_r ();	/* fully init console as a device */
+
+#if defined(CONFIG_ARCH_MISC_INIT)
+	/* miscellaneous arch dependent initialisations */
+	arch_misc_init ();
+#endif
+#if defined(CONFIG_MISC_INIT_R)
+	/* miscellaneous platform dependent initialisations */
+	misc_init_r ();
+#endif
+
+	 /* set up exceptions */
+	interrupt_init ();
+	/* enable exceptions */
+	enable_interrupts ();
+
+	/* Perform network card initialisation if necessary */
+#ifdef CONFIG_DRIVER_TI_EMAC
+	/* XXX: this needs to be moved to board init */
+extern void davinci_eth_set_mac_addr (const u_int8_t *addr);
+	if (getenv ("ethaddr")) {
+		uchar enetaddr[6];
+		eth_getenv_enetaddr("ethaddr", enetaddr);
+		davinci_eth_set_mac_addr(enetaddr);
+	}
+#endif
+
+#if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
+	/* XXX: this needs to be moved to board init */
+	if (getenv ("ethaddr")) {
+		uchar enetaddr[6];
+		eth_getenv_enetaddr("ethaddr", enetaddr);
+		smc_set_mac_addr(enetaddr);
+	}
+#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
+
+	/* Initialize from environment */
+	if ((s = getenv ("loadaddr")) != NULL) {
+		load_addr = simple_strtoul (s, NULL, 16);
+	}
+#if defined(CONFIG_CMD_NET)
+	if ((s = getenv ("bootfile")) != NULL) {
+		copy_filename (BootFile, s, sizeof (BootFile));
+	}
+#endif
+
+#ifdef BOARD_LATE_INIT
+	board_late_init ();
+#endif
+
+#ifdef CONFIG_GENERIC_MMC
+	puts ("MMC:   ");
+	mmc_initialize (gd->bd);
+#endif
+
+#ifdef CONFIG_BITBANGMII
+	bb_miiphy_init();
+#endif
+#if defined(CONFIG_CMD_NET)
+#if defined(CONFIG_NET_MULTI)
+	puts ("Net:   ");
+#endif
+	eth_initialize(gd->bd);
+#if defined(CONFIG_RESET_PHY_R)
+	debug ("Reset Ethernet PHY\n");
+	reset_phy();
+#endif
+#endif
+
+#ifdef CONFIG_POST
+	post_run (NULL, POST_RAM | post_bootmode_get(0));
+#endif
+
+#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
+	/*
+	 * Export available size of memory for Linux,
+	 * taking into account the protected RAM at top of memory
+	 */
+	{
+		ulong pram;
+		uchar memsz[32];
+#ifdef CONFIG_PRAM
+		char *s;
+
+		if ((s = getenv ("pram")) != NULL) {
+			pram = simple_strtoul (s, NULL, 10);
+		} else {
+			pram = CONFIG_PRAM;
+		}
+#else
+		pram=0;
+#endif
+#ifdef CONFIG_LOGBUFFER
+#ifndef CONFIG_ALT_LB_ADDR
+		/* Also take the logbuffer into account (pram is in kB) */
+		pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
+#endif
+#endif
+		sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
+		setenv ("mem", (char *)memsz);
+	}
+#endif
+
+	/* main_loop() can return to retry autoboot, if so just run it again. */
+	for (;;) {
+		main_loop ();
+	}
+
+	/* NOTREACHED - no way out of command loop except booting */
+}
+#endif /* defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 void hang (void)
 {
diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
index b2811f3..fe6d459 100644
--- a/arch/arm/lib/cache-cp15.c
+++ b/arch/arm/lib/cache-cp15.c
@@ -44,17 +44,44 @@ static void cp_delay (void)
 	asm volatile("" : : : "memory");
 }
 
-/* to activate the MMU we need to set up virtual memory: use 1M areas in bss */
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+static inline void dram_bank_mmu_setup(int bank)
+{
+	u32 *page_table = (u32 *)gd->tlb_addr;
+	bd_t *bd = gd->bd;
+	int	i;
+
+	debug("%s: bank: %d\n", __func__, bank);
+	for (i = bd->bi_dram[bank].start >> 20;
+	     i < (bd->bi_dram[bank].start + bd->bi_dram[bank].size) >> 20;
+	     i++) {
+		page_table[i] = i << 20 | (3 << 10) | CACHE_SETUP;
+	}
+}
+#endif
+
+/* to activate the MMU we need to set up virtual memory: use 1M areas */
 static inline void mmu_setup(void)
 {
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+	u32 *page_table = (u32 *)gd->tlb_addr;
+#else
 	static u32 __attribute__((aligned(16384))) page_table[4096];
 	bd_t *bd = gd->bd;
-	int i, j;
+	int j;
+#endif
+	int i;
 	u32 reg;
 
 	/* Set up an identity-mapping for all 4GB, rw for everyone */
 	for (i = 0; i < 4096; i++)
 		page_table[i] = i << 20 | (3 << 10) | 0x12;
+
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+		dram_bank_mmu_setup(i);
+	}
+#else
 	/* Then, enable cacheable and bufferable for RAM only */
 	for (j = 0; j < CONFIG_NR_DRAM_BANKS; j++) {
 		for (i = bd->bi_dram[j].start >> 20;
@@ -63,6 +90,7 @@ static inline void mmu_setup(void)
 			page_table[i] = i << 20 | (3 << 10) | CACHE_SETUP;
 		}
 	}
+#endif
 
 	/* Copy the page table address to cp15 */
 	asm volatile("mcr p15, 0, %0, c2, c0, 0"
@@ -74,7 +102,6 @@ static inline void mmu_setup(void)
 	reg = get_cr();	/* get control reg. */
 	cp_delay();
 	set_cr(reg | CR_M);
-
 }
 
 /* cache_bit must be either CR_I or CR_C */
@@ -96,6 +123,10 @@ static void cache_disable(uint32_t cache_bit)
 	uint32_t reg;
 
 	if (cache_bit == CR_C) {
+		/* if cache isn;t enabled no need to disable */
+		reg = get_cr();
+		if ((reg & CR_C) != CR_C)
+			return;
 		/* if disabling data cache, disable mmu too */
 		cache_bit |= CR_M;
 		flush_cache(0, ~0);
diff --git a/arch/arm/lib/interrupts.c b/arch/arm/lib/interrupts.c
index 1f2b815..9a21e7b 100644
--- a/arch/arm/lib/interrupts.c
+++ b/arch/arm/lib/interrupts.c
@@ -38,15 +38,20 @@
 #include <common.h>
 #include <asm/proc-armv/ptrace.h>
 
-#ifdef CONFIG_USE_IRQ
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_USE_IRQ
 int interrupt_init (void)
 {
 	/*
 	 * setup up stacks if necessary
 	 */
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+	IRQ_STACK_START = gd->irq_sp - 4;
+	IRQ_STACK_START_IN = gd->irq_sp + 8;
+#else
 	IRQ_STACK_START = _armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4;
+#endif
 	FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
 
 	return arch_interrupt_init();
@@ -81,6 +86,18 @@ int disable_interrupts (void)
 	return (old & 0x80) == 0;
 }
 #else
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+int interrupt_init (void)
+{
+	/*
+	 * setup up stacks if necessary
+	 */
+	IRQ_STACK_START_IN = gd->irq_sp + 8;
+
+	return 0;
+}
+#endif
+
 void enable_interrupts (void)
 {
 	return;
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index 2730fa9..58d9d20 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -343,7 +343,16 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	printf ("ip_addr     = %pI4\n", &bd->bi_ip_addr);
 #endif
 	printf ("baudrate    = %d bps\n", bd->bi_baudrate);
-
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+#if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE))
+	print_num ("TLB addr", gd->tlb_addr);
+#endif
+	print_num ("relocaddr", gd->relocaddr);
+	print_num ("reloc off", gd->reloc_off);
+	print_num ("irq_sp", gd->irq_sp);	/* irq stack pointer */
+	print_num ("sp start ", gd->start_addr_sp);
+	print_num ("FB base  ", gd->fb_base);
+#endif
 	return 0;
 }
 
diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c
index d51cc55..6fa8a15 100644
--- a/common/cmd_bmp.c
+++ b/common/cmd_bmp.c
@@ -137,6 +137,12 @@ static cmd_tbl_t cmd_bmp_sub[] = {
 	U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""),
 };
 
+#ifndef CONFIG_RELOC_FIXUP_WORKS
+void bmp_reloc(void) {
+	fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub));
+}
+#endif
+
 /*
  * Subroutine:  do_bmp
  *
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index a7b65ed..0a0cfce 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -1284,6 +1284,12 @@ static cmd_tbl_t cmd_i2c_sub[] = {
 	U_BOOT_CMD_MKENT(speed, 1, 1, do_i2c_bus_speed, "", ""),
 };
 
+#ifndef CONFIG_RELOC_FIXUP_WORKS
+void i2c_reloc(void) {
+	fixup_cmdtable(cmd_i2c_sub, ARRAY_SIZE(cmd_i2c_sub));
+}
+#endif
+
 static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	cmd_tbl_t *c;
diff --git a/doc/README.arm-relocation b/doc/README.arm-relocation
new file mode 100644
index 0000000..6be1a12
--- /dev/null
+++ b/doc/README.arm-relocation
@@ -0,0 +1,321 @@
+To make relocation on arm working, the following changes are done:
+
+Add new compilerflag:
+
+-fPIC
+
+	-> compiler generates position independent code
+
+changes in board code:
+
+- dram_init:
+  - bd pointer is now at this point not accessible, so only
+    detect the real dramsize, and store it in gd->ram_size.
+    best detected with get_ram_size();
+    ToDo: move there also the dram initialization on boards where
+          it is possible.
+  - setup the bd_t dram bank info in the new function
+    dram_init_banksize().
+
+- board.c code is adapted from ppc code
+
+- undef CONFIG_RELOC_FIXUP_WORKS
+
+  -> cmdtabl, and subcommand table must be handled from "hand"
+     collected in section "__datarellocal_start".
+
+  - How To fixup the sections:
+
+    __datarel_start, __datarelrolocal_start, __datarellocal_start and
+    __datarelro_start
+
+    automatically? Then it should be possible to define again
+    CONFIG_RELOC_FIXUP_WORKS
+
+- irq stack setup is now not longer on a fix position, instead it is
+  calculated in board_init_f, and stored in gd->irq_sp
+
+-------------------------------------------------------------------------------------
+
+To compile a board without relocation, define CONFIG_SYS_ARM_WITHOUT_RELOC
+This possibility will removed!! So please fix your board to compile without
+CONFIG_SYS_ARM_WITHOUT_RELOC defined!!!
+
+-------------------------------------------------------------------------------------
+
+ToDo:
+
+- fill in bd_t infos (check)
+- adapt all boards
+
+- maybe adapt TEXT_BASE (this must be checked from board maintainers)
+  This *must* be done for boards, which boot from NOR flash
+
+  on other boards if TEXT_BASE = relocation baseaddr, this saves
+  one copying from u-boot code.
+
+- new function dram_init_banksize() is actual board specific. Maybe
+  we make a weak default function in arch/arm/lib/board.c ?
+
+-------------------------------------------------------------------------------------
+
+Relocation with NAND_SPL (example for the tx25):
+
+- cpu copies the first page from NAND to 0xbb000000 (IMX_NFC_BASE)
+  and start with code execution on this address.
+
+- The First page contains u-boot code from u-boot:nand_spl/nand_boot_fsl_nfc.c
+  which inits the dram, cpu registers, reloacte itself to TEXT_BASE  and loads
+  the "real" u-boot to CONFIG_SYS_NAND_U_BOOT_DST and starts execution
+  @CONFIG_SYS_NAND_U_BOOT_START
+
+- This u-boot does no ram int, nor cpu register setup. Just looks
+  where it have to relocate and relocate itself to this address.
+  If relocate address = TEXT_BASE(not the same, as the TEXT_BASE
+  from the nand_spl code), no need to copy, just go on with bss clear
+  and jump to board_init_r.
+
+-------------------------------------------------------------------------------------
+
+Relocation:
+How to translate flash addresses in GOT to ram addresses.
+This is automagically done from code, but this example
+shows, how this magic code works ;-)
+(example on the qong board)
+
+Find a variable:
+
+a) search it in System.map
+(for example flash_info)
+
+a005b4c0 B BootpID
+a005b4c4 B BootpTry
+a005b4c8 b slave
+a005b4cc B flash_info
+^^^^^^^^
+a005c908 b saved_sector.4002
+a005c910 b cfi_mtd_info
+a005c9c0 b cfi_mtd_names
+a005c9d0 B mtd_table
+
+---------------------------------------
+
+b) create hexdump from u-boot code:
+
+hexdump -C u-boot > gnlmpfhex
+
+---------------------------------------
+
+c) search the variables address in the hexdump
+
+
+*
+0005fc80  00 00 00 00 00 00 00 00  2c 06 01 a0 18 cd 05 a0  |........,.......|
+0005fc90  9c d4 05 a0 bc b4 05 a0  1c 7f 05 a0 f0 05 01 a0  |................|
+0005fca0  08 5a 04 a0 1c ab 05 a0  ec a4 05 a0 98 c3 01 a0  |.Z..............|
+0005fcb0  a0 d6 05 a0 04 71 05 a0  c0 f9 00 a0 3c cd 05 a0  |.....q......<...|
+0005fcc0  cc b4 05 a0 f0 fa 00 a0  f0 d6 05 a0 10 86 05 a0  |................|
+          ^^^^^^^^^^^
+0005fcd0  a4 16 06 a0 dc 64 05 a0  18 86 05 a0 52 48 05 a0  |.....d......RH..|
+0005fce0  c0 86 05 a0 24 6e 02 a0  b4 6c 05 a0 b0 94 01 a0  |....$n...l......|
+0005fcf0  1c 86 05 a0 50 85 05 a0  d4 0c 06 a0 bc 0b 06 a0  |....P...........|
+
+
+-> 0005fcc0
+
+----------------------------------------
+
+d) know we calculate this address in RAM
+
+
+  8ff08000	(new address of code in RAM *1)
+
++ 0005fcc0
+
+- 00008000	(offset of text *2)
+
+----------
+
+  8ff5fcc0	-> Addr GOT in RAM
+
+*1:
+activate debug and look for the line:
+Now running in RAM - U-Boot at: 8ff08000
+                                ^^^^^^^^
+                                new address of u-boot code in RAM
+
+*2:
+Section Headers:
+  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
+  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
+  [ 1] .text             PROGBITS        a0000000 008000 04599c 00  AX  0   0 32
+                                                  ^^^^^^
+                                                  Offset of text
+
+----------------------------------------
+
+e) now we look in 8ff5fcc0 (RAM)
+
+
+QongEVB>md 0x8ff5fcc0
+8ff5fcc0 : a005b4cc a000faf0 a005d6f0 a0058610  ................
+           ^^^^^^^^
+           Bingo, here we have the old flash address (when relocation
+           is working, here is the fixed ram address. see @ f, how
+           it gets calculated)
+
+
+----------------------------------------
+
+f) now translate it in the new RAM address
+
+  a005b4cc
+
+- a0000000     TextBase
+
++ 8ff08000     new address of u-boot in ram
+----------
+  8ff634cc
+
+QongEVB>mm 0x8ff5fcc0 0x8ff634cc 1
+QongEVB>md 0x8ff5fcc0
+8ff5fcc0 : 8ff634cc a000faf0 a005d6f0 a0058610  .4..............
+8ff5fcd0 : a00616a4 a00564dc a0058618 a0054852  .....d......RH..
+
+As this must be done for all address in the GOT, the u-boot
+code did this automagically ... :-)
+
+----------------------------------------------
+
+g) check if the new address is really in the bss section:
+
+bss start:
+8ff6054c	(8ff08000 + 0005854C monitorlen)
+
+bss end:
+8ff698ac	(8ff08000 + 618AC)
+
+8ff634cc is in bss :-)
+
+----------------------------------------------
+
+h) u-boot prints:
+
+important  addresses:
+
+U-Boot code: A0000000 -> A005854C  BSS: -> A00618AC	TextBase 0xa0000000
+Now running in RAM - U-Boot at: 8ff08000		relocBase 0x8ff08000
+
+
+---------
+
+U-Boot 2010.06-rc2-00002-gf8fbb25-dirty (Jun 18 2010 - 17:07:19)
+
+U-Boot code: A0000000 -> A005854C  BSS: -> A00618AC
+CPU:   Freescale i.MX31 at 398 MHz
+Board: DAVE/DENX Qong
+mon: FFFFFFFF gd->monLen: 000618AC
+Top of RAM usable for U-Boot at: 90000000
+LCD panel info: 640 x 480, 16 bit/pix
+Reserving 600k for LCD Framebuffer at: 8ff6a000
+Reserving 390k for U-Boot at: 8ff08000
+Reserving 1280k for malloc() at: 8fdc8000
+Reserving 28 Bytes for Board Info at: 8fdc7fe4
+Reserving 48 Bytes for Global Data at: 8fdc7fb4
+New Stack Pointer is: 8fdc7fb0
+RAM Configuration:
+Bank #0: 80000000 256 MiB
+mon: 0005854C gd->monLen: 000618AC
+Now running in RAM - U-Boot at: 8ff08000
+
+-------------------------------------------------------------------------------------
+
+Debugging u-boot in RAM:
+(example on the qong board)
+
+a) add in config.mk:
+
+PLATFORM_CPPFLAGS += -DDEBUG
+
+-----------------
+
+b) start debugger
+
+arm-linux-gdb u-boot
+
+[hs at pollux u-boot]$ arm-linux-gdb u-boot
+GNU gdb Red Hat Linux (6.7-2rh)
+Copyright (C) 2007 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
+and "show warranty" for details.
+This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-linux".
+The target architecture is set automatically (currently arm)
+..
+(gdb)
+
+-----------------
+
+c) connect to target
+
+target remote bdi10:2001
+
+(gdb) target remote bdi10:2001
+Remote debugging using bdi10:2001
+0x8ff17f10 in ?? ()
+(gdb)
+
+-----------------
+
+d) discard symbol-file
+
+(gdb) symbol-file
+Discard symbol table from `/home/hs/celf/u-boot/u-boot'? (y or n) y
+No symbol file now.
+(gdb)
+
+-----------------
+
+e) load new symbol table:
+
+(gdb) add-symbol-file u-boot 0x8ff08000
+add symbol table from file "u-boot" at
+        .text_addr = 0x8ff08000
+(y or n) y
+Reading symbols from /home/hs/celf/u-boot/u-boot...done.
+(gdb) c
+Continuing.
+^C
+Program received signal SIGSTOP, Stopped (signal).
+0x8ff17f18 in serial_getc () at serial_mxc.c:192
+192             while (__REG(UART_PHYS + UTS) & UTS_RXEMPTY);
+(gdb)
+
+add-symbol-file u-boot 0x8ff08000
+                       ^^^^^^^^^^
+                       get this address from u-boot debug printfs
+
+U-Boot 2010.06-rc2-00009-gf77b8b8-dirty (Jun 22 2010 - 09:43:46)
+
+U-Boot code: A0000000 -> A0058BAC  BSS: -> A0061F10
+CPU:   Freescale i.MX31 at 398 MHz
+Board: DAVE/DENX Qong
+mon: FFFFFFFF gd->monLen: 00061F10
+Top of RAM usable for U-Boot at: 90000000
+LCD panel info: 640 x 480, 16 bit/pix
+Reserving 600k for LCD Framebuffer at: 8ff6a000
+Reserving 391k for U-Boot at: 8ff08000
+                              ^^^^^^^^
+Reserving 1280k for malloc() at: 8fdc8000
+Reserving 24 Bytes for Board Info at: 8fdc7fe8
+Reserving 52 Bytes for Global Data at: 8fdc7fb4
+New Stack Pointer is: 8fdc7fb0
+RAM Configuration:
+Bank #0: 80000000 256 MiB
+relocation Offset is: eff08000
+mon: 00058BAC gd->monLen: 00061F10
+Now running in RAM - U-Boot at: 8ff08000
+                                ^^^^^^^^
+
+Now you can use gdb as usual :-)
diff --git a/nand_spl/nand_boot.c b/nand_spl/nand_boot.c
index b9fd6f5..18ecbe1 100644
--- a/nand_spl/nand_boot.c
+++ b/nand_spl/nand_boot.c
@@ -221,6 +221,13 @@ static int nand_load(struct mtd_info *mtd, unsigned int offs,
 	return 0;
 }
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+void board_init_f (ulong bootflag)
+{
+	relocate_code (TEXT_BASE - TOTAL_MALLOC_LEN, NULL, TEXT_BASE);
+}
+#endif
+
 /*
  * The main entry for NAND booting. It's necessary that SDRAM is already
  * configured and available since this code loads the main U-Boot image
diff --git a/nand_spl/nand_boot_fsl_nfc.c b/nand_spl/nand_boot_fsl_nfc.c
index ea3566b..3105657 100644
--- a/nand_spl/nand_boot_fsl_nfc.c
+++ b/nand_spl/nand_boot_fsl_nfc.c
@@ -263,6 +263,13 @@ static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)
 	return 0;
 }
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+void board_init_f (ulong bootflag)
+{
+	relocate_code (TEXT_BASE - TOTAL_MALLOC_LEN, NULL, TEXT_BASE);
+}
+#endif
+
 /*
  * The main entry for NAND booting. It's necessary that SDRAM is already
  * configured and available since this code loads the main U-Boot image
-- 
1.6.2.5

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

* [U-Boot] [PATCH 13/26 v2][NEXT] ARM: implement relocation for ARM11
  2010-09-17 11:10                         ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Heiko Schocher
@ 2010-09-17 11:10                           ` Heiko Schocher
  2010-09-17 11:10                             ` [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP) Heiko Schocher
  2010-09-17 13:07                           ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Albert ARIBAUD
                                             ` (3 subsequent siblings)
  4 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for ARM11 to relocate the code to an
arbitrary address in RAM.

Tested on the qong board.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/arm1136/start.S    |  201 +++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/arm1136/u-boot.lds |   14 +++-
 board/davedenx/qong/config.mk   |    4 +-
 board/davedenx/qong/qong.c      |   87 +++++++++--------
 include/configs/qong.h          |   10 ++
 5 files changed, 273 insertions(+), 43 deletions(-)

diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S
index 1c58abd..8b63192 100644
--- a/arch/arm/cpu/arm1136/start.S
+++ b/arch/arm/cpu/arm1136/start.S
@@ -85,12 +85,15 @@ _end_vect:
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -103,6 +106,32 @@ _bss_start:
 _bss_end:
 	.word _end
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+#endif
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -115,6 +144,164 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+#endif
+
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+#ifdef CONFIG_OMAP2420H4
+       /* Copy vectors to mask ROM indirect addr */
+	adr	r0, _start		/* r0 <- current position of code   */
+		add     r0, r0, #4				/* skip reset vector			*/
+	mov	r2, #64			/* r2 <- size to copy  */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	mov	r1, #SRAM_OFFSET0	  /* build vect addr */
+	mov	r3, #SRAM_OFFSET1
+	add	r1, r1, r3
+	mov	r3, #SRAM_OFFSET2
+	add	r1, r1, r3
+next:
+	ldmia	r0!, {r3-r10}		/* copy from source address [r0]    */
+	stmia	r1!, {r3-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end address [r2]    */
+	bne	next			/* loop until equal */
+	bl	cpy_clk_code		/* put dpll adjust code behind vectors */
+#endif
+	/* the mask ROM code should have PLL and others stable */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl  cpu_init_crit
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+
+#ifdef CONFIG_NAND_SPL
+	bl	nand_boot
+#else
+#ifdef CONFIG_ONENAND_IPL
+	bl	start_oneboot
+#else
+	bl	board_init_f
+#endif /* CONFIG_ONENAND_IPL */
+#endif /* CONFIG_NAND_SPL */
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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 */
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+#ifdef CONFIG_NAND_SPL
+	ldr     pc, _nand_boot
+
+_nand_boot: .word nand_boot
+#else
+jump_2_ram:
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+#endif
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 /*
  * the actual reset code
  */
@@ -211,6 +398,8 @@ _start_armboot: .word start_armboot
 #endif /* CONFIG_ONENAND_IPL */
 #endif /* CONFIG_NAND_SPL */
 
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
+
 /*
  *************************************************************************
  *
@@ -295,9 +484,13 @@ cpu_init_crit:
 	sub	sp, sp, #S_FRAME_SIZE		@ carve out a frame on current user stack
 	stmia	sp, {r0 - r12}			@ Save user registers (now in svc mode) r0-r12
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+	ldr	r2, IRQ_STACK_START_IN		@ set base 2 words into abort stack
+#else
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)	@ set base 2 words into abort stack
+#endif
 	ldmia	r2, {r2 - r3}			@ get values for "aborted" pc and cpsr (into parm regs)
 	add	r0, sp, #S_FRAME_SIZE		@ grab pointer to old stack
 
@@ -328,9 +521,13 @@ cpu_init_crit:
 	.endm
 
 	.macro get_bad_stack
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack (enter in banked mode)
+#else
 	ldr	r13, _armboot_start		@ setup our mode stack (enter in banked mode)
 	sub	r13, r13, #(CONFIG_SYS_MALLOC_LEN)	@ move past malloc pool
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ move to reserved a couple spots for abort stack
+#endif
 
 	str	lr, [r13]			@ save caller lr in position 0 of saved stack
 	mrs	lr, spsr			@ get the spsr
@@ -346,9 +543,13 @@ cpu_init_crit:
 	.macro get_bad_stack_swi
 	sub	r13, r13, #4			@ space on current stack for scratch reg.
 	str	r0, [r13]			@ save R0's value.
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+	ldr	r0, IRQ_STACK_START_IN		@ get data regions start
+#else
 	ldr	r0, _armboot_start		@ get data regions start
 	sub	r0, r0, #(CONFIG_SYS_MALLOC_LEN)	@ move past malloc pool
 	sub	r0, r0, #(CONFIG_SYS_GBL_DATA_SIZE+8)	@ move past gbl and a couple spots for abort stack
+#endif
 	str	lr, [r0]			@ save caller lr in position 0 of saved stack
 	mrs	r0, spsr			@ get the spsr
 	str	lr, [r0, #4]			@ save spsr in position 1 of saved stack
diff --git a/arch/arm/cpu/arm1136/u-boot.lds b/arch/arm/cpu/arm1136/u-boot.lds
index e7eefc9..1db4b49 100644
--- a/arch/arm/cpu/arm1136/u-boot.lds
+++ b/arch/arm/cpu/arm1136/u-boot.lds
@@ -47,11 +47,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
diff --git a/board/davedenx/qong/config.mk b/board/davedenx/qong/config.mk
index d8d0a57..39c1203 100644
--- a/board/davedenx/qong/config.mk
+++ b/board/davedenx/qong/config.mk
@@ -1 +1,3 @@
-TEXT_BASE = 0x8ff00000
+TEXT_BASE = 0xa0000000
+
+# PLATFORM_CPPFLAGS += -DDEBUG
diff --git a/board/davedenx/qong/qong.c b/board/davedenx/qong/qong.c
index 781333b..e509383 100644
--- a/board/davedenx/qong/qong.c
+++ b/board/davedenx/qong/qong.c
@@ -33,10 +33,9 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init (void)
 {
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = get_ram_size((volatile void *)PHYS_SDRAM_1,
-			PHYS_SDRAM_1_SIZE);
-
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size((volatile void *)CONFIG_SYS_SDRAM_BASE,
+				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
 
@@ -49,6 +48,49 @@ static void qong_fpga_reset(void)
 	udelay(300);
 }
 
+int board_early_init_f (void)
+{
+#ifdef CONFIG_QONG_FPGA
+	/* CS1: FPGA/Network Controller/GPIO */
+	/* 16-bit, no DTACK */
+	__REG(CSCR_U(1)) = 0x00000A01;
+	__REG(CSCR_L(1)) = 0x20040501;
+	__REG(CSCR_A(1)) = 0x04020C00;
+
+	/* setup pins for FPGA */
+	mx31_gpio_mux(IOMUX_MODE(0x76, MUX_CTL_GPIO));
+	mx31_gpio_mux(IOMUX_MODE(0x7e, MUX_CTL_GPIO));
+	mx31_gpio_mux(IOMUX_MODE(0x91, MUX_CTL_OUT_FUNC | MUX_CTL_IN_GPIO));
+	mx31_gpio_mux(IOMUX_MODE(0x92, MUX_CTL_GPIO));
+	mx31_gpio_mux(IOMUX_MODE(0x93, MUX_CTL_GPIO));
+
+	/* FPGA reset  Pin */
+	/* rstn = 0 */
+	mx31_gpio_set(QONG_FPGA_RST_PIN, 0);
+	mx31_gpio_direction(QONG_FPGA_RST_PIN, MX31_GPIO_DIRECTION_OUT);
+
+	/* set interrupt pin as input */
+	mx31_gpio_direction(QONG_FPGA_IRQ_PIN, MX31_GPIO_DIRECTION_IN);
+
+#endif
+
+	/* setup pins for UART1 */
+	mx31_gpio_mux(MUX_RXD1__UART1_RXD_MUX);
+	mx31_gpio_mux(MUX_TXD1__UART1_TXD_MUX);
+	mx31_gpio_mux(MUX_RTS1__UART1_RTS_B);
+	mx31_gpio_mux(MUX_CTS1__UART1_CTS_B);
+
+	/* setup pins for SPI (pmic) */
+	mx31_gpio_mux(MUX_CSPI2_SS0__CSPI2_SS0_B);
+	mx31_gpio_mux(MUX_CSPI2_MOSI__CSPI2_MOSI);
+	mx31_gpio_mux(MUX_CSPI2_MISO__CSPI2_MISO);
+	mx31_gpio_mux(MUX_CSPI2_SCLK__CSPI2_CLK);
+	mx31_gpio_mux(MUX_CSPI2_SPI_RDY__CSPI2_DATAREADY_B);
+
+	return 0;
+
+}
+
 int board_init (void)
 {
 	/* Chip selects */
@@ -99,43 +141,6 @@ int board_init (void)
 						(0 << 0)	  /* FCE */
 					   );
 
-#ifdef CONFIG_QONG_FPGA
-	/* CS1: FPGA/Network Controller/GPIO */
-	/* 16-bit, no DTACK */
-	__REG(CSCR_U(1)) = 0x00000A01;
-	__REG(CSCR_L(1)) = 0x20040501;
-	__REG(CSCR_A(1)) = 0x04020C00;
-
-	/* setup pins for FPGA */
-	mx31_gpio_mux(IOMUX_MODE(0x76, MUX_CTL_GPIO));
-	mx31_gpio_mux(IOMUX_MODE(0x7e, MUX_CTL_GPIO));
-	mx31_gpio_mux(IOMUX_MODE(0x91, MUX_CTL_OUT_FUNC | MUX_CTL_IN_GPIO));
-	mx31_gpio_mux(IOMUX_MODE(0x92, MUX_CTL_GPIO));
-	mx31_gpio_mux(IOMUX_MODE(0x93, MUX_CTL_GPIO));
-
-	/* FPGA reset  Pin */
-	/* rstn = 0 */
-	mx31_gpio_set(QONG_FPGA_RST_PIN, 0);
-	mx31_gpio_direction(QONG_FPGA_RST_PIN, MX31_GPIO_DIRECTION_OUT);
-
-	/* set interrupt pin as input */
-	mx31_gpio_direction(QONG_FPGA_IRQ_PIN, MX31_GPIO_DIRECTION_IN);
-
-#endif
-
-	/* setup pins for UART1 */
-	mx31_gpio_mux(MUX_RXD1__UART1_RXD_MUX);
-	mx31_gpio_mux(MUX_TXD1__UART1_TXD_MUX);
-	mx31_gpio_mux(MUX_RTS1__UART1_RTS_B);
-	mx31_gpio_mux(MUX_CTS1__UART1_CTS_B);
-
-	/* setup pins for SPI (pmic) */
-	mx31_gpio_mux(MUX_CSPI2_SS0__CSPI2_SS0_B);
-	mx31_gpio_mux(MUX_CSPI2_MOSI__CSPI2_MOSI);
-	mx31_gpio_mux(MUX_CSPI2_MISO__CSPI2_MISO);
-	mx31_gpio_mux(MUX_CSPI2_SCLK__CSPI2_CLK);
-	mx31_gpio_mux(MUX_CSPI2_SPI_RDY__CSPI2_DATAREADY_B);
-
 	/* board id for linux */
 	gd->bd->bi_arch_number = MACH_TYPE_QONG;
 	gd->bd->bi_boot_params = (0x80000100);	/* adress of boot parameters */
diff --git a/include/configs/qong.h b/include/configs/qong.h
index 4735b5e..7a68b7b 100644
--- a/include/configs/qong.h
+++ b/include/configs/qong.h
@@ -282,4 +282,14 @@ extern int qong_nand_rdy(void *chip);
 	"mtdparts=physmap-flash.0:384k(U-Boot),128k(env1),"	\
 	"128k(env2),2432k(kernel),13m(ramdisk),-(user)"
 
+/* additions for new relocation code, must added to all boards */
+#undef CONFIG_SYS_ARM_WITHOUT_RELOC /* This board is tested with relocation support */
+#define CONFIG_SYS_SDRAM_BASE		0x80000000
+#define CONFIG_SYS_INIT_RAM_ADDR	IRAM_BASE_ADDR
+#define CONFIG_SYS_INIT_RAM_END		IRAM_SIZE
+#define CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_INIT_RAM_END - CONFIG_SYS_GBL_DATA_SIZE)
+#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET)
+
+#define CONFIG_BOARD_EARLY_INIT_F	1
+
 #endif /* __CONFIG_H */
-- 
1.6.2.5

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

* [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP)
  2010-09-17 11:10                           ` [U-Boot] [PATCH 13/26 v2][NEXT] ARM: implement relocation for ARM11 Heiko Schocher
@ 2010-09-17 11:10                             ` Heiko Schocher
  2010-09-17 11:10                               ` [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926 Heiko Schocher
  2010-09-17 21:40                               ` [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP) John Rigby
  0 siblings, 2 replies; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for ARM V7 to relocate the code to an
arbitrary address in RAM.

Adapt the Beagle board (Cortex A8) to test the changes.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/armv7/mx51/u-boot.lds |   14 +++-
 arch/arm/cpu/armv7/omap3/emif4.c   |   34 +++++++
 arch/arm/cpu/armv7/omap3/sdrc.c    |   38 +++++++
 arch/arm/cpu/armv7/start.S         |  191 +++++++++++++++++++++++++++++++++++-
 arch/arm/cpu/armv7/u-boot.lds      |   14 +++-
 board/ti/beagle/config.mk          |    2 +-
 include/configs/omap3_beagle.h     |    5 +
 7 files changed, 291 insertions(+), 7 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx51/u-boot.lds b/arch/arm/cpu/armv7/mx51/u-boot.lds
index d66434c..55d6599 100644
--- a/arch/arm/cpu/armv7/mx51/u-boot.lds
+++ b/arch/arm/cpu/armv7/mx51/u-boot.lds
@@ -44,10 +44,22 @@ SECTIONS
 	.rodata : { *(.rodata) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
+	__got_end = .;
 
 	. = .;
 	__u_boot_cmd_start = .;
diff --git a/arch/arm/cpu/armv7/omap3/emif4.c b/arch/arm/cpu/armv7/omap3/emif4.c
index fae5b11..da2cd90 100644
--- a/arch/arm/cpu/armv7/omap3/emif4.c
+++ b/arch/arm/cpu/armv7/omap3/emif4.c
@@ -136,6 +136,7 @@ void do_emif4_init(void)
  * dram_init -
  *  - Sets uboots idea of sdram size
  */
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 int dram_init(void)
 {
 	DECLARE_GLOBAL_DATA_PTR;
@@ -157,6 +158,39 @@ int dram_init(void)
 
 	return 0;
 }
+#else
+int dram_init(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+	unsigned int size0 = 0, size1 = 0;
+
+	size0 = get_sdr_cs_size(CS0);
+	/*
+	 * If a second bank of DDR is attached to CS1 this is
+	 * where it can be started.  Early init code will init
+	 * memory on CS0.
+	 */
+	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED))
+		size1 = get_sdr_cs_size(CS1);
+
+	gd->ram_size = size0 + size1;
+	return 0;
+}
+
+void dram_init_banksize (void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+	unsigned int size0 = 0, size1 = 0;
+
+	size0 = get_sdr_cs_size(CS0);
+	size1 = get_sdr_cs_size(CS1);
+
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = size0;
+	gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1);
+	gd->bd->bi_dram[1].size = size1;
+}
+#endif
 
 /*
  * mem_init() -
diff --git a/arch/arm/cpu/armv7/omap3/sdrc.c b/arch/arm/cpu/armv7/omap3/sdrc.c
index 8905224..2719bb5 100644
--- a/arch/arm/cpu/armv7/omap3/sdrc.c
+++ b/arch/arm/cpu/armv7/omap3/sdrc.c
@@ -163,6 +163,7 @@ void do_sdrc_init(u32 cs, u32 early)
  * dram_init -
  *  - Sets uboots idea of sdram size
  */
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 int dram_init(void)
 {
 	DECLARE_GLOBAL_DATA_PTR;
@@ -188,6 +189,43 @@ int dram_init(void)
 
 	return 0;
 }
+#else
+int dram_init(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+	unsigned int size0 = 0, size1 = 0;
+
+	size0 = get_sdr_cs_size(CS0);
+	/*
+	 * If a second bank of DDR is attached to CS1 this is
+	 * where it can be started.  Early init code will init
+	 * memory on CS0.
+	 */
+	if ((sysinfo.mtype == DDR_COMBO) || (sysinfo.mtype == DDR_STACKED)) {
+		do_sdrc_init(CS1, NOT_EARLY);
+		make_cs1_contiguous();
+
+		size1 = get_sdr_cs_size(CS1);
+	}
+	gd->ram_size = size0 + size1;
+
+	return 0;
+}
+
+void dram_init_banksize (void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+	unsigned int size0 = 0, size1 = 0;
+
+	size0 = get_sdr_cs_size(CS0);
+	size1 = get_sdr_cs_size(CS1);
+
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = size0;
+	gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1);
+	gd->bd->bi_dram[1].size = size1;
+}
+#endif
 
 /*
  * mem_init -
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index 1e0a150..f411c0f 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -65,12 +65,15 @@ _end_vect:
  *
  *************************************************************************/
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -95,6 +98,176 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0, cpsr
+	bic	r0, r0, #0x1f
+	orr	r0, r0, #0xd3
+	msr	cpsr,r0
+
+#if (CONFIG_OMAP34XX)
+	/* Copy vectors to mask ROM indirect addr */
+	adr	r0, _start		@ r0 <- current position of code
+	add	r0, r0, #4		@ skip reset vector
+	mov	r2, #64			@ r2 <- size to copy
+	add	r2, r0, r2		@ r2 <- source end address
+	mov	r1, #SRAM_OFFSET0	@ build vect addr
+	mov	r3, #SRAM_OFFSET1
+	add	r1, r1, r3
+	mov	r3, #SRAM_OFFSET2
+	add	r1, r1, r3
+next:
+	ldmia	r0!, {r3 - r10}		@ copy from source address [r0]
+	stmia	r1!, {r3 - r10}		@ copy to   target address [r1]
+	cmp	r0, r2			@ until source end address [r2]
+	bne	next			@ loop until equal */
+#if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_ONENAND_BOOT)
+	/* No need to copy/exec the clock code - DPLL adjust already done
+	 * in NAND/oneNAND Boot.
+	 */
+	bl	cpy_clk_code		@ put dpll adjust code behind vectors
+#endif /* NAND Boot */
+#endif
+	/* the mask ROM code should have PLL and others stable */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+	adr	r0, _start
+	ldr	r2, _TEXT_BASE
+	ldr	r3, _bss_start
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+#ifndef CONFIG_PRELOADER
+	beq	jump_2_ram
+#endif
+
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+
+clear_bss:
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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 */
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+jump_2_ram:
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 /*
  * the actual reset code
  */
@@ -180,7 +353,7 @@ clbss_l:
 	ldr	pc, _start_armboot	@ jump to C code
 
 _start_armboot: .word start_armboot
-
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*************************************************************************
  *
@@ -263,11 +436,14 @@ cpu_init_crit:
 						@ user stack
 	stmia	sp, {r0 - r12}			@ Save user registers (now in
 						@ svc mode) r0-r12
-
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE + 8)	@ set base 2 words into abort
+#else
+	ldr	r2, IRQ_STACK_START_IN		@ set base 2 words into abort
 						@ stack
+#endif
 	ldmia	r2, {r2 - r3}			@ get values for "aborted" pc
 						@ and cpsr (into parm regs)
 	add	r0, sp, #S_FRAME_SIZE		@ grab pointer to old stack
@@ -303,11 +479,14 @@ cpu_init_crit:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack (enter
-						@ in banked mode)
 	sub	r13, r13, #(CONFIG_SYS_MALLOC_LEN)	@ move past malloc pool
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE + 8) @ move to reserved a couple
-						@ spots for abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack (enter
+						@ in banked mode)
+#endif
 
 	str	lr, [r13]			@ save caller lr in position 0
 						@ of saved stack
@@ -328,10 +507,14 @@ cpu_init_crit:
 	sub	r13, r13, #4			@ space on current stack for
 						@ scratch reg.
 	str	r0, [r13]			@ save R0's value.
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r0, _armboot_start		@ get data regions start
 	sub	r0, r0, #(CONFIG_SYS_MALLOC_LEN)	@ move past malloc pool
 	sub	r0, r0, #(CONFIG_SYS_GBL_DATA_SIZE + 8)	@ move past gbl and a couple
+#else
+	ldr	r0, IRQ_STACK_START_IN		@ get data regions start
 						@ spots for abort stack
+#endif
 	str	lr, [r0]			@ save caller lr in position 0
 						@ of saved stack
 	mrs	r0, spsr			@ get the spsr
diff --git a/arch/arm/cpu/armv7/u-boot.lds b/arch/arm/cpu/armv7/u-boot.lds
index 9e5b5a9..d4fd3fc 100644
--- a/arch/arm/cpu/armv7/u-boot.lds
+++ b/arch/arm/cpu/armv7/u-boot.lds
@@ -42,10 +42,22 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
+	__got_end = .;
 
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
diff --git a/board/ti/beagle/config.mk b/board/ti/beagle/config.mk
index 879b2e2..6fb10e3 100644
--- a/board/ti/beagle/config.mk
+++ b/board/ti/beagle/config.mk
@@ -30,4 +30,4 @@
 # (mem base + reserved)
 
 # For use with external or internal boots.
-TEXT_BASE = 0x80e80000
+TEXT_BASE = 0x80008000
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index 3f6e803..2463be4 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -340,4 +340,9 @@ extern unsigned int boot_flash_sec;
 extern unsigned int boot_flash_type;
 #endif
 
+/* additions for new relocation code, must added to all boards */
+#undef CONFIG_SYS_ARM_WITHOUT_RELOC /* This board is tested with relocation support */
+#define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
+#define CONFIG_SYS_INIT_SP_ADDR		(LOW_LEVEL_SRAM_STACK - CONFIG_SYS_GBL_DATA_SIZE)
+
 #endif /* __CONFIG_H */
-- 
1.6.2.5

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

* [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926
  2010-09-17 11:10                             ` [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP) Heiko Schocher
@ 2010-09-17 11:10                               ` Heiko Schocher
  2010-09-17 11:10                                 ` [U-Boot] [PATCH 16/26 v2][NEXT] ARM: implement relocation for ARM920 Heiko Schocher
  2010-09-22  9:32                                 ` [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926 Albert ARIBAUD
  2010-09-17 21:40                               ` [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP) John Rigby
  1 sibling, 2 replies; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for arm926 to relocate the code to
an arbitrary address in RAM.

Adapt the TX25 (i.MX25), magnesium board to test the changes.

On the tx25 board TEXT_BASE is set to the final relocation
address to prevent one more copying of u-boot code
when relocating. More info see:
doc/README.arm-relocation

da850 board:
Tested-by: Ben Gardiner <bengardiner@nanometrics.ca>

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Ben Gardiner <bengardiner@nanometrics.ca>
---
 arch/arm/cpu/arm926ejs/orion5x/dram.c |   24 +++++-
 arch/arm/cpu/arm926ejs/start.S        |  172 ++++++++++++++++++++++++++++++++-
 arch/arm/cpu/arm926ejs/u-boot.lds     |   14 +++-
 board/karo/tx25/config.mk             |    4 +-
 board/karo/tx25/tx25.c                |   11 ++-
 board/keymile/km_arm/km_arm.c         |   24 +++++
 board/logicpd/imx27lite/config.mk     |    2 +-
 board/logicpd/imx27lite/imx27lite.c   |   15 ++-
 doc/README.arm-relocation             |   23 +++++
 include/configs/da850evm.h            |    6 +-
 include/configs/imx27lite-common.h    |    5 +
 include/configs/km_arm.h              |    4 +
 include/configs/tx25.h                |   13 ++-
 nand_spl/board/karo/tx25/u-boot.lds   |   14 +++-
 14 files changed, 310 insertions(+), 21 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/orion5x/dram.c b/arch/arm/cpu/arm926ejs/orion5x/dram.c
index c719798..c5c8ab7 100644
--- a/arch/arm/cpu/arm926ejs/orion5x/dram.c
+++ b/arch/arm/cpu/arm926ejs/orion5x/dram.c
@@ -49,7 +49,7 @@ u32 orion5x_sdram_bar(enum memory_bank bank)
 	result = winregs[bank].base;
 	return result;
 }
-
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 int dram_init(void)
 {
 	int i;
@@ -62,3 +62,25 @@ int dram_init(void)
 	}
 	return 0;
 }
+#else
+int dram_init (void)
+{
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size(
+			(volatile long *) orion5x_sdram_bar(0),
+			CONFIG_MAX_RAM_BANK_SIZE);
+	return 0;
+}
+
+void dram_init_banksize (void)
+{
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+		gd->bd->bi_dram[i].start = orion5x_sdram_bar(i);
+		gd->bd->bi_dram[i].size = get_ram_size(
+			(volatile long *) (gd->bd->bi_dram[i].start),
+			CONFIG_MAX_RAM_BANK_SIZE);
+	}
+}
+#endif
diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S
index cf40ce1..16ee972 100644
--- a/arch/arm/cpu/arm926ejs/start.S
+++ b/arch/arm/cpu/arm926ejs/start.S
@@ -114,12 +114,15 @@ _fiq:
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -144,6 +147,35 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
 
 /*
  * the actual reset code
@@ -166,6 +198,135 @@ reset:
 	bl	cpu_init_crit
 #endif
 
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+	bl coloured_LED_init
+	bl red_LED_on
+#endif
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+#ifdef CONFIG_NAND_SPL
+	ldr     pc, _nand_boot
+
+_nand_boot: .word nand_boot
+#else
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+#endif
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+	/*
+	 * we do sys-critical inits only@reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+#endif
+
 #ifndef CONFIG_SKIP_RELOCATE_UBOOT
 relocate:				/* relocate U-Boot to RAM	    */
 	adr	r0, _start		/* r0 <- current position of code   */
@@ -221,7 +382,7 @@ _start_armboot:
 #else
 	.word start_armboot
 #endif /* CONFIG_NAND_SPL */
-
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  *************************************************************************
@@ -307,10 +468,13 @@ cpu_init_crit:
 	@ carve out a frame on current user stack
 	sub	sp, sp, #S_FRAME_SIZE
 	stmia	sp, {r0 - r12}	@ Save user registers (now in svc mode) r0-r12
-
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	@ get values for "aborted" pc and cpsr (into parm regs)
 	ldmia	r2, {r2 - r3}
 	add	r0, sp, #S_FRAME_SIZE		@ grab pointer to old stack
@@ -342,9 +506,13 @@ cpu_init_crit:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	str	lr, [r13]	@ save caller lr in position 0 of saved stack
 	mrs	lr, spsr	@ get the spsr
diff --git a/arch/arm/cpu/arm926ejs/u-boot.lds b/arch/arm/cpu/arm926ejs/u-boot.lds
index ecbc58c..02eb8ca 100644
--- a/arch/arm/cpu/arm926ejs/u-boot.lds
+++ b/arch/arm/cpu/arm926ejs/u-boot.lds
@@ -39,11 +39,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
diff --git a/board/karo/tx25/config.mk b/board/karo/tx25/config.mk
index 732a14a..51ca1ab 100644
--- a/board/karo/tx25/config.mk
+++ b/board/karo/tx25/config.mk
@@ -1,5 +1,5 @@
 ifdef CONFIG_NAND_SPL
-TEXT_BASE = 0x81ec0000
+TEXT_BASE = 0x810c0000
 else
-TEXT_BASE = 0x81f00000
+TEXT_BASE = 0x81fc0000
 endif
diff --git a/board/karo/tx25/tx25.c b/board/karo/tx25/tx25.c
index 2608698..dc57d5c 100644
--- a/board/karo/tx25/tx25.c
+++ b/board/karo/tx25/tx25.c
@@ -159,7 +159,14 @@ int board_late_init(void)
 
 int dram_init (void)
 {
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size((volatile void *)PHYS_SDRAM_1,
+				PHYS_SDRAM_1_SIZE);
+	return 0;
+}
 
+void dram_init_banksize(void)
+{
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
 	gd->bd->bi_dram[0].size = get_ram_size((volatile void *)PHYS_SDRAM_1,
 			PHYS_SDRAM_1_SIZE);
@@ -167,9 +174,9 @@ int dram_init (void)
 	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
 	gd->bd->bi_dram[1].size = get_ram_size((volatile void *)PHYS_SDRAM_2,
 			PHYS_SDRAM_2_SIZE);
-#endif
+#else
 
-	return 0;
+#endif
 }
 
 int checkboard(void)
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index d7cbd7a..7c0b858 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -225,6 +225,7 @@ U_BOOT_CMD(
 	);
 #endif
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 int dram_init(void)
 {
 	int i;
@@ -234,9 +235,32 @@ int dram_init(void)
 		gd->bd->bi_dram[i].size = get_ram_size((long *)kw_sdram_bar(i),
 						       kw_sdram_bs(i));
 	}
+
+	return 0;
+}
+#else
+int dram_init(void)
+{
+	/* dram_init must store complete ramsize in gd->ram_size */
+	/* Fix this */
+	gd->ram_size = get_ram_size((volatile void *)kw_sdram_bar(0),
+				kw_sdram_bs(0));
 	return 0;
 }
 
+void dram_init_banksize(void)
+{
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+		gd->bd->bi_dram[i].start = kw_sdram_bar(i);
+		gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+		gd->bd->bi_dram[i].size = get_ram_size((long *)kw_sdram_bar(i),
+						       kw_sdram_bs(i));
+	}
+}
+#endif
+
 /* Configure and enable MV88E1118 PHY */
 void reset_phy(void)
 {
diff --git a/board/logicpd/imx27lite/config.mk b/board/logicpd/imx27lite/config.mk
index a2e7768..2f9c4e6 100644
--- a/board/logicpd/imx27lite/config.mk
+++ b/board/logicpd/imx27lite/config.mk
@@ -1 +1 @@
-TEXT_BASE = 0xA7F00000
+TEXT_BASE = 0xc0000000
diff --git a/board/logicpd/imx27lite/imx27lite.c b/board/logicpd/imx27lite/imx27lite.c
index 4427415..6eb5cc2 100644
--- a/board/logicpd/imx27lite/imx27lite.c
+++ b/board/logicpd/imx27lite/imx27lite.c
@@ -66,19 +66,22 @@ int board_init (void)
 
 int dram_init (void)
 {
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size((volatile void *)CONFIG_SYS_SDRAM_BASE,
+				PHYS_SDRAM_1_SIZE);
+	return 0;
+}
 
-#if CONFIG_NR_DRAM_BANKS > 0
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = get_ram_size((volatile void *)PHYS_SDRAM_1,
+void dram_init_banksize(void)
+{
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+	gd->bd->bi_dram[0].size = get_ram_size((volatile void *)CONFIG_SYS_SDRAM_BASE,
 			PHYS_SDRAM_1_SIZE);
-#endif
 #if CONFIG_NR_DRAM_BANKS > 1
 	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
 	gd->bd->bi_dram[1].size = get_ram_size((volatile void *)PHYS_SDRAM_2,
 			PHYS_SDRAM_2_SIZE);
 #endif
-
-	return 0;
 }
 
 int checkboard(void)
diff --git a/doc/README.arm-relocation b/doc/README.arm-relocation
index 6be1a12..e3ed60e 100644
--- a/doc/README.arm-relocation
+++ b/doc/README.arm-relocation
@@ -43,6 +43,29 @@ CONFIG_SYS_ARM_WITHOUT_RELOC defined!!!
 
 -------------------------------------------------------------------------------------
 
+For boards which boot from nand_spl, it is possible to save a copy
+if TEXT_BASE == relocation address! This prevents that uboot code
+is copied again in relocate_code().
+
+example for the tx25 board:
+
+a) cpu starts
+b) it copies the first page in nand to internal ram
+   (nand_spl_code)
+c) end executes this code
+d) this initialize CPU, RAM, ... and copy itself to RAM
+   (this bin must fit in one page, so board_init_f()
+    don;t fit in it ... )
+e) there it copy u-boot to CONFIG_SYS_NAND_U_BOOT_DST and
+   starts this image @ CONFIG_SYS_NAND_U_BOOT_START
+f) u-boot code steps through board_init_f() and calculates
+   the relocation address and copy itself to it
+
+If TEXT_BASE == relocation address, the copying of u-boot
+in f) could be saved.
+
+-------------------------------------------------------------------------------------
+
 ToDo:
 
 - fill in bd_t infos (check)
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h
index 357715d..016a21e 100644
--- a/include/configs/da850evm.h
+++ b/include/configs/da850evm.h
@@ -39,7 +39,6 @@
 #define CONFIG_SYS_HZ_CLOCK		clk_get(DAVINCI_AUXCLK_CLKID)
 #define CONFIG_SYS_HZ			1000
 #define CONFIG_SKIP_LOWLEVEL_INIT
-#define CONFIG_SKIP_RELOCATE_UBOOT	/* to a proper address, init done */
 
 /*
  * Memory Info
@@ -137,4 +136,9 @@
 #undef CONFIG_CMD_ENV
 #endif
 
+/* additions for new relocation code, must added to all boards */
+#undef CONFIG_SYS_ARM_WITHOUT_RELOC /* This board is tested with relocation support */
+#define CONFIG_SYS_SDRAM_BASE		0xc0000000
+#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x1000 - /* Fix this */ \
+					CONFIG_SYS_GBL_DATA_SIZE)
 #endif /* __CONFIG_H */
diff --git a/include/configs/imx27lite-common.h b/include/configs/imx27lite-common.h
index 33550ba..812e5f2 100644
--- a/include/configs/imx27lite-common.h
+++ b/include/configs/imx27lite-common.h
@@ -235,4 +235,9 @@
 	"mtdids=" MTDIDS_DEFAULT "\0"					\
 	"mtdparts=" MTDPARTS_DEFAULT "\0"				\
 
+/* additions for new relocation code, must added to all boards */
+#undef CONFIG_SYS_ARM_WITHOUT_RELOC /* This board is tested with relocation support */
+#define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
+#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x1000 - /* Fix this */ \
+					CONFIG_SYS_GBL_DATA_SIZE)
 #endif /* __IMX27LITE_COMMON_CONFIG_H */
diff --git a/include/configs/km_arm.h b/include/configs/km_arm.h
index 1617e69..8673e6f 100644
--- a/include/configs/km_arm.h
+++ b/include/configs/km_arm.h
@@ -180,4 +180,8 @@ int get_scl (void);
 #undef	CONFIG_JFFS2_CMDLINE
 #endif
 
+/* additions for new relocation code, must added to all boards */
+#define CONFIG_SYS_SDRAM_BASE		0x00000000
+#define CONFIG_SYS_INIT_SP_ADDR		(0x00000000 + 0x1000 - /* Fix this */ \
+					CONFIG_SYS_GBL_DATA_SIZE)
 #endif /* _CONFIG_KM_ARM_H */
diff --git a/include/configs/tx25.h b/include/configs/tx25.h
index 013aa35..c798570 100644
--- a/include/configs/tx25.h
+++ b/include/configs/tx25.h
@@ -40,9 +40,9 @@
 /* Start copying real U-boot from the second page */
 #define CONFIG_SYS_NAND_U_BOOT_OFFS	0x800
 #define CONFIG_SYS_NAND_U_BOOT_SIZE	0x30000
-/* Load U-Boot to this address */
-#define CONFIG_SYS_NAND_U_BOOT_DST	0x81f00000
-#define CONFIG_SYS_NAND_U_BOOT_START	CONFIG_SYS_NAND_U_BOOT_DST
+
+#define CONFIG_SYS_NAND_U_BOOT_DST      (0x81fc0000)
+#define CONFIG_SYS_NAND_U_BOOT_START    CONFIG_SYS_NAND_U_BOOT_DST
 
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_SPARE_SIZE	64
@@ -52,7 +52,6 @@
 #define CONFIG_SYS_NAND_BAD_BLOCK_POS	0
 #else
 #define CONFIG_SKIP_LOWLEVEL_INIT
-#define CONFIG_SKIP_RELOCATE_UBOOT
 #endif
 
 #define CONFIG_DISPLAY_CPUINFO
@@ -177,4 +176,10 @@
 	"update=nand erase 0 40000;nand write ${loadaddr} 0 40000\0"	\
 	"upd=run load update\0"						\
 
+/* additions for new relocation code, must added to all boards */
+#undef CONFIG_SYS_ARM_WITHOUT_RELOC /* This board is tested with relocation support */
+#define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
+#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x1000 - /* Fix this */ \
+					CONFIG_SYS_GBL_DATA_SIZE)
+
 #endif /* __CONFIG_H */
diff --git a/nand_spl/board/karo/tx25/u-boot.lds b/nand_spl/board/karo/tx25/u-boot.lds
index 423bed3..c572557 100644
--- a/nand_spl/board/karo/tx25/u-boot.lds
+++ b/nand_spl/board/karo/tx25/u-boot.lds
@@ -41,11 +41,23 @@ SECTIONS
 	.rodata : { *(.rodata) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 16/26 v2][NEXT] ARM: implement relocation for ARM920
  2010-09-17 11:10                               ` [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926 Heiko Schocher
@ 2010-09-17 11:10                                 ` Heiko Schocher
  2010-09-17 11:10                                   ` [U-Boot] [PATCH 17/26 v2][NEXT] ARM: implement relocation for ARM925 Heiko Schocher
  2010-09-22  9:32                                 ` [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926 Albert ARIBAUD
  1 sibling, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for arm920 to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/arm920t/start.S    |  225 ++++++++++++++++++++++++++++++++++++++-
 arch/arm/cpu/arm920t/u-boot.lds |   14 +++-
 2 files changed, 237 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/arm920t/start.S b/arch/arm/cpu/arm920t/start.S
index e532f55..a079bb2 100644
--- a/arch/arm/cpu/arm920t/start.S
+++ b/arch/arm/cpu/arm920t/start.S
@@ -70,12 +70,15 @@ _fiq:			.word fiq
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -100,6 +103,35 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
 
 /*
  * the actual start code
@@ -176,6 +208,189 @@ copyex:
 	bl	cpu_init_crit
 #endif
 
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+	bl coloured_LED_init
+	bl red_LED_on
+#endif
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+#ifdef CONFIG_NAND_SPL
+	ldr     pc, _nand_boot
+
+_nand_boot: .word nand_boot
+#else
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+#endif
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
+/*
+ * the actual start code
+ */
+
+start_code:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0, cpsr
+	bic	r0, r0, #0x1f
+	orr	r0, r0, #0xd3
+	msr	cpsr, r0
+
+	bl	coloured_LED_init
+	bl	red_LED_on
+
+#if	defined(CONFIG_AT91RM9200DK) || defined(CONFIG_AT91RM9200EK)
+	/*
+	 * relocate exception table
+	 */
+	ldr	r0, =_start
+	ldr	r1, =0x0
+	mov	r2, #16
+copyex:
+	subs	r2, r2, #1
+	ldr	r3, [r0], #4
+	str	r3, [r1], #4
+	bne	copyex
+#endif
+
+#ifdef CONFIG_S3C24X0
+	/* turn off the watchdog */
+
+# if defined(CONFIG_S3C2400)
+#  define pWTCON	0x15300000
+#  define INTMSK	0x14400008	/* Interupt-Controller base addresses */
+#  define CLKDIVN	0x14800014	/* clock divisor register */
+#else
+#  define pWTCON	0x53000000
+#  define INTMSK	0x4A000008	/* Interupt-Controller base addresses */
+#  define INTSUBMSK	0x4A00001C
+#  define CLKDIVN	0x4C000014	/* clock divisor register */
+# endif
+
+	ldr	r0, =pWTCON
+	mov	r1, #0x0
+	str	r1, [r0]
+
+	/*
+	 * mask all IRQs by setting all bits in the INTMR - default
+	 */
+	mov	r1, #0xffffffff
+	ldr	r0, =INTMSK
+	str	r1, [r0]
+# if defined(CONFIG_S3C2410)
+	ldr	r1, =0x3ff
+	ldr	r0, =INTSUBMSK
+	str	r1, [r0]
+# endif
+
+	/* FCLK:HCLK:PCLK = 1:2:4 */
+	/* default FCLK is 120 MHz ! */
+	ldr	r0, =CLKDIVN
+	mov	r1, #3
+	str	r1, [r0]
+#endif	/* CONFIG_S3C24X0 */
+
+	/*
+	 * we do sys-critical inits only@reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+#endif
+
 #ifndef CONFIG_SKIP_RELOCATE_UBOOT
 relocate:				/* relocate U-Boot to RAM	    */
 	adr	r0, _start		/* r0 <- current position of code   */
@@ -219,7 +434,7 @@ clbss_l:str	r2, [r0]		/* clear loop...                    */
 	ldr	pc, _start_armboot
 
 _start_armboot:	.word start_armboot
-
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  *************************************************************************
@@ -309,11 +524,15 @@ cpu_init_crit:
 	.macro	bad_save_user_regs
 	sub	sp, sp, #S_FRAME_SIZE
 	stmia	sp, {r0 - r12}			@ Calling r0-r12
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE)
 	sub	r2, r2, #(CONFIG_SYS_MALLOC_LEN)
 	/* set base 2 words into abort stack */
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	ldmia	r2, {r2 - r3}			@ get pc, cpsr
 	add	r0, sp, #S_FRAME_SIZE		@ restore sp_SVC
 
@@ -345,11 +564,15 @@ cpu_init_crit:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE)
 	sub	r13, r13, #(CONFIG_SYS_MALLOC_LEN)
 	/* reserve a couple spots in abort stack */
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8)
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	str	lr, [r13]			@ save caller lr / spsr
 	mrs	lr, spsr
diff --git a/arch/arm/cpu/arm920t/u-boot.lds b/arch/arm/cpu/arm920t/u-boot.lds
index a7decfc..6985434 100644
--- a/arch/arm/cpu/arm920t/u-boot.lds
+++ b/arch/arm/cpu/arm920t/u-boot.lds
@@ -47,11 +47,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 17/26 v2][NEXT] ARM: implement relocation for ARM925
  2010-09-17 11:10                                 ` [U-Boot] [PATCH 16/26 v2][NEXT] ARM: implement relocation for ARM920 Heiko Schocher
@ 2010-09-17 11:10                                   ` Heiko Schocher
  2010-09-17 11:10                                     ` [U-Boot] [PATCH 18/26 v2][NEXT] ARM: implement relocation for ARM946 Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for arm925 to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/arm925t/start.S    |  204 ++++++++++++++++++++++++++++++++++++++-
 arch/arm/cpu/arm925t/u-boot.lds |   14 +++-
 2 files changed, 216 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/arm925t/start.S b/arch/arm/cpu/arm925t/start.S
index 346615e..c0a856d 100644
--- a/arch/arm/cpu/arm925t/start.S
+++ b/arch/arm/cpu/arm925t/start.S
@@ -81,12 +81,15 @@ _fiq:			.word fiq
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -111,7 +114,198 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+	/*
+	 * Set up 925T mode
+	 */
+	mov r1, #0x81               /* Set ARM925T configuration. */
+	mcr p15, 0, r1, c15, c1, 0  /* Write ARM925T configuration register. */
+
+	/*
+	 * turn off the watchdog, unlock/diable sequence
+	 */
+	mov  r1, #0xF5
+	ldr  r0, =WDTIM_MODE
+	strh r1, [r0]
+	mov  r1, #0xA0
+	strh r1, [r0]
+
+	/*
+	 * mask all IRQs by setting all bits in the INTMR - default
+	 */
+	mov r1, #0xffffffff
+	ldr r0, =REG_IHL1_MIR
+	str r1, [r0]
+	ldr r0, =REG_IHL2_MIR
+	str r1, [r0]
+
+	/*
+	 * wait for dpll to lock
+	 */
+	ldr  r0, =CK_DPLL1
+	mov  r1, #0x10
+	strh r1, [r0]
+poll1:
+	ldrh r1, [r0]
+	ands r1, r1, #0x01
+	beq poll1
+
+	/*
+	 * we do sys-critical inits only at reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl  cpu_init_crit
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+#ifdef CONFIG_NAND_SPL
+	ldr     pc, _nand_boot
+
+_nand_boot: .word nand_boot
+#else
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+#endif
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 /*
  * the actual reset code
  */
@@ -211,7 +405,7 @@ clbss_l:str	r2, [r0]		/* clear loop...                    */
 	ldr	pc, _start_armboot
 
 _start_armboot:	.word start_armboot
-
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  *************************************************************************
@@ -295,9 +489,13 @@ cpu_init_crit:
 	sub	sp, sp, #S_FRAME_SIZE           @ carve out a frame on current user stack
 	stmia	sp, {r0 - r12}			@ Save user registers (now in svc mode) r0-r12
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	ldmia	r2, {r2 - r3}                   @ get values for "aborted" pc and cpsr (into parm regs)
 	add	r0, sp, #S_FRAME_SIZE		@ grab pointer to old stack
 
@@ -328,9 +526,13 @@ cpu_init_crit:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN
+#endif
 
 	str	lr, [r13]			@ save caller lr in position 0 of saved stack
 	mrs	lr, spsr                        @ get the spsr
diff --git a/arch/arm/cpu/arm925t/u-boot.lds b/arch/arm/cpu/arm925t/u-boot.lds
index e21d6dc..1c4e9bc 100644
--- a/arch/arm/cpu/arm925t/u-boot.lds
+++ b/arch/arm/cpu/arm925t/u-boot.lds
@@ -42,11 +42,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 18/26 v2][NEXT] ARM: implement relocation for ARM946
  2010-09-17 11:10                                   ` [U-Boot] [PATCH 17/26 v2][NEXT] ARM: implement relocation for ARM925 Heiko Schocher
@ 2010-09-17 11:10                                     ` Heiko Schocher
  2010-09-17 11:10                                       ` [U-Boot] [PATCH 19/26 v2][NEXT] ARM: implement relocation for pxa Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for arm946 to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/arm946es/start.S    |  168 +++++++++++++++++++++++++++++++++++++-
 arch/arm/cpu/arm946es/u-boot.lds |   14 +++-
 2 files changed, 180 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/arm946es/start.S b/arch/arm/cpu/arm946es/start.S
index 8844d44..18ed0b2 100644
--- a/arch/arm/cpu/arm946es/start.S
+++ b/arch/arm/cpu/arm946es/start.S
@@ -85,12 +85,15 @@ _fiq:
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -115,7 +118,162 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+	/*
+	 * we do sys-critical inits only at reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+#ifdef CONFIG_NAND_SPL
+	ldr     pc, _nand_boot
 
+_nand_boot: .word nand_boot
+#else
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+#endif
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 /*
  * the actual reset code
  */
@@ -179,7 +337,7 @@ clbss_l:str	r2, [r0]		/* clear loop...                    */
 
 _start_armboot:
 	.word start_armboot
-
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  *************************************************************************
@@ -266,9 +424,13 @@ cpu_init_crit:
 	sub	sp, sp, #S_FRAME_SIZE
 	stmia	sp, {r0 - r12}	@ Save user registers (now in svc mode) r0-r12
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	@ get values for "aborted" pc and cpsr (into parm regs)
 	ldmia	r2, {r2 - r3}
 	add	r0, sp, #S_FRAME_SIZE		@ grab pointer to old stack
@@ -300,9 +462,13 @@ cpu_init_crit:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	str	lr, [r13]	@ save caller lr in position 0 of saved stack
 	mrs	lr, spsr	@ get the spsr
diff --git a/arch/arm/cpu/arm946es/u-boot.lds b/arch/arm/cpu/arm946es/u-boot.lds
index fef21c7..6535963 100644
--- a/arch/arm/cpu/arm946es/u-boot.lds
+++ b/arch/arm/cpu/arm946es/u-boot.lds
@@ -39,11 +39,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 19/26 v2][NEXT] ARM: implement relocation for pxa
  2010-09-17 11:10                                     ` [U-Boot] [PATCH 18/26 v2][NEXT] ARM: implement relocation for ARM946 Heiko Schocher
@ 2010-09-17 11:10                                       ` Heiko Schocher
  2010-09-17 11:10                                         ` [U-Boot] [PATCH 20/26 v2][NEXT] ARM: implement relocation for ixp Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for pxa to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/pxa/start.S    |  168 +++++++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/pxa/u-boot.lds |   14 ++++-
 2 files changed, 181 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S
index 8010b0e..064ddbc 100644
--- a/arch/arm/cpu/pxa/start.S
+++ b/arch/arm/cpu/pxa/start.S
@@ -82,12 +82,15 @@ _fiq:			.word fiq
  * - jump to second stage
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -112,6 +115,162 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif /* CONFIG_USE_IRQ */
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+	/*
+	 * we do sys-critical inits only at reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+#ifdef CONFIG_ONENAND_IPL
+	ldr     pc, _start_oneboot
+
+_start_oneboot: .word start_oneboot
+#else
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+#endif
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /****************************************************************************/
 /*									    */
@@ -188,6 +347,7 @@ _start_armboot: .word start_oneboot
 #else
 _start_armboot: .word start_armboot
 #endif
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /****************************************************************************/
 /*									    */
@@ -367,9 +527,13 @@ setspeed_done:
 	stmia	sp, {r0 - r12}			/* Calling r0-r12	    */
 	add	r8, sp, #S_PC
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)	@ set base 2 words into abort stack
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	ldmia	r2, {r2 - r4}			/* get pc, cpsr, old_r0	    */
 	add	r0, sp, #S_FRAME_SIZE		/* restore sp_SVC	    */
 
@@ -404,9 +568,13 @@ setspeed_done:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	str	lr, [r13]			@ save caller lr / spsr
 	mrs	lr, spsr
diff --git a/arch/arm/cpu/pxa/u-boot.lds b/arch/arm/cpu/pxa/u-boot.lds
index d4e85ef..74a4c6e 100644
--- a/arch/arm/cpu/pxa/u-boot.lds
+++ b/arch/arm/cpu/pxa/u-boot.lds
@@ -39,11 +39,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 20/26 v2][NEXT] ARM: implement relocation for ixp
  2010-09-17 11:10                                       ` [U-Boot] [PATCH 19/26 v2][NEXT] ARM: implement relocation for pxa Heiko Schocher
@ 2010-09-17 11:10                                         ` Heiko Schocher
  2010-09-17 11:10                                           ` [U-Boot] [PATCH 21/26 v2][NEXT] ARM: implement relocation for sa1100 Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for ixp to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/ixp/start.S    |  280 +++++++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/ixp/u-boot.lds |   14 ++-
 2 files changed, 293 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/ixp/start.S b/arch/arm/cpu/ixp/start.S
index 6efe333..b2c8255 100644
--- a/arch/arm/cpu/ixp/start.S
+++ b/arch/arm/cpu/ixp/start.S
@@ -93,12 +93,15 @@ _fiq:			.word fiq
  * - jump to second stage
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -123,6 +126,274 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/* disable mmu, set big-endian */
+	mov	r0, #0xf8
+	mcr	p15, 0, r0, c1, c0, 0
+	CPWAIT  r0
+
+	/* invalidate I & D caches & BTB */
+	mcr	p15, 0, r0, c7, c7, 0
+	CPWAIT	r0
+
+	/* invalidate I & Data TLB */
+	mcr	p15, 0, r0, c8, c7, 0
+	CPWAIT r0
+
+	/* drain write and fill buffers */
+	mcr	p15, 0, r0, c7, c10, 4
+	CPWAIT	r0
+
+	/* disable write buffer coalescing */
+	mrc	p15, 0, r0, c1, c0, 1
+	orr	r0, r0, #1
+	mcr	p15, 0, r0, c1, c0, 1
+	CPWAIT	r0
+
+	/* set EXP CS0 to the optimum timing */
+	ldr	r1, =CONFIG_SYS_EXP_CS0
+	ldr     r2, =IXP425_EXP_CS0
+	str     r1, [r2]
+
+	/* make sure flash is visible at 0 */
+#if 0
+	ldr	r2, =IXP425_EXP_CFG0
+	ldr     r1, [r2]
+	orr     r1, r1, #0x80000000
+	str     r1, [r2]
+#endif
+	mov	r1, #CONFIG_SYS_SDR_CONFIG
+	ldr     r2, =IXP425_SDR_CONFIG
+	str     r1, [r2]
+
+	/* disable refresh cycles */
+	mov	r1, #0
+	ldr     r3, =IXP425_SDR_REFRESH
+	str	r1, [r3]
+
+	/* send nop command */
+	mov	r1, #3
+	ldr	r4, =IXP425_SDR_IR
+	str	r1, [r4]
+	DELAY_FOR 0x4000, r0
+
+	/* set SDRAM internal refresh val */
+	ldr	r1, =CONFIG_SYS_SDRAM_REFRESH_CNT
+	str     r1, [r3]
+	DELAY_FOR 0x4000, r0
+
+	/* send precharge-all command to close all open banks */
+	mov     r1, #2
+	str     r1, [r4]
+	DELAY_FOR 0x4000, r0
+
+	/* provide 8 auto-refresh cycles */
+	mov     r1, #4
+	mov     r5, #8
+111:    str	r1, [r4]
+	DELAY_FOR 0x100, r0
+	subs	r5, r5, #1
+	bne	111b
+
+	/* set mode register in sdram */
+	mov	r1, #CONFIG_SYS_SDR_MODE_CONFIG
+	str	r1, [r4]
+	DELAY_FOR 0x4000, r0
+
+	/* send normal operation command */
+	mov	r1, #6
+	str	r1, [r4]
+	DELAY_FOR 0x4000, r0
+
+	/* copy */
+	mov     r0, #0
+	mov     r4, r0
+	add     r2, r0, #CONFIG_SYS_MONITOR_LEN
+	mov     r1, #0x10000000
+	mov     r5, r1
+
+    30:
+	ldr     r3, [r0], #4
+	str     r3, [r1], #4
+	cmp     r0, r2
+	bne     30b
+
+	/* invalidate I & D caches & BTB */
+	mcr	p15, 0, r0, c7, c7, 0
+	CPWAIT	r0
+
+	/* invalidate I & Data TLB */
+	mcr	p15, 0, r0, c8, c7, 0
+	CPWAIT r0
+
+	/* drain write and fill buffers */
+	mcr	p15, 0, r0, c7, c10, 4
+	CPWAIT	r0
+
+	/* move flash to 0x50000000 */
+	ldr	r2, =IXP425_EXP_CFG0
+	ldr     r1, [r2]
+	bic     r1, r1, #0x80000000
+	str     r1, [r2]
+
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+
+	/* invalidate I & Data TLB */
+	mcr	p15, 0, r0, c8, c7, 0
+	CPWAIT r0
+
+	/* enable I cache */
+	mrc     p15, 0, r0, c1, c0, 0
+	orr     r0, r0, #MMU_Control_I
+	mcr     p15, 0, r0, c1, c0, 0
+	CPWAIT  r0
+
+	mrs	r0,cpsr			/* set the cpu to SVC32 mode	    */
+	bic	r0,r0,#0x1f		/* (superviser mode, M=10011)	    */
+	orr	r0,r0,#0x13
+	msr	cpsr,r0
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+	bl coloured_LED_init
+	bl red_LED_on
+#endif
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 /****************************************************************************/
 /*									    */
 /* the actual reset code						    */
@@ -304,6 +575,7 @@ clbss_l:str	r2, [r0]		/* clear loop...                    */
 	ldr	pc, _start_armboot
 
 _start_armboot: .word start_armboot
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 
 /****************************************************************************/
@@ -345,9 +617,13 @@ _start_armboot: .word start_armboot
 	stmia	sp, {r0 - r12}			/* Calling r0-r12	    */
 	add	r8, sp, #S_PC
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	ldmia	r2, {r2 - r4}			/* get pc, cpsr, old_r0	    */
 	add	r0, sp, #S_FRAME_SIZE		/* restore sp_SVC	    */
 
@@ -382,9 +658,13 @@ _start_armboot: .word start_armboot
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	str	lr, [r13]			@ save caller lr / spsr
 	mrs	lr, spsr
diff --git a/arch/arm/cpu/ixp/u-boot.lds b/arch/arm/cpu/ixp/u-boot.lds
index b8ff2ee..f3d9dc5 100644
--- a/arch/arm/cpu/ixp/u-boot.lds
+++ b/arch/arm/cpu/ixp/u-boot.lds
@@ -39,11 +39,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 21/26 v2][NEXT] ARM: implement relocation for sa1100
  2010-09-17 11:10                                         ` [U-Boot] [PATCH 20/26 v2][NEXT] ARM: implement relocation for ixp Heiko Schocher
@ 2010-09-17 11:10                                           ` Heiko Schocher
  2010-09-17 11:10                                             ` [U-Boot] [PATCH 22/26 v2][NEXT] ARM: implement relocation for s3c44b0 Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for sa1100 to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/sa1100/start.S    |  162 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/sa1100/u-boot.lds |   14 +++-
 2 files changed, 175 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/sa1100/start.S b/arch/arm/cpu/sa1100/start.S
index deb4745..4730e5a 100644
--- a/arch/arm/cpu/sa1100/start.S
+++ b/arch/arm/cpu/sa1100/start.S
@@ -73,12 +73,15 @@ _fiq:			.word fiq
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -103,6 +106,156 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+	/*
+	 * we do sys-critical inits only at reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  * the actual reset code
@@ -169,6 +322,7 @@ clbss_l:str	r2, [r0]		/* clear loop...                    */
 
 _start_armboot:	.word start_armboot
 
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  *************************************************************************
@@ -288,9 +442,13 @@ cpu_init_crit:
 	stmia	sp, {r0 - r12}			@ Calling r0-r12
 	add     r8, sp, #S_PC
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	ldmia	r2, {r2 - r4}                   @ get pc, cpsr, old_r0
 	add	r0, sp, #S_FRAME_SIZE		@ restore sp_SVC
 
@@ -321,9 +479,13 @@ cpu_init_crit:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	str	lr, [r13]			@ save caller lr / spsr
 	mrs	lr, spsr
diff --git a/arch/arm/cpu/sa1100/u-boot.lds b/arch/arm/cpu/sa1100/u-boot.lds
index f6197ac..2e29291 100644
--- a/arch/arm/cpu/sa1100/u-boot.lds
+++ b/arch/arm/cpu/sa1100/u-boot.lds
@@ -42,11 +42,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 22/26 v2][NEXT] ARM: implement relocation for s3c44b0
  2010-09-17 11:10                                           ` [U-Boot] [PATCH 21/26 v2][NEXT] ARM: implement relocation for sa1100 Heiko Schocher
@ 2010-09-17 11:10                                             ` Heiko Schocher
  2010-09-17 11:10                                               ` [U-Boot] [PATCH 23/26 v2][NEXT] ARM: implement relocation for lh7a40x Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for s3c44b0 to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/s3c44b0/start.S    |  174 +++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/s3c44b0/u-boot.lds |   14 +++-
 2 files changed, 187 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/s3c44b0/start.S b/arch/arm/cpu/s3c44b0/start.S
index 0063063..e1ab5cc 100644
--- a/arch/arm/cpu/s3c44b0/start.S
+++ b/arch/arm/cpu/s3c44b0/start.S
@@ -63,12 +63,15 @@ _start:	b       reset
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -93,7 +96,177 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+	/*
+	 * we do sys-critical inits only at reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+	/*
+	 * before relocating, we have to setup RAM timing
+	 * because memory timing is board-dependend, you will
+	 * find a lowlevel_init.S in your board directory.
+	 */
+	bl	lowlevel_init
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+/*
+	now copy to sram the interrupt vector
+*/
+	adr	r0, real_vectors
+	add	r2, r0, #1024
+	ldr	r1, =0x0c000000
+	add	r1, r1, #0x08
+vector_copy_loop:
+	ldmia	r0!, {r3-r10}
+	stmia	r1!, {r3-r10}
+	cmp	r0, r2
+	ble	vector_copy_loop
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+	bl coloured_LED_init
+	bl red_LED_on
+#endif
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
 
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 /*
  * the actual reset code
  */
@@ -169,6 +342,7 @@ stack_setup:
 
 _start_armboot:	.word start_armboot
 
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  *************************************************************************
diff --git a/arch/arm/cpu/s3c44b0/u-boot.lds b/arch/arm/cpu/s3c44b0/u-boot.lds
index 267d94c..bbc8c3a 100644
--- a/arch/arm/cpu/s3c44b0/u-boot.lds
+++ b/arch/arm/cpu/s3c44b0/u-boot.lds
@@ -39,11 +39,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 23/26 v2][NEXT] ARM: implement relocation for lh7a40x
  2010-09-17 11:10                                             ` [U-Boot] [PATCH 22/26 v2][NEXT] ARM: implement relocation for s3c44b0 Heiko Schocher
@ 2010-09-17 11:10                                               ` Heiko Schocher
  2010-09-17 11:10                                                 ` [U-Boot] [PATCH 24/26 v2][NEXT] ARM: implement relocation for arm_intcm Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for lh7a40x to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/lh7a40x/start.S    |  187 ++++++++++++++++++++++++++++++++++++++-
 arch/arm/cpu/lh7a40x/u-boot.lds |   14 +++-
 2 files changed, 199 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/lh7a40x/start.S b/arch/arm/cpu/lh7a40x/start.S
index 14a1fbe..002116a 100644
--- a/arch/arm/cpu/lh7a40x/start.S
+++ b/arch/arm/cpu/lh7a40x/start.S
@@ -72,12 +72,15 @@ _fiq:			.word fiq
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -102,8 +105,182 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+#define pWDTCTL		0x80001400  /* Watchdog Timer control register */
+#define pINTENC		0x8000050C  /* Interupt-Controller enable clear register */
+#define pCLKSET		0x80000420  /* clock divisor register */
+
+	/* disable watchdog, set watchdog control register to
+	 * all zeros (default reset)
+	 */
+	ldr     r0, =pWDTCTL
+	mov     r1, #0x0
+	str     r1, [r0]
+
+	/*
+	 * mask all IRQs by setting all bits in the INTENC register (default)
+	 */
+	mov	r1, #0xffffffff
+	ldr	r0, =pINTENC
+	str	r1, [r0]
+
+	/* FCLK:HCLK:PCLK = 1:2:2 */
+	/* default FCLK is 200 MHz, using 14.7456 MHz fin */
+	ldr	r0, =pCLKSET
+	ldr r1, =0x0004ee39
+@	ldr r1, =0x0005ee39	@ 1: 2: 4
+	str	r1, [r0]
+
+	/*
+	 * we do sys-critical inits only at reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
 
 /*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
+/*
  * the actual reset code
  */
 
@@ -195,7 +372,7 @@ clbss_l:str	r2, [r0]		/* clear loop...                    */
 	ldr	pc, _start_armboot
 
 _start_armboot:	.word start_armboot
-
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  *************************************************************************
@@ -285,9 +462,13 @@ cpu_init_crit:
 	.macro	bad_save_user_regs
 	sub	sp, sp, #S_FRAME_SIZE
 	stmia	sp, {r0 - r12}			@ Calling r0-r12
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	ldmia	r2, {r2 - r3}			@ get pc, cpsr
 	add	r0, sp, #S_FRAME_SIZE		@ restore sp_SVC
 
@@ -318,9 +499,13 @@ cpu_init_crit:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	str	lr, [r13]			@ save caller lr / spsr
 	mrs	lr, spsr
diff --git a/arch/arm/cpu/lh7a40x/u-boot.lds b/arch/arm/cpu/lh7a40x/u-boot.lds
index 5a8ccf5..cb55b0a 100644
--- a/arch/arm/cpu/lh7a40x/u-boot.lds
+++ b/arch/arm/cpu/lh7a40x/u-boot.lds
@@ -39,11 +39,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 24/26 v2][NEXT] ARM: implement relocation for arm_intcm
  2010-09-17 11:10                                               ` [U-Boot] [PATCH 23/26 v2][NEXT] ARM: implement relocation for lh7a40x Heiko Schocher
@ 2010-09-17 11:10                                                 ` Heiko Schocher
  2010-09-17 11:10                                                   ` [U-Boot] [PATCH 25/26 v2][NEXT] ARM: implement relocation for arm720t Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for arm_intcm to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/arm_intcm/start.S    |  166 +++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/arm_intcm/u-boot.lds |   14 +++-
 2 files changed, 179 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/arm_intcm/start.S b/arch/arm/cpu/arm_intcm/start.S
index 328bae0..b39fdc6 100644
--- a/arch/arm/cpu/arm_intcm/start.S
+++ b/arch/arm/cpu/arm_intcm/start.S
@@ -83,12 +83,15 @@ _fiq:
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE /* address of _start in the linked image */
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -113,6 +116,159 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+	/*
+	 * we do sys-critical inits only at reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+	bl coloured_LED_init
+	bl red_LED_on
+#endif
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  * the actual reset code
@@ -178,6 +334,8 @@ clbss_l:str	r2, [r0]		/* clear loop...                    */
 _start_armboot:
 	.word start_armboot
 
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
+
 /*
  *************************************************************************
  *
@@ -242,9 +400,13 @@ cpu_init_crit:
 	sub	sp, sp, #S_FRAME_SIZE
 	stmia	sp, {r0 - r12}	@ Save user registers (now in svc mode) r0-r12
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)  @ set base 2 words into abort stack
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	@ get values for "aborted" pc and cpsr (into parm regs)
 	ldmia	r2, {r2 - r3}
 	add	r0, sp, #S_FRAME_SIZE		@ grab pointer to old stack
@@ -276,9 +438,13 @@ cpu_init_crit:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	str	lr, [r13]	@ save caller lr in position 0 of saved stack
 	mrs	lr, spsr	@ get the spsr
diff --git a/arch/arm/cpu/arm_intcm/u-boot.lds b/arch/arm/cpu/arm_intcm/u-boot.lds
index 4ed7d89..242c7ec 100644
--- a/arch/arm/cpu/arm_intcm/u-boot.lds
+++ b/arch/arm/cpu/arm_intcm/u-boot.lds
@@ -39,11 +39,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 25/26 v2][NEXT] ARM: implement relocation for arm720t
  2010-09-17 11:10                                                 ` [U-Boot] [PATCH 24/26 v2][NEXT] ARM: implement relocation for arm_intcm Heiko Schocher
@ 2010-09-17 11:10                                                   ` Heiko Schocher
  2010-09-17 11:10                                                     ` [U-Boot] [PATCH 26/26 v2][NEXT] ARM: implement relocation for arm1176 Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for arm720t to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/arm720t/start.S    |  170 +++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/arm720t/u-boot.lds |   14 +++-
 2 files changed, 183 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S
index d6f2c16..0f5f6c4 100644
--- a/arch/arm/cpu/arm720t/start.S
+++ b/arch/arm/cpu/arm720t/start.S
@@ -75,12 +75,15 @@ _fiq:			.word fiq
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -105,6 +108,163 @@ FIQ_STACK_START:
 	.word 0x0badc0de
 #endif
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+	/*
+	 * we do sys-critical inits only at reboot,
+	 * not when booting from ram!
+	 */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl	cpu_init_crit
+#endif
+
+#ifdef CONFIG_LPC2292
+	bl	lowlevel_init
+#endif
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+	bl coloured_LED_init
+	bl red_LED_on
+#endif
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 
 /*
  * the actual reset code
@@ -188,6 +348,8 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 
 _start_armboot: .word start_armboot
 
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
+
 /*
  *************************************************************************
  *
@@ -444,9 +606,13 @@ lock_loop:
 	stmia	sp, {r0 - r12}			@ Calling r0-r12
 	add	r8, sp, #S_PC
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)	@ set base 2 words into abort stack
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	ldmia	r2, {r2 - r4}			@ get pc, cpsr, old_r0
 	add	r0, sp, #S_FRAME_SIZE		@ restore sp_SVC
 
@@ -477,9 +643,13 @@ lock_loop:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r13, _armboot_start		@ setup our mode stack
 	sub	r13, r13, #(CONFIG_STACKSIZE+CONFIG_SYS_MALLOC_LEN)
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE+8) @ reserved a couple spots in abort stack
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	str	lr, [r13]			@ save caller lr / spsr
 	mrs	lr, spsr
diff --git a/arch/arm/cpu/arm720t/u-boot.lds b/arch/arm/cpu/arm720t/u-boot.lds
index c975fc3..4a0bc70 100644
--- a/arch/arm/cpu/arm720t/u-boot.lds
+++ b/arch/arm/cpu/arm720t/u-boot.lds
@@ -39,11 +39,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 26/26 v2][NEXT] ARM: implement relocation for arm1176
  2010-09-17 11:10                                                   ` [U-Boot] [PATCH 25/26 v2][NEXT] ARM: implement relocation for arm720t Heiko Schocher
@ 2010-09-17 11:10                                                     ` Heiko Schocher
  0 siblings, 0 replies; 60+ messages in thread
From: Heiko Schocher @ 2010-09-17 11:10 UTC (permalink / raw)
  To: u-boot

Change the implementation for arm1176 to relocate the code to
an arbitrary address in RAM.

Portions of this work were supported by funding from
the CE Linux Forum.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/arm1176/start.S    |  286 +++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/arm1176/u-boot.lds |   14 ++-
 2 files changed, 299 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S
index f98a7aa..e5e7913 100644
--- a/arch/arm/cpu/arm1176/start.S
+++ b/arch/arm/cpu/arm1176/start.S
@@ -95,6 +95,7 @@ _end_vect:
  *************************************************************************
  */
 
+.globl _TEXT_BASE
 _TEXT_BASE:
 	.word	TEXT_BASE
 
@@ -106,9 +107,11 @@ _TEXT_BASE:
 _TEXT_PHY_BASE:
 	.word	CONFIG_SYS_PHY_UBOOT_BASE
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 .globl _armboot_start
 _armboot_start:
 	.word _start
+#endif
 
 /*
  * These are defined in the board-specific linker script.
@@ -121,6 +124,275 @@ _bss_start:
 _bss_end:
 	.word _end
 
+#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+/* IRQ stack memory (calculated at run-time) + 8 bytes */
+.globl IRQ_STACK_START_IN
+IRQ_STACK_START_IN:
+	.word	0x0badc0de
+
+.globl _datarel_start
+_datarel_start:
+	.word __datarel_start
+
+.globl _datarelrolocal_start
+_datarelrolocal_start:
+	.word __datarelrolocal_start
+
+.globl _datarellocal_start
+_datarellocal_start:
+	.word __datarellocal_start
+
+.globl _datarelro_start
+_datarelro_start:
+	.word __datarelro_start
+
+.globl _got_start
+_got_start:
+	.word __got_start
+
+.globl _got_end
+_got_end:
+	.word __got_end
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0, cpsr
+	bic	r0, r0, #0x3f
+	orr	r0, r0, #0xd3
+	msr	cpsr, r0
+
+/*
+ *************************************************************************
+ *
+ * CPU_init_critical registers
+ *
+ * setup important registers
+ * setup memory timing
+ *
+ *************************************************************************
+ */
+	/*
+	 * we do sys-critical inits only at reboot,
+	 * not when booting from ram!
+	 */
+cpu_init_crit:
+	/*
+	 * When booting from NAND - it has definitely been a reset, so, no need
+	 * to flush caches and disable the MMU
+	 */
+#ifndef CONFIG_NAND_SPL
+	/*
+	 * flush v4 I/D caches
+	 */
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c7, 0	/* flush v3/v4 cache */
+	mcr	p15, 0, r0, c8, c7, 0	/* flush v4 TLB */
+
+	/*
+	 * disable MMU stuff and caches
+	 */
+	mrc	p15, 0, r0, c1, c0, 0
+	bic	r0, r0, #0x00002300	@ clear bits 13, 9:8 (--V- --RS)
+	bic	r0, r0, #0x00000087	@ clear bits 7, 2:0 (B--- -CAM)
+	orr	r0, r0, #0x00000002	@ set bit 2 (A) Align
+	orr	r0, r0, #0x00001000	@ set bit 12 (I) I-Cache
+
+	/* Prepare to disable the MMU */
+	adr	r2, mmu_disable_phys
+	sub	r2, r2, #(CONFIG_SYS_PHY_UBOOT_BASE - TEXT_BASE)
+	b	mmu_disable
+
+	.align 5
+	/* Run in a single cache-line */
+mmu_disable:
+	mcr	p15, 0, r0, c1, c0, 0
+	nop
+	nop
+	mov	pc, r2
+mmu_disable_phys:
+
+#ifdef CONFIG_DISABLE_TCM
+	/*
+	 * Disable the TCMs
+	 */
+	mrc	p15, 0, r0, c0, c0, 2	/* Return TCM details */
+	cmp	r0, #0
+	beq	skip_tcmdisable
+	mov	r1, #0
+	mov	r2, #1
+	tst	r0, r2
+	mcrne	p15, 0, r1, c9, c1, 1	/* Disable Instruction TCM if present*/
+	tst	r0, r2, LSL #16
+	mcrne	p15, 0, r1, c9, c1, 0	/* Disable Data TCM if present*/
+skip_tcmdisable:
+#endif
+#endif
+
+#ifdef CONFIG_PERIPORT_REMAP
+	/* Peri port setup */
+	ldr	r0, =CONFIG_PERIPORT_BASE
+	orr	r0, r0, #CONFIG_PERIPORT_SIZE
+	mcr	p15,0,r0,c15,c2,4
+#endif
+
+	/*
+	 * Go setup Memory and board specific bits prior to relocation.
+	 */
+	bl	lowlevel_init		/* go setup pll,mux,memory */
+
+/* Set stackpointer in internal RAM to call board_init_f */
+call_board_init_f:
+	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
+	ldr	r0,=0x00000000
+	bl	board_init_f
+
+/*------------------------------------------------------------------------------*/
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ */
+	.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
+	sub	r2, r3, r2		/* r2 <- size of armboot	    */
+	add	r2, r0, r2		/* r2 <- source end address	    */
+	cmp	r0, r6
+	beq	clear_bss
+
+#ifndef CONFIG_SKIP_RELOCATE_UBOOT
+copy_loop:
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r6!, {r9-r10}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+#ifndef CONFIG_PRELOADER
+	/* fix got entries */
+	ldr	r1, _TEXT_BASE		/* Text base */
+	mov	r0, r7			/* reloc addr */
+	ldr	r2, _got_start		/* addr in Flash */
+	ldr	r3, _got_end		/* addr in Flash */
+	sub	r3, r3, r1
+	add	r3, r3, r0
+	sub	r2, r2, r1
+	add	r2, r2, r0
+
+fixloop:
+	ldr	r4, [r2]
+	sub	r4, r4, r1
+	add	r4, r4, r0
+	str	r4, [r2]
+	add	r2, r2, #4
+	cmp	r2, r3
+	bne	fixloop
+#endif
+#endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
+
+#ifdef CONFIG_ENABLE_MMU
+enable_mmu:
+	/* enable domain access */
+	ldr	r5, =0x0000ffff
+	mcr	p15, 0, r5, c3, c0, 0	/* load domain access register */
+
+	/* Set the TTB register */
+	ldr	r0, _mmu_table_base
+	ldr	r1, =CONFIG_SYS_PHY_UBOOT_BASE
+	ldr	r2, =0xfff00000
+	bic	r0, r0, r2
+	orr	r1, r0, r1
+	mcr	p15, 0, r1, c2, c0, 0
+
+	/* Enable the MMU */
+	mrc	p15, 0, r0, c1, c0, 0
+	orr	r0, r0, #1		/* Set CR_M to enable MMU */
+
+	/* Prepare to enable the MMU */
+	adr	r1, skip_hw_init
+	and	r1, r1, #0x3fc
+	ldr	r2, _TEXT_BASE
+	ldr	r3, =0xfff00000
+	and	r2, r2, r3
+	orr	r2, r2, r1
+	b	mmu_enable
+
+	.align 5
+	/* Run in a single cache-line */
+mmu_enable:
+
+	mcr	p15, 0, r0, c1, c0, 0
+	nop
+	nop
+	mov	pc, r2
+skip_hw_init:
+#endif
+
+clear_bss:
+#ifndef CONFIG_PRELOADER
+	ldr	r0, _bss_start
+	ldr	r1, _bss_end
+	ldr	r3, _TEXT_BASE		/* Text base */
+	mov	r4, r7			/* reloc addr */
+	sub	r0, r0, r3
+	add	r0, r0, r4
+	sub	r1, r1, r3
+	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
+
+	bl coloured_LED_init
+	bl red_LED_on
+#endif
+
+/*
+ * We are done. Do not return, instead branch to second part of board
+ * initialization, now running from RAM.
+ */
+#ifdef CONFIG_NAND_SPL
+	ldr     pc, _nand_boot
+
+_nand_boot: .word nand_boot
+#else
+	ldr	r0, _TEXT_BASE
+	ldr	r2, _board_init_r
+	sub	r2, r2, r0
+	add	r2, r2, r7	/* position from board_init_r in RAM */
+	/* setup parameters for board_init_r */
+	mov	r0, r5		/* gd_t */
+	mov	r1, r7		/* dest_addr */
+	/* jump to it ... */
+	mov	lr, r2
+	mov	pc, lr
+
+_board_init_r: .word board_init_r
+#endif
+
+#else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
+
 /*
  * the actual reset code
  */
@@ -299,6 +571,8 @@ _start_armboot:
 /*	.word nand_boot*/
 #endif
 
+#endif /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
+
 #ifdef CONFIG_ENABLE_MMU
 _mmu_table_base:
 	.word mmu_table
@@ -385,10 +659,14 @@ phy_last_jump:
 	/* Save user registers (now in svc mode) r0-r12 */
 	stmia	sp, {r0 - r12}
 
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	ldr	r2, _armboot_start
 	sub	r2, r2, #(CONFIG_SYS_MALLOC_LEN)
 	/* set base 2 words into abort stack */
 	sub	r2, r2, #(CONFIG_SYS_GBL_DATA_SIZE+8)
+#else
+	ldr	r2, IRQ_STACK_START_IN
+#endif
 	/* get values for "aborted" pc and cpsr (into parm regs) */
 	ldmia	r2, {r2 - r3}
 	/* grab pointer to old stack */
@@ -403,12 +681,16 @@ phy_last_jump:
 	.endm
 
 	.macro get_bad_stack
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	/* setup our mode stack (enter in banked mode) */
 	ldr	r13, _armboot_start
 	/* move past malloc pool */
 	sub	r13, r13, #(CONFIG_SYS_MALLOC_LEN)
 	/* move to reserved a couple spots for abort stack */
 	sub	r13, r13, #(CONFIG_SYS_GBL_DATA_SIZE + 8)
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 
 	/* save caller lr in position 0 of saved stack */
 	str	lr, [r13]
@@ -433,12 +715,16 @@ phy_last_jump:
 	sub	r13, r13, #4
 	/* save R0's value. */
 	str	r0, [r13]
+#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
 	/* get data regions start */
 	ldr	r0, _armboot_start
 	/* move past malloc pool */
 	sub	r0, r0, #(CONFIG_SYS_MALLOC_LEN)
 	/* move past gbl and a couple spots for abort stack */
 	sub	r0, r0, #(CONFIG_SYS_GBL_DATA_SIZE + 8)
+#else
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+#endif
 	/* save caller lr in position 0 of saved stack */
 	str	lr, [r0]
 	/* get the spsr */
diff --git a/arch/arm/cpu/arm1176/u-boot.lds b/arch/arm/cpu/arm1176/u-boot.lds
index 8969587..fa640ee 100644
--- a/arch/arm/cpu/arm1176/u-boot.lds
+++ b/arch/arm/cpu/arm1176/u-boot.lds
@@ -39,11 +39,23 @@ SECTIONS
 	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data : { *(.data) }
+	.data : {
+		*(.data)
+	__datarel_start = .;
+		*(.data.rel)
+	__datarelrolocal_start = .;
+		*(.data.rel.ro.local)
+	__datarellocal_start = .;
+		*(.data.rel.local)
+	__datarelro_start = .;
+		*(.data.rel.ro)
+	}
 
+	__got_start = .;
 	. = ALIGN(4);
 	.got : { *(.got) }
 
+	__got_end = .;
 	. = .;
 	__u_boot_cmd_start = .;
 	.u_boot_cmd : { *(.u_boot_cmd) }
-- 
1.6.2.5

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-17 11:10                         ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Heiko Schocher
  2010-09-17 11:10                           ` [U-Boot] [PATCH 13/26 v2][NEXT] ARM: implement relocation for ARM11 Heiko Schocher
@ 2010-09-17 13:07                           ` Albert ARIBAUD
  2010-09-17 14:54                             ` Wolfgang Denk
  2010-09-18 22:35                           ` Albert ARIBAUD
                                             ` (2 subsequent siblings)
  4 siblings, 1 reply; 60+ messages in thread
From: Albert ARIBAUD @ 2010-09-17 13:07 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

Le 17/09/2010 13:10, Heiko Schocher a ?crit :

> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 54519b0..88c6427 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c

> @@ -234,6 +246,7 @@ typedef int (init_fnc_t) (void);
>
>   int print_cpuinfo (void);
>
> +#if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
>   init_fnc_t *init_sequence[] = {

init_sequence is a constant, not an initialized variable, and thus 
should have the 'const' qualifier.

> @@ -444,6 +457,459 @@ extern void davinci_eth_set_mac_addr (const u_int8_t *addr);
>
>   	/* NOTREACHED - no way out of command loop except booting */
>   }
> +#else
> +void __dram_init_banksize(void)
> +{
> +	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
> +	gd->bd->bi_dram[0].size =  gd->ram_size;
> +}
> +void dram_init_banksize(void)
> +	__attribute__((weak, alias("__dram_init_banksize")));
> +
> +init_fnc_t *init_sequence[] = {

Ditto.

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-17 13:07                           ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Albert ARIBAUD
@ 2010-09-17 14:54                             ` Wolfgang Denk
  2010-09-17 16:44                               ` Albert ARIBAUD
  0 siblings, 1 reply; 60+ messages in thread
From: Wolfgang Denk @ 2010-09-17 14:54 UTC (permalink / raw)
  To: u-boot

Dear Albert ARIBAUD,

In message <4C936823.1060802@free.fr> you wrote:
> 
> >   init_fnc_t *init_sequence[] = {
>
> init_sequence is a constant, not an initialized variable, and thus
> should have the 'const' qualifier.

Actually it _is_ an initialized variable (which still may take a
const).

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
We are all agreed that your  theory  is  crazy.  The  question  which
divides  us  is  whether it is crazy enough to have a chance of being
correct. My own feeling is that it is not crazy enough.  - Niels Bohr

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-17 14:54                             ` Wolfgang Denk
@ 2010-09-17 16:44                               ` Albert ARIBAUD
  2010-09-17 19:22                                 ` Wolfgang Denk
  0 siblings, 1 reply; 60+ messages in thread
From: Albert ARIBAUD @ 2010-09-17 16:44 UTC (permalink / raw)
  To: u-boot

Le 17/09/2010 16:54, Wolfgang Denk a ?crit :
> Dear Albert ARIBAUD,
>
> In message<4C936823.1060802@free.fr>  you wrote:
>>
>>>    init_fnc_t *init_sequence[] = {
>>
>> init_sequence is a constant, not an initialized variable, and thus
>> should have the 'const' qualifier.
>
> Actually it _is_ an initialized variable (which still may take a
> const).

Maybe we're having a terminology discrepancy here.

For me an initialized variable is a *variable*, i.e. intended to *vary* 
over execution time, and which is initialized, i.e. set to a known 
initial value; whereas a const has a value which does not vary over 
execution time, and thus a const is not a variable.

In that sense, and as init_sequence does not, and should not, vary over 
execution time, it is not a variable.

> Best regards,
>
> Wolfgang Denk

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-17 16:44                               ` Albert ARIBAUD
@ 2010-09-17 19:22                                 ` Wolfgang Denk
  2010-09-17 22:58                                   ` Albert ARIBAUD
  0 siblings, 1 reply; 60+ messages in thread
From: Wolfgang Denk @ 2010-09-17 19:22 UTC (permalink / raw)
  To: u-boot

Dear Albert ARIBAUD,

In message <4C939ADD.5090009@free.fr> you wrote:
>
> >>>    init_fnc_t *init_sequence[] = {
> >>
> >> init_sequence is a constant, not an initialized variable, and thus
> >> should have the 'const' qualifier.
> >
> > Actually it _is_ an initialized variable (which still may take a
> > const).
> 
> Maybe we're having a terminology discrepancy here.

We are talking about C code here, so I apply the terminology of the C
programming language.

> For me an initialized variable is a *variable*, i.e. intended to *vary* 
> over execution time, and which is initialized, i.e. set to a known 
> initial value; whereas a const has a value which does not vary over 
> execution time, and thus a const is not a variable.

A variable is a meaningful name of a data storage location in computer
memory. The term "variable" does not include specific properties of
this storage location.  In the C programming language, additional
qualifiers are used to refer to specific properties, like "automatic
variable", "initialized variable", "global variable", etc.

The C code line above declares a _variable_ with the name
"init_sequence" as an array of pointers to objects of type
init_fnc_t.  C does not have a notation to declare "constants".

Even if you add a "const" type qualifier (or two), it's still a
declaration of a variable.

> In that sense, and as init_sequence does not, and should not, vary over 
> execution time, it is not a variable.

Indeed, you use a different terminology.

Let's end this discussion here. Please.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"It is better to have tried and failed than to have  failed  to  try,
but the result's the same."                           - Mike Dennison

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

* [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP)
  2010-09-17 11:10                             ` [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP) Heiko Schocher
  2010-09-17 11:10                               ` [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926 Heiko Schocher
@ 2010-09-17 21:40                               ` John Rigby
  2010-09-17 22:02                                 ` Wolfgang Denk
  1 sibling, 1 reply; 60+ messages in thread
From: John Rigby @ 2010-09-17 21:40 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 17, 2010 at 5:10 AM, Heiko Schocher <hs@denx.de> wrote:
> Change the implementation for ARM V7 to relocate the code to an
> arbitrary address in RAM.
>
> Adapt the Beagle board (Cortex A8) to test the changes.
>
Heiko,

I'm running  -next on a Beagle board (first version of arm reloc not v2).

I noticed that when I wrote to ram in the range where u-boot runs
before being relocated sometimes the board hangs.  I then narrowed it
down to being able to reproduce the hang by writing to a single byte.
Turns out that __aeabi_uidiv gets called in its original location
after relocation.  I believe the culprit is ____aeabi_uidiv_veneer.

Here is a disassembly of my u-boot elf file:
80035c98 <____aeabi_uidiv_veneer>:
80035c98:       e51ff004        ldr     pc, [pc, #-4]   ; 80035c9c
<_end+0xfffc2498>
80035c9c:       800356f1        .word   0x800356f1

My relocaton offset is 0x07f7c000 so the relocated
____aeabi_uidiv_veneer is at 0x80035c98+0x07f7c000 or 0x87fb1c98.  If
I dump memory there:

OMAP3 beagleboard.org # md 0x87fb1c98
87fb1c98: e51ff004 800356f1 e51ff004 80035bfd    .....V.......[..

The original 800356f1 is still there.

Looks like these *veneer routines need to be relocated.

Please disregard if this is fixed in v2.

Regards,
John

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

* [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP)
  2010-09-17 21:40                               ` [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP) John Rigby
@ 2010-09-17 22:02                                 ` Wolfgang Denk
  2010-09-19  1:21                                   ` John Rigby
  0 siblings, 1 reply; 60+ messages in thread
From: Wolfgang Denk @ 2010-09-17 22:02 UTC (permalink / raw)
  To: u-boot

Dear John,

In message <AANLkTims+909jaF1Ho41+WAZbH1qmoNDG8AOhpM04j8F@mail.gmail.com> you wrote:
> 
> I noticed that when I wrote to ram in the range where u-boot runs
> before being relocated sometimes the board hangs.  I then narrowed it

Stupid question: how did you write to that RAM location? And why?

The RAM is not supposed to be accessable before relocation...

> down to being able to reproduce the hang by writing to a single byte.
> Turns out that __aeabi_uidiv gets called in its original location
> after relocation.  I believe the culprit is ____aeabi_uidiv_veneer.

Where is this coming from? I cannot see this symbol anywhere in U-Boot
code...

Which tool chain are you using? 

> Looks like these *veneer routines need to be relocated.

Hm... where are they coming from in the first place?


Can you please try building with (1) a different tool chain and/or
(2) with USE_PRIVATE_LIBGCC=yes on the command line?  Does this change
anything?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Q:  What's a light-year?
A:  One-third less calories than a regular year.

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-17 19:22                                 ` Wolfgang Denk
@ 2010-09-17 22:58                                   ` Albert ARIBAUD
  0 siblings, 0 replies; 60+ messages in thread
From: Albert ARIBAUD @ 2010-09-17 22:58 UTC (permalink / raw)
  To: u-boot

Le 17/09/2010 21:22, Wolfgang Denk a ?crit :
> Dear Albert ARIBAUD,
>
> In message<4C939ADD.5090009@free.fr>  you wrote:
>>
>>>>>     init_fnc_t *init_sequence[] = {
>>>>
>>>> init_sequence is a constant, not an initialized variable, and thus
>>>> should have the 'const' qualifier.
>>>
>>> Actually it _is_ an initialized variable (which still may take a
>>> const).
>>
>> Maybe we're having a terminology discrepancy here.
>
> We are talking about C code here, so I apply the terminology of the C
> programming language.

Sorry, but the C terminology as expressed in the C standard *never* 
refers to regions of data storage which hold value as 'variables'; it 
defines them as 'objects' (for instance, see paragraph 3.14 of the C99 
draft widely available; but C89 used the same terminology), and the term 
'variable' appears in it *only* within the expression 'variable length 
array'.

Now granted, I did not use C terminology either. So let's use it: I 
meant to say that the init_sequence object should have a const-qualified 
type. Would you agree?

> The C code line above declares a _variable_ with the name
> "init_sequence" as an array of pointers to objects of type
> init_fnc_t.  C does not have a notation to declare "constants".

Yes it has, it is the type qualifier 'const', which C89, C90 and C99 
define as forbidding writes to an lvalue.

> Even if you add a "const" type qualifier (or two), it's still a
> declaration of a variable.

Not per the standard, I'm afraid. I'll agree it is still the declaration 
of an object.

>> In that sense, and as init_sequence does not, and should not, vary over
>> execution time, it is not a variable.
>
> Indeed, you use a different terminology.
>
> Let's end this discussion here. Please.

As you wish: let us put the temrinology aside.

It remains that whatever name you want to give it, init_sequence is a 
constant object and should be qualified as such.

> Best regards,
>
> Wolfgang Denk

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-17 11:10                         ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Heiko Schocher
  2010-09-17 11:10                           ` [U-Boot] [PATCH 13/26 v2][NEXT] ARM: implement relocation for ARM11 Heiko Schocher
  2010-09-17 13:07                           ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Albert ARIBAUD
@ 2010-09-18 22:35                           ` Albert ARIBAUD
  2010-09-18 22:58                             ` Wolfgang Denk
  2010-09-19  8:28                           ` Albert ARIBAUD
  2010-09-19 11:17                           ` Wolfgang Denk
  4 siblings, 1 reply; 60+ messages in thread
From: Albert ARIBAUD @ 2010-09-18 22:35 UTC (permalink / raw)
  To: u-boot

Le 17/09/2010 13:10, Heiko Schocher a ?crit :

> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 54519b0..88c6427 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c

> @@ -444,6 +457,459 @@ extern void davinci_eth_set_mac_addr (const u_int8_t *addr);
>
>   	/* NOTREACHED - no way out of command loop except booting */
>   }
> +#else
> +void __dram_init_banksize(void)
> +{
> +	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
> +	gd->bd->bi_dram[0].size =  gd->ram_size;
> +}
> +void dram_init_banksize(void)
> +	__attribute__((weak, alias("__dram_init_banksize")));
> +
> +init_fnc_t *init_sequence[] = {
> +#if defined(CONFIG_ARCH_CPU_INIT)
> +	arch_cpu_init,		/* basic arch cpu dependent setup */
> +#endif
> +#if defined(CONFIG_BOARD_EARLY_INIT_F)
> +	board_early_init_f,
> +#endif
> +	timer_init,		/* initialize timer */
> +#ifdef CONFIG_FSL_ESDHC
> +	get_clocks,
> +#endif
> +	env_init,		/* initialize environment */
> +	init_baudrate,		/* initialze baudrate settings */
> +	serial_init,		/* serial communications setup */
> +	console_init_f,		/* stage 1 init of console */
> +	display_banner,		/* say that we are here */
> +#if defined(CONFIG_DISPLAY_CPUINFO)
> +	print_cpuinfo,		/* display cpu info (and speed) */
> +#endif
> +#if defined(CONFIG_DISPLAY_BOARDINFO)
> +	checkboard,		/* display board info */
> +#endif
> +#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
> +	init_func_i2c,
> +#endif
> +	dram_init,		/* configure available RAM banks */
> +#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
> +	arm_pci_init,
> +#endif
> +	NULL,
> +};

Are all these inits really required at board_init_f stage? I understand 
initializing the console in order to print out diagnostic and error 
messages before RAM is initialized, and I understand initializing RAM of 
course, but are I2C or PCI init needed before relocation? Can't they 
wait until board_init_r?

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-18 22:35                           ` Albert ARIBAUD
@ 2010-09-18 22:58                             ` Wolfgang Denk
  2010-09-19  6:04                               ` Heiko Schocher
  0 siblings, 1 reply; 60+ messages in thread
From: Wolfgang Denk @ 2010-09-18 22:58 UTC (permalink / raw)
  To: u-boot

Dear Albert ARIBAUD,

In message <4C953EC4.2090604@free.fr> you wrote:
> 
> > +#if defined(CONFIG_BOARD_EARLY_INIT_F)
> > +	board_early_init_f,
> > +#endif
> > +	timer_init,		/* initialize timer */
> > +#ifdef CONFIG_FSL_ESDHC
> > +	get_clocks,
> > +#endif
> > +	env_init,		/* initialize environment */
> > +	init_baudrate,		/* initialze baudrate settings */
> > +	serial_init,		/* serial communications setup */
> > +	console_init_f,		/* stage 1 init of console */
> > +	display_banner,		/* say that we are here */
> > +#if defined(CONFIG_DISPLAY_CPUINFO)
> > +	print_cpuinfo,		/* display cpu info (and speed) */
> > +#endif
> > +#if defined(CONFIG_DISPLAY_BOARDINFO)
> > +	checkboard,		/* display board info */
> > +#endif
> > +#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
> > +	init_func_i2c,
> > +#endif
> > +	dram_init,		/* configure available RAM banks */
> > +#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
> > +	arm_pci_init,
> > +#endif
> > +	NULL,
> > +};
>
> Are all these inits really required at board_init_f stage? I understand

Good question...

> initializing the console in order to print out diagnostic and error
> messages before RAM is initialized, and I understand initializing RAM of
> course, but are I2C or PCI init needed before relocation? Can't they
> wait until board_init_r?

I2C may be needed for example if you have the environment stored in a
I2C EEPROM - but then this is needed before init_baudrate ...

CONFIG_PCI - I don't think this is used at all by any ARM board yet.


My understanding is that Heiko might be preparing arch/arm/lib/board.c
for merging with arch/powerpc/lib/board.c ...

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Do not simplify the design of a program if a way can be found to make
it complex and wonderful.

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

* [U-Boot] [PATCH 00/26 v2][NEXT] arm: add full relocation / cache support
  2010-09-17 11:10 ` [U-Boot] [PATCH 00/26 v2][NEXT] " Heiko Schocher
  2010-09-17 11:10   ` [U-Boot] [PATCH 01/26 v2][NEXT] arm: get rid of bi_env Heiko Schocher
@ 2010-09-18 23:19   ` Wolfgang Denk
  2010-09-22 17:51   ` Ben Gardiner
  2 siblings, 0 replies; 60+ messages in thread
From: Wolfgang Denk @ 2010-09-18 23:19 UTC (permalink / raw)
  To: u-boot

Dear Heiko Schocher,

In message <1284721853-8298-1-git-send-email-hs@denx.de> you wrote:
> This patch series add full relocation and cache support for arm
> based boards. I test this for arm1136, arm_cortexa8 and arm926ejs
> based boards.
...
> changes since v1:
> 
> - missed to add statistics for enabling dcache to arm926ejs in
>   commit message. Add also CACHE command to the tx25 and
>   magnesium board. So I changed old patch
>   "ARM: flush cache for arm926" to
>   "ARM (ARM926ejs): add data cache support, tested on magnesium and tx25 board"
> - set TEXT_BASE == relocation address for the tx25 board.
>   -> in relocation_code() no need to copy code again for
>   this board. This results in editing "ARM: implement relocation for ARM926"
>   patch.
> 
> -> So actual next branch needs a rebase. Sorry for that!

OK, applied locally; will rebase public "next" after some more
testing.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
GUIs  are  virtually  useless.  Learn  tools.  They're  configurable,
scriptable, automatable, cron-able, interoperable, etc. We don't need
no brain-dead winslurping monolithic claptrap.
                               -- Tom Christiansen in 371140df at csnews

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

* [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP)
  2010-09-17 22:02                                 ` Wolfgang Denk
@ 2010-09-19  1:21                                   ` John Rigby
  2010-09-19  6:07                                     ` Heiko Schocher
  2010-09-19  6:58                                     ` Wolfgang Denk
  0 siblings, 2 replies; 60+ messages in thread
From: John Rigby @ 2010-09-19  1:21 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang,

Thanks for the feedback.

On Fri, Sep 17, 2010 at 4:02 PM, Wolfgang Denk <wd@denx.de> wrote:
> Dear John,
>
> In message <AANLkTims+909jaF1Ho41+WAZbH1qmoNDG8AOhpM04j8F@mail.gmail.com> you wrote:
>>
>> I noticed that when I wrote to ram in the range where u-boot runs
>> before being relocated sometimes the board hangs. ?I then narrowed it
>
> Stupid question: how did you write to that RAM location? And why?
>
> The RAM is not supposed to be accessable before relocation...

I worded this poorly.  I write to memory using mw at the u-boot
command line.  I write to the region where u-boot was running prior to
relocation:

OMAP3 beagleboard.org # mw.b 80000000 ff 1000000

>
>> down to being able to reproduce the hang by writing to a single byte.
>> Turns out that __aeabi_uidiv gets called in its original location
>> after relocation. ?I believe the culprit is ____aeabi_uidiv_veneer.
>
> Where is this coming from? I cannot see this symbol anywhere in U-Boot
> code...
>
> Which tool chain are you using?

I'm using a prerelease Ubuntu/Linaro gcc 4.4.4.

>
>> Looks like these *veneer routines need to be relocated.
>
> Hm... where are they coming from in the first place?
>
>
> Can you please try building with (1) a different tool chain and/or
> (2) with USE_PRIVATE_LIBGCC=yes on the command line? ?Does this change
> anything?

With USE_PRIVATE_LIBGCC=yes these veneer* routines go away and the
problem is gone.

Thanks,
John

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-18 22:58                             ` Wolfgang Denk
@ 2010-09-19  6:04                               ` Heiko Schocher
  2010-09-19  7:17                                 ` Albert ARIBAUD
  0 siblings, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-19  6:04 UTC (permalink / raw)
  To: u-boot

Hello Wolfgang,

Wolfgang Denk wrote:
> Dear Albert ARIBAUD,
> 
> In message <4C953EC4.2090604@free.fr> you wrote:
>>> +#if defined(CONFIG_BOARD_EARLY_INIT_F)
>>> +	board_early_init_f,
>>> +#endif
>>> +	timer_init,		/* initialize timer */
>>> +#ifdef CONFIG_FSL_ESDHC
>>> +	get_clocks,
>>> +#endif
>>> +	env_init,		/* initialize environment */
>>> +	init_baudrate,		/* initialze baudrate settings */
>>> +	serial_init,		/* serial communications setup */
>>> +	console_init_f,		/* stage 1 init of console */
>>> +	display_banner,		/* say that we are here */
>>> +#if defined(CONFIG_DISPLAY_CPUINFO)
>>> +	print_cpuinfo,		/* display cpu info (and speed) */
>>> +#endif
>>> +#if defined(CONFIG_DISPLAY_BOARDINFO)
>>> +	checkboard,		/* display board info */
>>> +#endif
>>> +#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
>>> +	init_func_i2c,
>>> +#endif
>>> +	dram_init,		/* configure available RAM banks */
>>> +#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
>>> +	arm_pci_init,
>>> +#endif
>>> +	NULL,
>>> +};
>> Are all these inits really required at board_init_f stage? I understand
> 
> Good question...
> 
>> initializing the console in order to print out diagnostic and error
>> messages before RAM is initialized, and I understand initializing RAM of
>> course, but are I2C or PCI init needed before relocation? Can't they
>> wait until board_init_r?
> 
> I2C may be needed for example if you have the environment stored in a
> I2C EEPROM - but then this is needed before init_baudrate ...

or for reading SPD EEprom for DDR setup ...

> CONFIG_PCI - I don't think this is used at all by any ARM board yet.
> 
> 
> My understanding is that Heiko might be preparing arch/arm/lib/board.c
> for merging with arch/powerpc/lib/board.c ...

Indeed, I copied this from arch/powerpc/lib/board.c and added
arm specific code. I think goal should be, that we can make a
arch/generic/lib/board.c ... ?

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP)
  2010-09-19  1:21                                   ` John Rigby
@ 2010-09-19  6:07                                     ` Heiko Schocher
  2010-09-19  6:59                                       ` Wolfgang Denk
  2010-09-19  6:58                                     ` Wolfgang Denk
  1 sibling, 1 reply; 60+ messages in thread
From: Heiko Schocher @ 2010-09-19  6:07 UTC (permalink / raw)
  To: u-boot

Hello John,

John Rigby wrote:
> Dear Wolfgang,
> 
> Thanks for the feedback.
> 
> On Fri, Sep 17, 2010 at 4:02 PM, Wolfgang Denk <wd@denx.de> wrote:
>> Dear John,
>>
>> In message <AANLkTims+909jaF1Ho41+WAZbH1qmoNDG8AOhpM04j8F@mail.gmail.com> you wrote:
>>> I noticed that when I wrote to ram in the range where u-boot runs
>>> before being relocated sometimes the board hangs.  I then narrowed it
>> Stupid question: how did you write to that RAM location? And why?
>>
>> The RAM is not supposed to be accessable before relocation...
> 
> I worded this poorly.  I write to memory using mw at the u-boot
> command line.  I write to the region where u-boot was running prior to
> relocation:
> 
> OMAP3 beagleboard.org # mw.b 80000000 ff 1000000
> 
>>> down to being able to reproduce the hang by writing to a single byte.
>>> Turns out that __aeabi_uidiv gets called in its original location
>>> after relocation.  I believe the culprit is ____aeabi_uidiv_veneer.
>> Where is this coming from? I cannot see this symbol anywhere in U-Boot
>> code...
>>
>> Which tool chain are you using?
> 
> I'm using a prerelease Ubuntu/Linaro gcc 4.4.4.
> 
>>> Looks like these *veneer routines need to be relocated.
>> Hm... where are they coming from in the first place?
>>
>>
>> Can you please try building with (1) a different tool chain and/or
>> (2) with USE_PRIVATE_LIBGCC=yes on the command line?  Does this change
>> anything?
> 
> With USE_PRIVATE_LIBGCC=yes these veneer* routines go away and the
> problem is gone.

Maybe, you can document this in doc/README.arm-relocation, in
a problem/solution chapter?

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP)
  2010-09-19  1:21                                   ` John Rigby
  2010-09-19  6:07                                     ` Heiko Schocher
@ 2010-09-19  6:58                                     ` Wolfgang Denk
  1 sibling, 0 replies; 60+ messages in thread
From: Wolfgang Denk @ 2010-09-19  6:58 UTC (permalink / raw)
  To: u-boot

Dear John Rigby,

In message <AANLkTi=b9dUZvLBj-5+BejGcgnqe=3XeME_9jQJSeNf4@mail.gmail.com> you wrote:
> 
> I worded this poorly.  I write to memory using mw at the u-boot
> command line.  I write to the region where u-boot was running prior to
> relocation:
> 
> OMAP3 beagleboard.org # mw.b 80000000 ff 1000000

Ah, now I understand.

So it seems that in your case parts of the code appear to access to
old addresses that were used before relocation.

> >> after relocation. I believe the culprit is ____aeabi_uidiv_veneer.
> >
> > Where is this coming from? I cannot see this symbol anywhere in U-Boot
> > code...
> >
> > Which tool chain are you using?
> 
> I'm using a prerelease Ubuntu/Linaro gcc 4.4.4.

So it seems these *_veneer symbos are introduced by GCC-4.4.* or so -
with ELDK's GCC-4.2.2 based tool chain and with the U-Boot internal
gcc helper funtions no such problem happens.

Can you please ask the people for help who are wroking on that Linaro
tool chain? They probably know better what these symbols mean and why
they are not properly relocated / relocatable.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Extreme feminine beauty is always disturbing.
	-- Spock, "The Cloud Minders", stardate 5818.4

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

* [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP)
  2010-09-19  6:07                                     ` Heiko Schocher
@ 2010-09-19  6:59                                       ` Wolfgang Denk
  0 siblings, 0 replies; 60+ messages in thread
From: Wolfgang Denk @ 2010-09-19  6:59 UTC (permalink / raw)
  To: u-boot

Dear Heiko Schocher,

In message <4C95A8A0.6080008@denx.de> you wrote:
> 
> > With USE_PRIVATE_LIBGCC=yes these veneer* routines go away and the
> > problem is gone.
> 
> Maybe, you can document this in doc/README.arm-relocation, in
> a problem/solution chapter?

No, I consider this a problem / incompatibility with that specific
tool chain that needs to be fixed either here or there.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Writing a book is like washing an elephant: there's no good place  to
begin  or  end,  and  it's  hard to keep track of what you've already
covered.

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-19  6:04                               ` Heiko Schocher
@ 2010-09-19  7:17                                 ` Albert ARIBAUD
  0 siblings, 0 replies; 60+ messages in thread
From: Albert ARIBAUD @ 2010-09-19  7:17 UTC (permalink / raw)
  To: u-boot

Le 19/09/2010 08:04, Heiko Schocher a ?crit :
> Hello Wolfgang,
>
> Wolfgang Denk wrote:
>> Dear Albert ARIBAUD,
>>
>> In message<4C953EC4.2090604@free.fr>  you wrote:
>>>> +#if defined(CONFIG_BOARD_EARLY_INIT_F)
>>>> +	board_early_init_f,
>>>> +#endif
>>>> +	timer_init,		/* initialize timer */
>>>> +#ifdef CONFIG_FSL_ESDHC
>>>> +	get_clocks,
>>>> +#endif
>>>> +	env_init,		/* initialize environment */
>>>> +	init_baudrate,		/* initialze baudrate settings */
>>>> +	serial_init,		/* serial communications setup */
>>>> +	console_init_f,		/* stage 1 init of console */
>>>> +	display_banner,		/* say that we are here */
>>>> +#if defined(CONFIG_DISPLAY_CPUINFO)
>>>> +	print_cpuinfo,		/* display cpu info (and speed) */
>>>> +#endif
>>>> +#if defined(CONFIG_DISPLAY_BOARDINFO)
>>>> +	checkboard,		/* display board info */
>>>> +#endif
>>>> +#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
>>>> +	init_func_i2c,
>>>> +#endif
>>>> +	dram_init,		/* configure available RAM banks */
>>>> +#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
>>>> +	arm_pci_init,
>>>> +#endif
>>>> +	NULL,
>>>> +};
>>> Are all these inits really required at board_init_f stage? I understand
>>
>> Good question...
>>
>>> initializing the console in order to print out diagnostic and error
>>> messages before RAM is initialized, and I understand initializing RAM of
>>> course, but are I2C or PCI init needed before relocation? Can't they
>>> wait until board_init_r?
>>
>> I2C may be needed for example if you have the environment stored in a
>> I2C EEPROM - but then this is needed before init_baudrate ...
>
> or for reading SPD EEprom for DDR setup ...
>
>> CONFIG_PCI - I don't think this is used at all by any ARM board yet.
>>
>>
>> My understanding is that Heiko might be preparing arch/arm/lib/board.c
>> for merging with arch/powerpc/lib/board.c ...
>
> Indeed, I copied this from arch/powerpc/lib/board.c and added
> arm specific code. I think goal should be, that we can make a
> arch/generic/lib/board.c ... ?
>
> bye,
> Heiko

Thanks, that clarifies it.

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-17 11:10                         ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Heiko Schocher
                                             ` (2 preceding siblings ...)
  2010-09-18 22:35                           ` Albert ARIBAUD
@ 2010-09-19  8:28                           ` Albert ARIBAUD
  2010-09-19 11:17                           ` Wolfgang Denk
  4 siblings, 0 replies; 60+ messages in thread
From: Albert ARIBAUD @ 2010-09-19  8:28 UTC (permalink / raw)
  To: u-boot

Le 17/09/2010 13:10, Heiko Schocher a ?crit :

> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 54519b0..88c6427 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c

> +void board_init_f (ulong bootflag)

A recursive grep found 'bootflag' nowhere else in the whole u-boot code; 
it always receives the value 0 from start.S; and is not used in 
board_init_f. What was it supposed to be for?

(if it has no use, no need to remove it: I am preparing a patch which 
will need to pass an argument from _start to board_init_f, and bootflag 
should be alright).

> +	relocate_code (addr_sp, id, addr);
> +	/* NOTREACHED - relocate_code() does not return */
> +}

Why call relocate_code() here when board_init_f could simply return to 
it? (passing a success/failure through a return value if necessary).

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-17 11:10                         ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Heiko Schocher
                                             ` (3 preceding siblings ...)
  2010-09-19  8:28                           ` Albert ARIBAUD
@ 2010-09-19 11:17                           ` Wolfgang Denk
  2010-09-19 11:56                             ` Heiko Schocher
  4 siblings, 1 reply; 60+ messages in thread
From: Wolfgang Denk @ 2010-09-19 11:17 UTC (permalink / raw)
  To: u-boot

Dear Heiko Schocher,

In message <1284721853-8298-13-git-send-email-hs@denx.de> you wrote:
> !! This breaks support for all arm boards !!

Not only that...

...
> diff --git a/nand_spl/nand_boot.c b/nand_spl/nand_boot.c
> index b9fd6f5..18ecbe1 100644
> --- a/nand_spl/nand_boot.c
> +++ b/nand_spl/nand_boot.c
> @@ -221,6 +221,13 @@ static int nand_load(struct mtd_info *mtd, unsigned int offs,
>  	return 0;
>  }
>  
> +#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
> +void board_init_f (ulong bootflag)
> +{
> +	relocate_code (TEXT_BASE - TOTAL_MALLOC_LEN, NULL, TEXT_BASE);
> +}
> +#endif
> +
>  /*
>   * The main entry for NAND booting. It's necessary that SDRAM is already
>   * configured and available since this code loads the main U-Boot image
> diff --git a/nand_spl/nand_boot_fsl_nfc.c b/nand_spl/nand_boot_fsl_nfc.c
> index ea3566b..3105657 100644
> --- a/nand_spl/nand_boot_fsl_nfc.c
> +++ b/nand_spl/nand_boot_fsl_nfc.c
> @@ -263,6 +263,13 @@ static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)
>  	return 0;
>  }
>  
> +#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
> +void board_init_f (ulong bootflag)
> +{
> +	relocate_code (TEXT_BASE - TOTAL_MALLOC_LEN, NULL, TEXT_BASE);
> +}
> +#endif

This is global code, which is used not only on ARM systems. The
changes break more or less all NAND-booting PowerPC board
configurations.


I'm currently testing this change:

-#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
+#if defined(CONFIG_ARM) && !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)


If this works, and you are OK with it, I will insert this into the
commit when checking in.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The so-called "desktop metaphor" of today's workstations  is  instead
an  "airplane-seat"  metaphor.  Anyone who has shuffled a lap full of
papers while seated between two portly passengers will recognize  the
difference -- one can see only a very few things at once.
                                                   - Fred Brooks, Jr.

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

* [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support
  2010-09-19 11:17                           ` Wolfgang Denk
@ 2010-09-19 11:56                             ` Heiko Schocher
  0 siblings, 0 replies; 60+ messages in thread
From: Heiko Schocher @ 2010-09-19 11:56 UTC (permalink / raw)
  To: u-boot

Hello Wolfgang,

Wolfgang Denk wrote:
> Dear Heiko Schocher,
> 
> In message <1284721853-8298-13-git-send-email-hs@denx.de> you wrote:
>> !! This breaks support for all arm boards !!
> 
> Not only that...
> 
> ...
>> diff --git a/nand_spl/nand_boot.c b/nand_spl/nand_boot.c
>> index b9fd6f5..18ecbe1 100644
>> --- a/nand_spl/nand_boot.c
>> +++ b/nand_spl/nand_boot.c
>> @@ -221,6 +221,13 @@ static int nand_load(struct mtd_info *mtd, unsigned int offs,
>>  	return 0;
>>  }
>>  
>> +#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
>> +void board_init_f (ulong bootflag)
>> +{
>> +	relocate_code (TEXT_BASE - TOTAL_MALLOC_LEN, NULL, TEXT_BASE);
>> +}
>> +#endif
>> +
>>  /*
>>   * The main entry for NAND booting. It's necessary that SDRAM is already
>>   * configured and available since this code loads the main U-Boot image
>> diff --git a/nand_spl/nand_boot_fsl_nfc.c b/nand_spl/nand_boot_fsl_nfc.c
>> index ea3566b..3105657 100644
>> --- a/nand_spl/nand_boot_fsl_nfc.c
>> +++ b/nand_spl/nand_boot_fsl_nfc.c
>> @@ -263,6 +263,13 @@ static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)
>>  	return 0;
>>  }
>>  
>> +#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
>> +void board_init_f (ulong bootflag)
>> +{
>> +	relocate_code (TEXT_BASE - TOTAL_MALLOC_LEN, NULL, TEXT_BASE);
>> +}
>> +#endif
> 
> This is global code, which is used not only on ARM systems. The
> changes break more or less all NAND-booting PowerPC board
> configurations.

Argh, you are right, thanks for finding this!

> I'm currently testing this change:
> 
> -#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
> +#if defined(CONFIG_ARM) && !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
> 
> 
> If this works, and you are OK with it, I will insert this into the
> commit when checking in.

I am fine with that, if it works ... but actually I am thinking
why this is not needed on PowerPC boards! If I don; t oversee
something, they jump in the nand_spl code to board_init_f() from
arch/powerpc/lib/board.c, and how fit this in the first nand
page?

Ahh! ... they(PowerPc boards) have their "own" board_init_f() in
nand_spl/board/* code for example like the mpc8313erdb ...
Hmm.. don;t know if this is possible for all PowerPc boards, but
I think, this should be also possible to move this board_init_f()
to a common place, like I did this for arm boards ... Ah, all
of this boards have board specific things to initialize in
their board_init_f() and then call relocate_code() ... Hmm...

So, in the end, I am fine with your suggested change!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926
  2010-09-17 11:10                               ` [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926 Heiko Schocher
  2010-09-17 11:10                                 ` [U-Boot] [PATCH 16/26 v2][NEXT] ARM: implement relocation for ARM920 Heiko Schocher
@ 2010-09-22  9:32                                 ` Albert ARIBAUD
  1 sibling, 0 replies; 60+ messages in thread
From: Albert ARIBAUD @ 2010-09-22  9:32 UTC (permalink / raw)
  To: u-boot

Le 17/09/2010 13:10, Heiko Schocher a ?crit :

> diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h
> index 357715d..016a21e 100644
> --- a/include/configs/da850evm.h
> +++ b/include/configs/da850evm.h
> @@ -39,7 +39,6 @@
>   #define CONFIG_SYS_HZ_CLOCK		clk_get(DAVINCI_AUXCLK_CLKID)
>   #define CONFIG_SYS_HZ			1000
>   #define CONFIG_SKIP_LOWLEVEL_INIT
> -#define CONFIG_SKIP_RELOCATE_UBOOT	/* to a proper address, init done */
>
>   /*
>    * Memory Info
> @@ -137,4 +136,9 @@
>   #undef CONFIG_CMD_ENV
>   #endif
>
> +/* additions for new relocation code, must added to all boards */

s/must added/must be added/

> +#undef CONFIG_SYS_ARM_WITHOUT_RELOC /* This board is tested with relocation support */
> +#define CONFIG_SYS_SDRAM_BASE		0xc0000000
> +#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x1000 - /* Fix this */ \
> +					CONFIG_SYS_GBL_DATA_SIZE)
>   #endif /* __CONFIG_H */
> diff --git a/include/configs/imx27lite-common.h b/include/configs/imx27lite-common.h
> index 33550ba..812e5f2 100644
> --- a/include/configs/imx27lite-common.h
> +++ b/include/configs/imx27lite-common.h
> @@ -235,4 +235,9 @@
>   	"mtdids=" MTDIDS_DEFAULT "\0"					\
>   	"mtdparts=" MTDPARTS_DEFAULT "\0"				\
>
> +/* additions for new relocation code, must added to all boards */

Ditto -- probably needs a global search and replace.

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH 00/26 v2][NEXT] arm: add full relocation / cache support
  2010-09-17 11:10 ` [U-Boot] [PATCH 00/26 v2][NEXT] " Heiko Schocher
  2010-09-17 11:10   ` [U-Boot] [PATCH 01/26 v2][NEXT] arm: get rid of bi_env Heiko Schocher
  2010-09-18 23:19   ` [U-Boot] [PATCH 00/26 v2][NEXT] arm: add full relocation / cache support Wolfgang Denk
@ 2010-09-22 17:51   ` Ben Gardiner
  2 siblings, 0 replies; 60+ messages in thread
From: Ben Gardiner @ 2010-09-22 17:51 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 17, 2010 at 7:10 AM, Heiko Schocher <hs@denx.de> wrote:
> This patch series add full relocation and cache support for arm
> based boards. I test this for arm1136, arm_cortexa8 and arm926ejs
> based boards.
>
> Relocation support:
>
> !! This change is not compatible to old code !!
>
> If you want to compile in old style, you can set
>
> CONFIG_SYS_ARM_WITHOUT_RELOC
>
> but this possibility will be removed soon, so please
> adapt your board(s)
>
> changed arch/arm/lib/board.c to get inline with arch/powerpc/lib/board.c
> maybe it is possible to snyc them to one arch/generic/lib/board.c?
>
> This approach is similiar to powerpc, so there is a need for
> an initial stack pointer addr defined through CONFIG_SYS_INIT_SP_ADDR.
>
> Please also read doc/README.arm-relocation There is more
> info what is done, and maybe should be done.
>
> Cache support:
>
> I used the patches from Alessandro Rubini:
> http://lists.denx.de/pipermail/u-boot/2010-January/067099.html
>
> and rebased them to actual code. Also, in case of full relocation,
> the position of the TLB can not be set on compile time, instead
> it is calculated in board_init_f() and stored in gd. Also added
> cache support for arm_cortexa8 and arm1136.
>
> changes since v1:
>
> - missed to add statistics for enabling dcache to arm926ejs in
> ?commit message. Add also CACHE command to the tx25 and
> ?magnesium board. So I changed old patch
> ?"ARM: flush cache for arm926" to
> ?"ARM (ARM926ejs): add data cache support, tested on magnesium and tx25 board"
> - set TEXT_BASE == relocation address for the tx25 board.
> ?-> in relocation_code() no need to copy code again for
> ?this board. This results in editing "ARM: implement relocation for ARM926"
> ?patch.

Tested u-boot/next, where the following is also applied:

97003756249bd790910417eb66f0039bbf06a02c da8xx: fixup ARM relocation support

Tests on da850evm with NAND and MII PHY enabled work fine.

Tested-by: Ben Gardiner <bengardiner@nanometrics.ca>

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca

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

end of thread, other threads:[~2010-09-22 17:51 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-11 18:15 [U-Boot] [PATCH 00/26] arm: add full relocation / cache support Heiko Schocher
2010-08-11 20:00 ` Ben Gardiner
2010-08-11 20:36   ` Ben Gardiner
2010-08-11 20:01 ` Wolfgang Denk
2010-08-12  5:34   ` Heiko Schocher
2010-08-12 20:49   ` Magnus Lilja
2010-08-13 10:01     ` Wolfgang Denk
2010-08-12 12:50 ` Shinya Kuribayashi
2010-08-12 12:55   ` Shinya Kuribayashi
2010-08-12 20:19     ` Wolfgang Denk
2010-08-12 20:17   ` Wolfgang Denk
2010-08-13 14:36     ` Shinya Kuribayashi
2010-09-17 11:10 ` [U-Boot] [PATCH 00/26 v2][NEXT] " Heiko Schocher
2010-09-17 11:10   ` [U-Boot] [PATCH 01/26 v2][NEXT] arm: get rid of bi_env Heiko Schocher
2010-09-17 11:10     ` [U-Boot] [PATCH 02/26 v2][NEXT] ARM: cp15: setup mmu and enable dcache Heiko Schocher
2010-09-17 11:10       ` [U-Boot] [PATCH 03/26 v2][NEXT] ARM (ARM926ejs): add data cache support, tested on magnesium and tx25 board Heiko Schocher
2010-09-17 11:10         ` [U-Boot] [PATCH 04/26 v2][NEXT] ARM V7 (OMAP): add data cache support, test on Beagle board Heiko Schocher
2010-09-17 11:10           ` [U-Boot] [PATCH 05/26 v2][NEXT] ARM (ARM11): add data cache support, test on Qong board Heiko Schocher
2010-09-17 11:10             ` [U-Boot] [PATCH 06/26 v2][NEXT] relocation: fixup cmdtable Heiko Schocher
2010-09-17 11:10               ` [U-Boot] [PATCH 07/26 v2][NEXT] common: move TOTAL_MALLOC_LEN to include/common.h Heiko Schocher
2010-09-17 11:10                 ` [U-Boot] [PATCH 08/26 v2][NEXT] i2c: fix command usage help Heiko Schocher
2010-09-17 11:10                   ` [U-Boot] [PATCH 09/26 v2][NEXT] disk/part.c: fix relocation fixup Heiko Schocher
2010-09-17 11:10                     ` [U-Boot] [PATCH 10/26 v2][NEXT] i2c, omap24xx: set bus_initialized only after relocation Heiko Schocher
2010-09-17 11:10                       ` [U-Boot] [PATCH 11/26 v2][NEXT] nand_boot_fsl_nfc.c: make "nfc" a "static const" pointer Heiko Schocher
2010-09-17 11:10                         ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Heiko Schocher
2010-09-17 11:10                           ` [U-Boot] [PATCH 13/26 v2][NEXT] ARM: implement relocation for ARM11 Heiko Schocher
2010-09-17 11:10                             ` [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP) Heiko Schocher
2010-09-17 11:10                               ` [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926 Heiko Schocher
2010-09-17 11:10                                 ` [U-Boot] [PATCH 16/26 v2][NEXT] ARM: implement relocation for ARM920 Heiko Schocher
2010-09-17 11:10                                   ` [U-Boot] [PATCH 17/26 v2][NEXT] ARM: implement relocation for ARM925 Heiko Schocher
2010-09-17 11:10                                     ` [U-Boot] [PATCH 18/26 v2][NEXT] ARM: implement relocation for ARM946 Heiko Schocher
2010-09-17 11:10                                       ` [U-Boot] [PATCH 19/26 v2][NEXT] ARM: implement relocation for pxa Heiko Schocher
2010-09-17 11:10                                         ` [U-Boot] [PATCH 20/26 v2][NEXT] ARM: implement relocation for ixp Heiko Schocher
2010-09-17 11:10                                           ` [U-Boot] [PATCH 21/26 v2][NEXT] ARM: implement relocation for sa1100 Heiko Schocher
2010-09-17 11:10                                             ` [U-Boot] [PATCH 22/26 v2][NEXT] ARM: implement relocation for s3c44b0 Heiko Schocher
2010-09-17 11:10                                               ` [U-Boot] [PATCH 23/26 v2][NEXT] ARM: implement relocation for lh7a40x Heiko Schocher
2010-09-17 11:10                                                 ` [U-Boot] [PATCH 24/26 v2][NEXT] ARM: implement relocation for arm_intcm Heiko Schocher
2010-09-17 11:10                                                   ` [U-Boot] [PATCH 25/26 v2][NEXT] ARM: implement relocation for arm720t Heiko Schocher
2010-09-17 11:10                                                     ` [U-Boot] [PATCH 26/26 v2][NEXT] ARM: implement relocation for arm1176 Heiko Schocher
2010-09-22  9:32                                 ` [U-Boot] [PATCH 15/26 v2][NEXT] ARM: implement relocation for ARM926 Albert ARIBAUD
2010-09-17 21:40                               ` [U-Boot] [PATCH 14/26 v2][NEXT] ARM: implement relocation for ARM V7 (OMAP) John Rigby
2010-09-17 22:02                                 ` Wolfgang Denk
2010-09-19  1:21                                   ` John Rigby
2010-09-19  6:07                                     ` Heiko Schocher
2010-09-19  6:59                                       ` Wolfgang Denk
2010-09-19  6:58                                     ` Wolfgang Denk
2010-09-17 13:07                           ` [U-Boot] [PATCH 12/26 v2][NEXT] ARM: add relocation support Albert ARIBAUD
2010-09-17 14:54                             ` Wolfgang Denk
2010-09-17 16:44                               ` Albert ARIBAUD
2010-09-17 19:22                                 ` Wolfgang Denk
2010-09-17 22:58                                   ` Albert ARIBAUD
2010-09-18 22:35                           ` Albert ARIBAUD
2010-09-18 22:58                             ` Wolfgang Denk
2010-09-19  6:04                               ` Heiko Schocher
2010-09-19  7:17                                 ` Albert ARIBAUD
2010-09-19  8:28                           ` Albert ARIBAUD
2010-09-19 11:17                           ` Wolfgang Denk
2010-09-19 11:56                             ` Heiko Schocher
2010-09-18 23:19   ` [U-Boot] [PATCH 00/26 v2][NEXT] arm: add full relocation / cache support Wolfgang Denk
2010-09-22 17:51   ` Ben Gardiner

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.