From: Scott McNutt <smcnutt@psyent.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] nios2: fix out of reach case for do_reset
Date: Thu, 19 Aug 2010 22:25:07 -0400 [thread overview]
Message-ID: <4C6DE783.1040203@psyent.com> (raw)
In-Reply-To: <1281926984-11411-1-git-send-email-thomas@wytron.com.tw>
Thomas,
Applied to: git://git.denx.de/u-boot-nios.git next
Thanks,
--Scott
Thomas Chou wrote:
> 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>
> ---
> v2, add a macro for the inlince asm nios2_callr.
>
> arch/nios2/cpu/cpu.c | 11 +++++------
> arch/nios2/include/asm/system.h | 5 +++++
> 2 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
> index 6379534..d9c6544 100644
> --- a/arch/nios2/cpu/cpu.c
> +++ b/arch/nios2/cpu/cpu.c
> @@ -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;
> }
> diff --git a/arch/nios2/include/asm/system.h b/arch/nios2/include/asm/system.h
> index bb03ca5..086d92b 100644
> --- a/arch/nios2/include/asm/system.h
> +++ b/arch/nios2/include/asm/system.h
> @@ -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 */
prev parent reply other threads:[~2010-08-20 2:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-13 2:40 [U-Boot] [PATCH] nios2: fix out of reach case for do_reset Thomas Chou
2010-08-13 2:52 ` Mike Frysinger
2010-08-13 3:26 ` Thomas Chou
2010-08-13 23:51 ` [U-Boot] UNS: [Nios2-dev] " Brad Parker
2010-08-16 2:48 ` Thomas Chou
2010-08-16 2:49 ` [U-Boot] [PATCH v2] " Thomas Chou
2010-08-20 2:25 ` Scott McNutt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C6DE783.1040203@psyent.com \
--to=smcnutt@psyent.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox