]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
nios2: fix out of reach case for do_reset
authorThomas Chou <thomas@wytron.com.tw>
Mon, 16 Aug 2010 02:49:44 +0000 (10:49 +0800)
committerScott McNutt <smcnutt@psyent.com>
Fri, 20 Aug 2010 02:15:49 +0000 (22:15 -0400)
There is a limitation (or bug?) of nios2 toolchain. The nios2 gcc
didn't generate correct code when the reset vector is passed as a
constant. It just generated a direct "call", which was wrong when
the reset vector was not located in the same 256MB span as u-boot.

The "Nios II Processor Reference Handbook" said,
"call can transfer execution anywhere within the 256 MByte range
determined by PC31..28. The Nios II GNU linker does not automatically
handle cases in which the address is out of this range."

So we have to use registered "callr" instruction to do the job.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Signed-off-by: Scott McNutt <smcnutt@psyent.com>
arch/nios2/cpu/cpu.c
arch/nios2/include/asm/system.h

index 6379534a0b5c59175332a11b317fbd5f35fec39d..d9c654477d99569f23d031338dc693ee2cf7ed5d 100644 (file)
@@ -40,11 +40,10 @@ int checkcpu (void)
        return (0);
 }
 
-
-int do_reset (void)
+int do_reset(void)
 {
-       void (*rst)(void) = (void(*)(void))CONFIG_SYS_RESET_ADDR;
-       disable_interrupts ();
-       rst();
-       return(0);
+       disable_interrupts();
+       /* indirect call to go beyond 256MB limitation of toolchain */
+       nios2_callr(CONFIG_SYS_RESET_ADDR);
+       return 0;
 }
index bb03ca5316a31aea95a035e09b5632cdbec3ac38..086d92bb0c946526e5b0606c1e090932b19569d1 100644 (file)
@@ -56,4 +56,9 @@
        ((flags & NIOS2_STATUS_PIE_MSK) == 0x0);        \
 })
 
+/* indirect call to go beyond 256MB limitation of toolchain */
+#define nios2_callr(addr) __asm__ __volatile__ (       \
+       "callr  %0"                                     \
+       : : "r" (addr))
+
 #endif /* __ASM_NIOS2_SYSTEM_H */