* [U-Boot] [PATCH] openrisc: Work around potential relocation issues
@ 2012-05-05 22:32 Julius Baxter
2012-05-14 5:21 ` Mike Frysinger
2012-08-09 21:38 ` Wolfgang Denk
0 siblings, 2 replies; 3+ messages in thread
From: Julius Baxter @ 2012-05-05 22:32 UTC (permalink / raw)
To: u-boot
When reset code is in flash, the jump instructions emitted by the compiler are relative instead of absolute jumps.
A fix to the reset code to make correct jumps to the beginning of code relocated to RAM have also been added.
Signed-off-by: Julius Baxter <juliusbaxter@gmail.com>
---
arch/openrisc/cpu/cpu.c | 6 +++++-
arch/openrisc/cpu/start.S | 13 ++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/arch/openrisc/cpu/cpu.c b/arch/openrisc/cpu/cpu.c
index 25cd624..73ecc6f 100644
--- a/arch/openrisc/cpu/cpu.c
+++ b/arch/openrisc/cpu/cpu.c
@@ -151,7 +151,11 @@ extern void __reset(void);
int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
disable_interrupts();
- __reset();
+ /* Code the jump to __reset here as the compiler is prone to
+ emitting a bad jump instruction if the function is in flash */
+ __asm__("l.movhi r1,hi(__reset); \
+ l.ori r1,r1,lo(__reset); \
+ l.jr r1");
/* not reached, __reset does not return */
return 0;
}
diff --git a/arch/openrisc/cpu/start.S b/arch/openrisc/cpu/start.S
index 3a42717..39c80e1 100644
--- a/arch/openrisc/cpu/start.S
+++ b/arch/openrisc/cpu/start.S
@@ -26,8 +26,11 @@
#define HANDLE_EXCEPTION \
l.addi r1, r1, -EXCEPTION_STACK_SIZE ;\
+ l.sw 0x00(r1), r2 ;\
l.sw 0x1c(r1), r9 ;\
- l.jal _exception_handler ;\
+ l.movhi r2,hi(_exception_handler) ;\
+ l.ori r2,r2,lo(_exception_handler) ;\
+ l.jalr r2 ;\
l.nop ;\
l.lwz r9, 0x1c(r1) ;\
l.addi r1, r1, EXCEPTION_STACK_SIZE ;\
@@ -79,8 +82,9 @@ __reset:
l.bnf .L_relocvectors
l.addi r4,r4, 4
#endif
-
- l.j _start
+ l.movhi r4,hi(_start)
+ l.ori r4,r4,lo(_start)
+ l.jr r4
l.nop
/* bus error */
@@ -262,8 +266,7 @@ _start:
.type _exception_handler, at function
_exception_handler:
- /* Store state (r9 already saved)*/
- l.sw 0x00(r1), r2
+ /* Store state (r2 and r9 already saved)*/
l.sw 0x04(r1), r3
l.sw 0x08(r1), r4
l.sw 0x0c(r1), r5
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] openrisc: Work around potential relocation issues
2012-05-05 22:32 [U-Boot] [PATCH] openrisc: Work around potential relocation issues Julius Baxter
@ 2012-05-14 5:21 ` Mike Frysinger
2012-08-09 21:38 ` Wolfgang Denk
1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2012-05-14 5:21 UTC (permalink / raw)
To: u-boot
On Saturday 05 May 2012 18:32:11 Julius Baxter wrote:
> When reset code is in flash, the jump instructions emitted by the compiler
> are relative instead of absolute jumps.
>
> A fix to the reset code to make correct jumps to the beginning of code
> relocated to RAM have also been added.
please line wrap your commit messages to ~75 chars
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120514/bcefecfa/attachment.pgp>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] openrisc: Work around potential relocation issues
2012-05-05 22:32 [U-Boot] [PATCH] openrisc: Work around potential relocation issues Julius Baxter
2012-05-14 5:21 ` Mike Frysinger
@ 2012-08-09 21:38 ` Wolfgang Denk
1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Denk @ 2012-08-09 21:38 UTC (permalink / raw)
To: u-boot
Dear Julius Baxter,
In message <1336257131-29747-1-git-send-email-juliusbaxter@gmail.com> you wrote:
> When reset code is in flash, the jump instructions emitted by the compiler are relative instead of absolute jumps.
>
> A fix to the reset code to make correct jumps to the beginning of code relocated to RAM have also been added.
>
> Signed-off-by: Julius Baxter <juliusbaxter@gmail.com>
> ---
> arch/openrisc/cpu/cpu.c | 6 +++++-
> arch/openrisc/cpu/start.S | 13 ++++++++-----
> 2 files changed, 13 insertions(+), 6 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A good marriage would be between a blind wife and deaf husband.
-- Michel de Montaigne
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-09 21:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-05 22:32 [U-Boot] [PATCH] openrisc: Work around potential relocation issues Julius Baxter
2012-05-14 5:21 ` Mike Frysinger
2012-08-09 21:38 ` Wolfgang Denk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.