arm: add full relocation / cache support
Subsystems (7)
cover arm: add full relocation / cache support
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
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
cover arm: add full relocation / cache support
Quoted 3 lines · Heiko Schocher
This patch series add full relocation and cache support for arm based boards. I test this for arm1136,
arm_cortexa8and 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 ofgit://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
cover arm: add full relocation / cache support
Quoted 55 lines · Ben Gardiner
Quoted 3 lines · Heiko Schocher
This patch series add full relocation and cache support for arm based boards. I test this for arm1136,
arm_cortexa8and 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
046be127bbccfafe8b84c656ed87e1873e8a63d4ofgit://git.denx.de/u-boot-testing.gitwithda850evm_config.The board did not come up. I set a breakpoint in
relocate_codeand got a register dump as requested in previous email threads.(gdb) hbreak
relocate_code
Hardware assisted breakpoint 1 at0xc1080088: filestart.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
Quoted 8 lines
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
cover arm: add full relocation / cache support
In reply to Heiko SchocherDear Heiko Schocher,
a few comments...
Quoted 7 lines · In message <[email protected]> you wrote:
This patch series add full relocation and cache support for arm based boards. I test this for arm1136,
arm_cortexa8and 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.
Quoted 6 lines
If you want to compile in old style, you can set
CONFIG_SYS_ARM_WITHOUT_RELOCbut 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
Signature · 5 lines
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 Gurioncover arm: add full relocation / cache support
Hello Wolfgang,
Quoted 9 lines · Wolfgang Denk
Dear Heiko Schocher,
a few comments...
Quoted 4 lines · In message <[email protected]> you wrote:
This patch series add full relocation and cache support for arm based boards. I test this for arm1136,
arm_cortexa8and arm926ejs based boards.
Quoted 7 lines
Quoted 3 lines
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"
Quoted 9 lines
Quoted 6 lines
If you want to compile in old style, you can set
CONFIG_SYS_ARM_WITHOUT_RELOCbut this possibility will be removed soon, so please adapt your board(s)
The plan is as follows:
Quoted 7 lines
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
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
cover arm: add full relocation / cache support
In reply to Wolfgang DenkDear Wolfgang Denk,
Quoted 9 lines
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
cover arm: add full relocation / cache support
Dear Magnus Lilja,
Quoted 12 lines · In message <[email protected]> you wrote:
Dear Wolfgang Denk,
Quoted 9 lines
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.
Quoted 2 lines
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.
Quoted 2 lines
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.
Quoted 1 line
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
Signature · 7 lines
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
cover arm: add full relocation / cache support
In reply to Heiko SchocherQuoted 15 lines · Heiko Schocher
This patch series add full relocation and cache support for arm based boards. I test this for arm1136,
arm_cortexa8and 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_RELOCbut this possibility will be removed soon, so please adapt your board(s)
Quoted 8 lines
changed
arch/arm/lib/board.cto get inline witharch/powerpc/lib/board.cmaybe it is possible to snyc them to onearch/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
cover arm: add full relocation / cache support
Quoted 2 lines · Shinya Kuribayashi
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.
cover arm: add full relocation / cache support
Dear Shinya Kuribayashi,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 2 lines · Shinya Kuribayashi
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
Signature · 5 lines
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.
cover arm: add full relocation / cache support
In reply to Shinya KuribayashiDear Shinya Kuribayashi,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 3 lines
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.
Quoted 3 lines
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
Signature · 4 lines
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.
cover arm: add full relocation / cache support
Quoted 3 lines · Wolfgang Denk
Yes, this is the one.
[snip[
Quoted 4 lines
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
v2 cover arm: add full relocation / cache support
In reply to Heiko SchocherThis 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
PATCH v2 1/26 arm: get rid of bi_env
bi_env is nowhere used, so delete it!
Portions of this work were supported by funding from the CE Linux Forum.
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(-)
arch/arm/include/asm/u-boot.h +0 -4
@@ -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_ */
arch/avr32/include/asm/u-boot.h +0 -1
@@ -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 {
arch/i386/include/asm/u-boot.h +0 -4
@@ -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_ */
arch/mips/include/asm/u-boot.h +0 -2
@@ -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_ */
common/cmd_bdinfo.c +0 -1
@@ -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) {
Signature · 1 line
1.6.2.5
PATCH v2 2/26 ARM: cp15: setup mmu and enable dcache
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.
--- arch/arm/lib/cache-cp15.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-)
arch/arm/lib/cache-cp15.c +51 -0
@@ -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 (); + asmvolatile ("" : : :"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 */ + asmvolatile ("mcr p15, 0, %0, c2, c0, 0" + : :"r" (page_table) :"memory" ); +/* Set the access control to all-supervisor */ + asmvolatile ("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);
Signature · 1 line
1.6.2.5
PATCH v2 3/26 ARM (ARM926ejs): add data cache support, tested on magnesium and tx25 board
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.
--- arch/arm/lib/cache.c | 6 ++++++ include/configs/imx27lite-common.h | 1 + include/configs/tx25.h | 1 + 3 files changed, 8 insertions(+), 0 deletions(-)
arch/arm/lib/cache.c +6 -0
@@ -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 ; }
include/configs/imx27lite-common.h +1 -0
@@ -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
include/configs/tx25.h +1 -0
@@ -131,6 +131,7 @@/* U-Boot commands */ #include <config_cmd_default.h> #define CONFIG_CMD_NAND +#define CONFIG_CMD_CACHE /* * Ethernet
Signature · 1 line
1.6.2.5
PATCH v2 4/26 ARM V7 (OMAP): add data cache support, test on Beagle board
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.
--- 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(-)
arch/arm/cpu/armv7/omap3/cache.S +81 -0
@@ -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 +
arch/arm/lib/cache.c +5 -0
@@ -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 ; }
include/configs/omap3_beagle.h +1 -0
@@ -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 */
Signature · 1 line
1.6.2.5
PATCH v2 5/26 ARM (ARM11): add data cache support, test on Qong board
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.
--- 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(-)
arch/arm/cpu/arm1136/start.S +5 -0
@@ -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 */
arch/arm/lib/cache.c +1 -1
@@ -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 ();
include/configs/qong.h +1 -0
@@ -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
Signature · 1 line
1.6.2.5
PATCH v2 6/26 relocation: fixup cmdtable
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.
--- 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(-)
arch/avr32/lib/board.c +4 -21
@@ -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
arch/m68k/lib/board.c +4 -23
@@ -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;
arch/mips/lib/board.c +4 -24
@@ -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;
arch/sparc/lib/board.c +4 -24
@@ -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" );
common/command.c +37 -0
@@ -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
include/command.h +3 -0
@@ -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 */
Signature · 1 line
1.6.2.5
PATCH v2 7/26 common: move TOTAL_MALLOC_LEN to include/common.h
Portions of this work were supported by funding from the CE Linux Forum.
--- 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(-)
arch/m68k/lib/board.c +0 -8
@@ -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;
arch/mips/lib/board.c +0 -8
@@ -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 DEBUGextern int timer_init (void );
arch/powerpc/lib/board.c +0 -10
@@ -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
include/common.h +9 -0
@@ -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
Signature · 1 line
1.6.2.5
PATCH v2 8/26 i2c: fix command usage help
Portions of this work were supported by funding from the CE Linux Forum.
--- common/cmd_i2c.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
common/cmd_i2c.c +3 -0
@@ -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++;
Signature · 1 line
1.6.2.5
PATCH v2 9/26 disk/part.c: fix relocation fixup
Portions of this work were supported by funding from the CE Linux Forum.
--- disk/part.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
disk/part.c +9 -2
@@ -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++; }
Signature · 1 line
1.6.2.5
PATCH v2 10/26 i2c, omap24xx: set bus_initialized only after relocation.
Portions of this work were supported by funding from the CE Linux Forum.
--- drivers/i2c/omap24xx_i2c.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/i2c/omap24xx_i2c.c +3 -1
@@ -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)
Signature · 1 line
1.6.2.5
PATCH v2 11/26 nand_boot_fsl_nfc.c: make "nfc" a "static const" pointer
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.
--- nand_spl/nand_boot_fsl_nfc.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
nand_spl/nand_boot_fsl_nfc.c +1 -5
@@ -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
Signature · 1 line
1.6.2.5
PATCH v2 12/26 ARM: add relocation support
!! 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.
--- 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
arch/arm/config.mk +8 -0
@@ -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:
arch/arm/include/asm/config.h +2 -1
@@ -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
arch/arm/include/asm/global_data.h +11 -0
@@ -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;
arch/arm/include/asm/u-boot-arm.h +13 -1
@@ -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);
arch/arm/lib/board.c +467 -1
505 lines not on this page · raw message
arch/arm/lib/cache-cp15.c +34 -3
@@ -44,17 +44,44 @@ static void cp_delay (void) asmvolatile ("" : : :"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 );
arch/arm/lib/interrupts.c +18 -1
@@ -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 ;
common/cmd_bdinfo.c +10 -1
@@ -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 ; }
common/cmd_bmp.c +6 -0
@@ -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 *
common/cmd_i2c.c +6 -0
@@ -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;
doc/README.arm-relocation new file +321 -0
321 lines not on this page · raw message
nand_spl/nand_boot.c +7 -0
@@ -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
nand_spl/nand_boot_fsl_nfc.c +7 -0
@@ -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
Signature · 1 line
1.6.2.5
PATCH v2 13/26 ARM: implement relocation for ARM11
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.
--- 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(-)
arch/arm/cpu/arm1136/start.S +201 -0
@@ -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
arch/arm/cpu/arm1136/u-boot.lds +13 -1
@@ -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) }
board/davedenx/qong/config.mk +3 -1
@@ -1 +1,3 @@ -TEXT_BASE = 0x8ff00000 +TEXT_BASE = 0xa0000000 + +# PLATFORM_CPPFLAGS += -DDEBUG
board/davedenx/qong/qong.c +46 -41
105 lines not on this page · raw message
include/configs/qong.h +10 -0
@@ -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 */
Signature · 1 line
1.6.2.5
PATCH v2 14/26 ARM: implement relocation for ARM V7 (OMAP)
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.
--- 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(-)
arch/arm/cpu/armv7/mx51/u-boot.lds +13 -1
@@ -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 = .;
arch/arm/cpu/armv7/omap3/emif4.c +34 -0
@@ -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() -
arch/arm/cpu/armv7/omap3/sdrc.c +38 -0
@@ -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 -
arch/arm/cpu/armv7/start.S +187 -4
244 lines not on this page · raw message
arch/arm/cpu/armv7/u-boot.lds +13 -1
@@ -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) }
board/ti/beagle/config.mk +1 -1
@@ -30,4 +30,4 @@ # (mem base + reserved) # For use with external or internal boots. -TEXT_BASE = 0x80e80000 +TEXT_BASE = 0x80008000
include/configs/omap3_beagle.h +5 -0
@@ -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 */
Signature · 1 line
1.6.2.5
PATCH v2 15/26 ARM: implement relocation for ARM926
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:
Portions of this work were supported by funding from the CE Linux Forum.
--- 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(-)
arch/arm/cpu/arm926ejs/orion5x/dram.c +23 -1
@@ -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
arch/arm/cpu/arm926ejs/start.S +170 -2
220 lines not on this page · raw message
arch/arm/cpu/arm926ejs/u-boot.lds +13 -1
@@ -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) }
board/karo/tx25/config.mk +2 -2
@@ -1,5 +1,5 @@ ifdef CONFIG_NAND_SPL -TEXT_BASE = 0x81ec0000 +TEXT_BASE = 0x810c0000 else -TEXT_BASE = 0x81f00000 +TEXT_BASE = 0x81fc0000 endif
board/karo/tx25/tx25.c +9 -2
@@ -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 )
board/keymile/km_arm/km_arm.c +24 -0
@@ -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 ) {
board/logicpd/imx27lite/config.mk +1 -1
@@ -1 +1 @@ -TEXT_BASE = 0xA7F00000 +TEXT_BASE = 0xc0000000
board/logicpd/imx27lite/imx27lite.c +9 -6
@@ -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 )
doc/README.arm-relocation +23 -0
@@ -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)
include/configs/da850evm.h +5 -1
@@ -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 */
include/configs/imx27lite-common.h +5 -0
@@ -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 */
include/configs/km_arm.h +4 -0
@@ -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 */
include/configs/tx25.h +9 -4
@@ -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 */
nand_spl/board/karo/tx25/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 16/26 ARM: implement relocation for ARM920
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.
--- arch/arm/cpu/arm920t/start.S | 225 ++++++++++++++++++++++++++++++++++++++- arch/arm/cpu/arm920t/u-boot.lds | 14 +++- 2 files changed, 237 insertions(+), 2 deletions(-)
arch/arm/cpu/arm920t/start.S +224 -1
@@ -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
arch/arm/cpu/arm920t/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 17/26 ARM: implement relocation for ARM925
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.
--- arch/arm/cpu/arm925t/start.S | 204 ++++++++++++++++++++++++++++++++++++++- arch/arm/cpu/arm925t/u-boot.lds | 14 +++- 2 files changed, 216 insertions(+), 2 deletions(-)
arch/arm/cpu/arm925t/start.S +203 -1
@@ -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
arch/arm/cpu/arm925t/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 18/26 ARM: implement relocation for ARM946
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.
--- arch/arm/cpu/arm946es/start.S | 168 +++++++++++++++++++++++++++++++++++++- arch/arm/cpu/arm946es/u-boot.lds | 14 +++- 2 files changed, 180 insertions(+), 2 deletions(-)
arch/arm/cpu/arm946es/start.S +167 -1
@@ -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
arch/arm/cpu/arm946es/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 19/26 ARM: implement relocation for pxa
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.
--- arch/arm/cpu/pxa/start.S | 168 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/cpu/pxa/u-boot.lds | 14 ++++- 2 files changed, 181 insertions(+), 1 deletions(-)
arch/arm/cpu/pxa/start.S +168 -0
@@ -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
arch/arm/cpu/pxa/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 20/26 ARM: implement relocation for ixp
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.
--- arch/arm/cpu/ixp/start.S | 280 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/cpu/ixp/u-boot.lds | 14 ++- 2 files changed, 293 insertions(+), 1 deletions(-)
arch/arm/cpu/ixp/start.S +280 -0
@@ -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
arch/arm/cpu/ixp/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 21/26 ARM: implement relocation for sa1100
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.
--- arch/arm/cpu/sa1100/start.S | 162 ++++++++++++++++++++++++++++++++++++++++ arch/arm/cpu/sa1100/u-boot.lds | 14 +++- 2 files changed, 175 insertions(+), 1 deletions(-)
arch/arm/cpu/sa1100/start.S +162 -0
@@ -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
arch/arm/cpu/sa1100/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 22/26 ARM: implement relocation for s3c44b0
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.
--- arch/arm/cpu/s3c44b0/start.S | 174 +++++++++++++++++++++++++++++++++++++++ arch/arm/cpu/s3c44b0/u-boot.lds | 14 +++- 2 files changed, 187 insertions(+), 1 deletions(-)
arch/arm/cpu/s3c44b0/start.S +174 -0
@@ -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) */ /* *************************************************************************
arch/arm/cpu/s3c44b0/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 23/26 ARM: implement relocation for lh7a40x
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.
--- arch/arm/cpu/lh7a40x/start.S | 187 ++++++++++++++++++++++++++++++++++++++- arch/arm/cpu/lh7a40x/u-boot.lds | 14 +++- 2 files changed, 199 insertions(+), 2 deletions(-)
arch/arm/cpu/lh7a40x/start.S +186 -1
@@ -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
arch/arm/cpu/lh7a40x/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 24/26 ARM: implement relocation for arm_intcm
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.
--- arch/arm/cpu/arm_intcm/start.S | 166 +++++++++++++++++++++++++++++++++++++ arch/arm/cpu/arm_intcm/u-boot.lds | 14 +++- 2 files changed, 179 insertions(+), 1 deletions(-)
arch/arm/cpu/arm_intcm/start.S +166 -0
@@ -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
arch/arm/cpu/arm_intcm/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 25/26 ARM: implement relocation for arm720t
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.
--- arch/arm/cpu/arm720t/start.S | 170 +++++++++++++++++++++++++++++++++++++++ arch/arm/cpu/arm720t/u-boot.lds | 14 +++- 2 files changed, 183 insertions(+), 1 deletions(-)
arch/arm/cpu/arm720t/start.S +170 -0
@@ -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
arch/arm/cpu/arm720t/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 26/26 ARM: implement relocation for arm1176
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.
--- arch/arm/cpu/arm1176/start.S | 286 +++++++++++++++++++++++++++++++++++++++ arch/arm/cpu/arm1176/u-boot.lds | 14 ++- 2 files changed, 299 insertions(+), 1 deletions(-)
arch/arm/cpu/arm1176/start.S +286 -0
@@ -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 */
arch/arm/cpu/arm1176/u-boot.lds +13 -1
@@ -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) }
Signature · 1 line
1.6.2.5
PATCH v2 15/26 ARM: implement relocation for ARM926
In reply to Heiko SchocherLe 17/09/2010 13:10, Heiko Schocher a ?crit :
Quoted 13 lines
include/configs/da850evm.h +0
-1@@ -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
include/configs/da850evm.h line 139
Quoted 4 lines
include/configs/da850evm.h +1
-0@@ -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/
Quoted 10 lines
include/configs/da850evm.h +4
-0+#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 */ include/configs/imx27lite-common.h +0
-0
include/configs/imx27lite-common.h line 238
Quoted 4 lines
include/configs/imx27lite-common.h +1
-0@@ -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,
Signature · 1 line
Albert.
PATCH v2 14/26 ARM: implement relocation for ARM V7 (OMAP)
In reply to Heiko SchocherQuoted 5 lines · Heiko Schocher
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 0x87fb1c9887fb1c98: 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
PATCH v2 14/26 ARM: implement relocation for ARM V7 (OMAP)
Dear John,
Quoted 3 lines · In message <[email protected]> you…
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...
Quoted 3 lines
down to being able to reproduce the hang by writing to a single byte. Turns out that
__aeabi_uidivgets 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?
Quoted 1 line
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
Signature · 5 lines
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.
PATCH v2 14/26 ARM: implement relocation for ARM V7 (OMAP)
Dear Wolfgang,
Thanks for the feedback.
Quoted 10 lines · Wolfgang Denk
Dear John,
Quoted 3 lines · In message <[email protected]> you…
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
Quoted 9 lines
Quoted 4 lines
down to being able to reproduce the hang by writing to a single byte. Turns out that
__aeabi_uidivgets 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.
Quoted 9 lines
Quoted 2 lines
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
PATCH v2 14/26 ARM: implement relocation for ARM V7 (OMAP)
Hello John,
Quoted 34 lines · John Rigby
Dear Wolfgang,
Thanks for the feedback.
Quoted 8 lines · Wolfgang Denk
Dear John,
Quoted 2 lines · In message <[email protected]> you…
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
Quoted 7 lines
Quoted 3 lines
down to being able to reproduce the hang by writing to a single byte. Turns out that
__aeabi_uidivgets 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.
Quoted 4 lines
Quoted 1 line
Looks like these *veneer routines need to be relocated.
Hm... where are they coming from in the first place?
Quoted 6 lines
Quoted 3 lines
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
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v2 14/26 ARM: implement relocation for ARM V7 (OMAP)
Dear Heiko Schocher,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 3 lines
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
Signature · 6 lines
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.
PATCH v2 14/26 ARM: implement relocation for ARM V7 (OMAP)
In reply to John RigbyDear John Rigby,
Quoted 6 lines · In message <[email protected]> you…
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.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
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
Signature · 5 lines
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
PATCH v2 12/26 ARM: add relocation support
In reply to Heiko SchocherHi Heiko,
Le 17/09/2010 13:10, Heiko Schocher a ?crit :
arch/arm/lib/board.c typedef int (init_fnc_t) (void); · line 250
Quoted 11 lines
arch/arm/lib/board.c +1
-0@@ -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.
Quoted 4 lines
arch/arm/lib/board.c +0
-0@@ -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 */ }
arch/arm/lib/board.c extern void davinci_eth_set_mac_addr (const u_int8_t *addr); · line 469
Quoted 10 lines
arch/arm/lib/board.c +10
-0+#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,
Signature · 1 line
Albert.
PATCH v2 12/26 ARM: add relocation support
Dear Albert ARIBAUD,
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 2 lines
init_fnc_t *init_sequence[] = {
init_sequenceis 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
Signature · 6 lines
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
PATCH v2 12/26 ARM: add relocation support
Le 17/09/2010 16:54, Wolfgang Denk a ?crit :
Quoted 11 lines
Dear Albert ARIBAUD,
Quoted 5 lines · In message<[email protected]> you wrote:
Quoted 2 lines
init_fnc_t *init_sequence[] = {
init_sequenceis 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.
Quoted 3 lines
Best regards,
Wolfgang Denk
Amicalement,
Signature · 1 line
Albert.
PATCH v2 12/26 ARM: add relocation support
Dear Albert ARIBAUD,
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
init_fnc_t *init_sequence[] = {
init_sequenceis 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.
Quoted 4 lines
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.
Quoted 2 lines
In that sense, and as
init_sequencedoes 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
Signature · 5 lines
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
PATCH v2 12/26 ARM: add relocation support
Le 17/09/2010 21:22, Wolfgang Denk a ?crit :
Quoted 9 lines
Dear Albert ARIBAUD,
Quoted 6 lines · In message<[email protected]> you wrote:
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
init_fnc_t *init_sequence[] = {
init_sequenceis a constant, not an initialized variable, and thus should have the 'const' qualifier.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
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?
Quoted 3 lines
The C code line above declares a _variable_ with the name "
init_sequence" as an array of pointers to objects of typeinit_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.
Quoted 2 lines
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.
Quoted 6 lines
Quoted 2 lines
In that sense, and as
init_sequencedoes 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.
Quoted 3 lines
Best regards,
Wolfgang Denk
Amicalement,
Signature · 1 line
Albert.
PATCH v2 12/26 ARM: add relocation support
In reply to Heiko SchocherLe 17/09/2010 13:10, Heiko Schocher a ?crit :
Quoted 39 lines
arch/arm/lib/board.c +30
-0@@ -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 */
arch/arm/lib/board.c extern void davinci_eth_set_mac_addr (const u_int8_t *addr); · line 499
Quoted 10 lines
arch/arm/lib/board.c +10
-0+#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,
Signature · 1 line
Albert.
PATCH v2 12/26 ARM: add relocation support
Dear Albert ARIBAUD,
Quoted 22 lines · In message <[email protected]> you wrote:
Quoted 22 lines
arch/arm/lib/board.c +21
-0+#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
Quoted 8 lines
arch/arm/lib/board.c extern void davinci_eth_set_mac_addr (const u_int8_t *addr); · line 499
Quoted 6 lines
arch/arm/lib/board.c +6
-0+ 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_fstage? I understand
Good question...
Quoted 4 lines
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
Signature · 5 lines
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.
PATCH v2 12/26 ARM: add relocation support
Hello Wolfgang,
Quoted 34 lines · Wolfgang Denk
Dear Albert ARIBAUD,
Quoted 20 lines · In message <[email protected]> you wrote:
Quoted 20 lines
arch/arm/lib/board.c +20
-0+#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,Quoted 8 lines
arch/arm/lib/board.c extern void davinci_eth_set_mac_addr (const u_int8_t *addr); · line 499
Quoted 7 lines
arch/arm/lib/board.c +7
-0+#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_fstage? I understandGood question...
Quoted 7 lines
Quoted 4 lines
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 ...
Quoted 5 lines
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.cfor merging witharch/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
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v2 12/26 ARM: add relocation support
Le 19/09/2010 08:04, Heiko Schocher a ?crit :
Quoted 53 lines
Hello Wolfgang,
Quoted 34 lines · Wolfgang Denk
Dear Albert ARIBAUD,
Quoted 20 lines · In message<[email protected]> you wrote:
Quoted 20 lines
arch/arm/lib/board.c +20
-0+#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,Quoted 8 lines
arch/arm/lib/board.c extern void davinci_eth_set_mac_addr (const u_int8_t *addr); · line 499
Quoted 7 lines
arch/arm/lib/board.c +7
-0+#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_fstage? I understandGood question...
Quoted 7 lines
Quoted 4 lines
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 ...
Quoted 5 lines
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.cfor merging witharch/powerpc/lib/board.c...
Quoted 6 lines
Indeed, I copied this from
arch/powerpc/lib/board.cand added arm specific code. I think goal should be, that we can make aarch/generic/lib/board.c... ?bye,
Heiko
Thanks, that clarifies it.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 12/26 ARM: add relocation support
In reply to Heiko SchocherLe 17/09/2010 13:10, Heiko Schocher a ?crit :
arch/arm/lib/board.c
Quoted 6 lines
arch/arm/lib/board.c +1
-0+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).
arch/arm/lib/board.c extern void davinci_eth_set_mac_addr (const u_int8_t *addr); · line 662
Quoted 3 lines
arch/arm/lib/board.c +3
-0+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,
Signature · 1 line
Albert.
PATCH v2 12/26 ARM: add relocation support
In reply to Heiko SchocherDear Heiko Schocher,
Quoted 1 line · In message <[email protected]> you wrote:
!! This breaks support for all arm boards !!
Not only that...
...
Quoted 23 lines
nand_spl/nand_boot.c +7
-0@@ -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 nand_spl/nand_boot_fsl_nfc.c +0
-0
nand_spl/nand_boot_fsl_nfc.c static int nand_load(unsigned int from, unsigned int size, unsigned char *buf) · line 271
Quoted 9 lines
nand_spl/nand_boot_fsl_nfc.c +6
-0@@ -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
Signature · 8 lines
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.PATCH v2 12/26 ARM: add relocation support
Hello Wolfgang,
Quoted 34 lines · Wolfgang Denk
Dear Heiko Schocher,
Quoted 1 line · In message <[email protected]> you wrote:
!! This breaks support for all arm boards !!
Not only that...
...
Quoted 26 lines
nand_spl/nand_boot.c +7
-0@@ -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 nand_spl/nand_boot_fsl_nfc.c +0
-0@@ -263,6 +263,13 @@ static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)return 0 ; }
Quoted 10 lines
nand_spl/nand_boot_fsl_nfc.c static int nand_load(unsigned int from, unsigned int size, unsigned char *buf) · line 271
Quoted 6 lines
nand_spl/nand_boot_fsl_nfc.c +6
-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!
Quoted 8 lines
I'm currently testing this change:
(quoted diff) +1
-1-#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
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
v2 cover arm: add full relocation / cache support
In reply to Heiko SchocherDear Heiko Schocher,
Quoted 3 lines · In message <[email protected]> you wrote:
This patch series add full relocation and cache support for arm based boards. I test this for arm1136,
arm_cortexa8and arm926ejs based boards.
...
Quoted 12 lines
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"
- setTEXT_BASE== relocation address for the tx25 board.
-> inrelocation_code()no need to copy code again for
this board. This results in editing "ARM: implement relocation for ARM926" patch.
Quoted 1 line
-> 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
Signature · 7 lines
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 csnewsv2 cover arm: add full relocation / cache support
In reply to Heiko SchocherQuoted 36 lines · Heiko Schocher
This patch series add full relocation and cache support for arm based boards. I test this for arm1136,
arm_cortexa8and 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_RELOCbut this possibility will be removed soon, so please adapt your board(s)
changed
arch/arm/lib/board.cto get inline witharch/powerpc/lib/board.cmaybe it is possible to snyc them to onearch/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.htmland 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 forarm_cortexa8and arm1136.changes since v1:
Quoted 9 lines
- 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"
- setTEXT_BASE== relocation address for the tx25 board.
?-> inrelocation_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.
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca