[U-Boot-Users] [PATCH] Use an absolute address when jumping out of 4k boot page

On e500 when we leave the 4k boot page we should use an absolute address since we don't know where the board code may want us to be really running at.
Signed-off-by: Kumar Gala galak@kernel.crashing.org --- cpu/mpc85xx/start.S | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/cpu/mpc85xx/start.S b/cpu/mpc85xx/start.S index 9dfd38d..89bae58 100644 --- a/cpu/mpc85xx/start.S +++ b/cpu/mpc85xx/start.S @@ -261,12 +261,11 @@ _start_e500: #endif
/* Jump out the last 4K page and continue to 'normal' start */ - bl 3f - b _start_cont + lis r1,_start_cont@h + ori r1,r1,_start_cont@l
-3: li r0,0 + li r0,0 mtspr SRR1,r0 /* Keep things disabled for now */ - mflr r1 mtspr SRR0,r1 rfi isync

In message Pine.LNX.4.64.0708071321210.9458@blarg.am.freescale.net you wrote:
On e500 when we leave the 4k boot page we should use an absolute address since we don't know where the board code may want us to be really running at.
I'm not sure I understand the problem or your intentions.
Normally we try to keep start.S more or less position-independent. Thus, an absolute jump seems contra-productive to me. Maybe I'm missing something?
Best regards,
Wolfgang Denk

On Aug 7, 2007, at 2:15 PM, Wolfgang Denk wrote:
In message <Pine.LNX. 4.64.0708071321210.9458@blarg.am.freescale.net> you wrote:
On e500 when we leave the 4k boot page we should use an absolute address since we don't know where the board code may want us to be really running at.
I'm not sure I understand the problem or your intentions.
Normally we try to keep start.S more or less position-independent. Thus, an absolute jump seems contra-productive to me. Maybe I'm missing something?
The code in 85xx/start.S is aware of CFG_MONITOR_BASE. In the first 4k code that is running @ 0xfffff000 we setup all the TLBs and local access windows that will be used through out the system. It seems reasonable that if my FLASH is going to end up at 0xe0000000 - 0xe7ffffff that when I jump out of that first 4k page I'd go to an address range that is in CFG_MONITOR_BASE.
In my particular case I have CFG_MONITOR_BASE set to 0xe7f80000. I don't have a TLB or local access window to cover anything but 0xfffff000 so the previous code being relative would have gotten me to something like 0xfff80100, however I want to be at 0xe7f80100.
Today the code does:
* do init 4k page setup code * jump to _start_cont (relative, outside of first 4k) * setup d-cache for stack * jump to flash_base (absolute)
All I'm doing is moving the absolute relocation to occur when we jump out of the 4k page instead of a few instructions later.
- k

On e500 when we leave the 4k boot page we should use an absolute address since we don't know where the board code may want us to be really running at.
Signed-off-by: Kumar Gala galak@kernel.crashing.org ---
This version might be a little cleaner in that we do the absolute address relocation to FLASH only once when leaving the initial 4k page.
cpu/mpc85xx/start.S | 53 +++++++++++++++++++++++--------------------------- 1 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/cpu/mpc85xx/start.S b/cpu/mpc85xx/start.S index 9dfd38d..2c98c2a 100644 --- a/cpu/mpc85xx/start.S +++ b/cpu/mpc85xx/start.S @@ -260,9 +260,33 @@ _start_e500: mtspr DBCR0,r0 #endif
+/* L1 DCache is used for initial RAM */ + + /* Allocate Initial RAM in data cache. + */ + lis r3,CFG_INIT_RAM_ADDR@h + ori r3,r3,CFG_INIT_RAM_ADDR@l + li r2,512 /* 512*32=16K */ + mtctr r2 + li r0,0 +1: + dcbz r0,r3 + dcbtls 0,r0,r3 + addi r3,r3,32 + bdnz 1b + /* Jump out the last 4K page and continue to 'normal' start */ +#ifdef CFG_RAMBOOT bl 3f b _start_cont +#else + /* Calculate absolute address in FLASH and jump there */ + /*--------------------------------------------------------------*/ + lis r3,CFG_MONITOR_BASE@h + ori r3,r3,CFG_MONITOR_BASE@l + addi r3,r3,_start_cont - _start + _START_OFFSET + mtlr r3 +#endif
3: li r0,0 mtspr SRR1,r0 /* Keep things disabled for now */ @@ -271,7 +295,6 @@ _start_e500: rfi isync
- .text .globl _start _start: @@ -285,34 +308,6 @@ version_string: .align 4 .globl _start_cont _start_cont: - -/* L1 DCache is used for initial RAM */ - - /* Allocate Initial RAM in data cache. - */ - lis r3,CFG_INIT_RAM_ADDR@h - ori r3,r3,CFG_INIT_RAM_ADDR@l - li r2,512 /* 512*32=16K */ - mtctr r2 - li r0,0 -1: - dcbz r0,r3 - dcbtls 0,r0,r3 - addi r3,r3,32 - bdnz 1b - -#ifndef CFG_RAMBOOT - /* Calculate absolute address in FLASH and jump there */ - /*--------------------------------------------------------------*/ - lis r3,CFG_MONITOR_BASE@h - ori r3,r3,CFG_MONITOR_BASE@l - addi r3,r3,in_flash - _start + _START_OFFSET - mtlr r3 - blr - .global in_flash -in_flash: -#endif /* CFG_RAMBOOT */ - /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/ lis r1,CFG_INIT_RAM_ADDR@h ori r1,r1,CFG_INIT_SP_OFFSET@l

In message Pine.LNX.4.64.0708071806001.15169@blarg.am.freescale.net you wrote:
On e500 when we leave the 4k boot page we should use an absolute address since we don't know where the board code may want us to be really running at.
Signed-off-by: Kumar Gala galak@kernel.crashing.org
Andy, please confirm that you picked this up and will send a pull request soon...
Thanks.
Best regards,
Wolfgang Denk
participants (2)
-
Kumar Gala
-
Wolfgang Denk