From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brad Parker Date: Fri, 13 Aug 2010 19:51:43 -0400 Subject: [U-Boot] UNS: [Nios2-dev] [PATCH] nios2: fix out of reach case for do_reset In-Reply-To: <1281667205-23282-1-git-send-email-thomas@wytron.com.tw> (sfid-20100812_224039_277713_FED0353C) References: <1281667205-23282-1-git-send-email-thomas@wytron.com.tw> (sfid-20100812_224039_277713_FED0353C) Message-ID: <4C65DA8F.5000301@heeltoe.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de As a comment, that patch looks pretty ugly. I might suggest an inline function (called "callr" or "nios2_callr") which encapsulates the __asm__. That would make the code much easier to read. You could put the inline function in one of the asm headers. -brad Thomas Chou wrote: > 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 > --- > arch/nios2/cpu/cpu.c | 14 ++++++++------ > 1 files changed, 8 insertions(+), 6 deletions(-) > > diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c > index 6379534..d9c3003 100644 > --- a/arch/nios2/cpu/cpu.c > +++ b/arch/nios2/cpu/cpu.c > @@ -40,11 +40,13 @@ 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(); > + __asm__ __volatile__ ( > + "callr %0" > + : > + : "r" (CONFIG_SYS_RESET_ADDR) > + ); > + return 0; > } >