From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Chou Date: Fri, 13 Aug 2010 11:26:18 +0800 Subject: [U-Boot] [PATCH] nios2: fix out of reach case for do_reset In-Reply-To: References: <1281667205-23282-1-git-send-email-thomas@wytron.com.tw> Message-ID: <4C64BB5A.8090404@wytron.com.tw> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 08/13/2010 10:52 AM, Mike Frysinger wrote: > On Thu, Aug 12, 2010 at 10:40 PM, 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. > > doesnt NIOS have an insn to call indirectly via a register ? > typically that's how function pointers should be handled when gcc > generates code. > -mike > > Hi Mike, The nios2 does have "callr" instruction to do registered call. But 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 gcc does generate correct "callr" if the reset vector is passed as an argument. As Altera said, this is a limitation (or bug?) of nios2 toolchain. So I'd take a similar inline asm approach as we do in linux kernel. Best regards, Thomas