public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] nios2: convert copy_exception_trampoline to use dm cpu data
Date: Thu, 8 Oct 2015 23:41:05 +0200	[thread overview]
Message-ID: <201510082341.05707.marex@denx.de> (raw)
In-Reply-To: <1444114536-21999-1-git-send-email-thomas@wytron.com.tw>

On Tuesday, October 06, 2015 at 08:55:36 AM, Thomas Chou wrote:
> Convert copy_exception_trampoline() to use dm cpu data.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
> v2
>   fix exception address references.
> 
>  arch/nios2/cpu/cpu.c   | 24 ++++++++++++++++++++++++
>  arch/nios2/cpu/start.S | 24 +-----------------------
>  2 files changed, 25 insertions(+), 23 deletions(-)
> 
> diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
> index 229a07b..5403c0d 100644
> --- a/arch/nios2/cpu/cpu.c
> +++ b/arch/nios2/cpu/cpu.c
> @@ -44,6 +44,27 @@ void dcache_disable(void)
>  	flush_dcache(CONFIG_SYS_DCACHE_SIZE, CONFIG_SYS_DCACHELINE_SIZE);
>  }
> 
> +/*
> + * COPY EXCEPTION TRAMPOLINE -- copy the tramp to the
> + * exception address. Define CONFIG_ROM_STUBS to prevent
> + * the copy (e.g. exception in flash or in other
> + * softare/firmware component).
> + */
> +#ifndef CONFIG_ROM_STUBS
> +static void copy_exception_trampoline(void)
> +{
> +	extern int _except_start, _except_end;
> +	void *except_target = (void *)gd->arch.exception_addr;
> +
> +	if (&_except_start != except_target) {
> +		memcpy(except_target, &_except_start,
> +		       &_except_end - &_except_start);
> +		flush_cache(gd->arch.exception_addr,
> +			    &_except_end - &_except_start);

Are you absolutelly sure that those addresses are aligned ?

> +	}
> +}
> +#endif
> +
>  int arch_cpu_init_dm(void)
>  {
>  	struct udevice *dev;
> @@ -56,6 +77,9 @@ int arch_cpu_init_dm(void)
>  		return -ENODEV;
> 
>  	gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
> +#ifndef CONFIG_ROM_STUBS
> +	copy_exception_trampoline();
> +#endif
> 
>  	return 0;
>  }
> diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
> index 6c7c777..90e0310 100644
> --- a/arch/nios2/cpu/start.S
> +++ b/arch/nios2/cpu/start.S
> @@ -14,7 +14,7 @@
>   ************************************************************************/
> 
>  	.text
> -	.global _start
> +	.global _start, _except_start, _except_end
> 
>  _start:
>  	wrctl	status, r0		/* Disable interrupts */
> @@ -89,28 +89,6 @@ _cur:	movhi	r5, %hi(_cur - _start)
>  	jmp	r4
>  _reloc:
> 
> -	/* COPY EXCEPTION TRAMPOLINE -- copy the tramp to the
> -	 * exception address. Define CONFIG_ROM_STUBS to prevent
> -	 * the copy (e.g. exception in flash or in other
> -	 * softare/firmware component).
> -	 */
> -#if !defined(CONFIG_ROM_STUBS)
> -	movhi	r4, %hi(_except_start)
> -	ori	r4, r4, %lo(_except_start)
> -	movhi	r5, %hi(_except_end)
> -	ori	r5, r5, %lo(_except_end)
> -	movhi	r6, %hi(CONFIG_SYS_EXCEPTION_ADDR)
> -	ori	r6, r6, %lo(CONFIG_SYS_EXCEPTION_ADDR)
> -	beq	r4, r6, 7f	/* Skip if at proper addr */
> -
> -6:	ldwio	r7, 0(r4)
> -	stwio	r7, 0(r6)
> -	addi	r4, r4, 4
> -	addi	r6, r6, 4
> -	bne	r4, r5, 6b
> -7:
> -#endif
> -
>  	/* STACK INIT -- zero top two words for call back chain.
>  	 */
>  	movhi	sp, %hi(CONFIG_SYS_INIT_SP)

  reply	other threads:[~2015-10-08 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-05  3:39 [U-Boot] [PATCH] nios2: convert copy_exception_trampoline to use dm cpu data Thomas Chou
2015-10-06  6:55 ` [U-Boot] [PATCH v2] " Thomas Chou
2015-10-08 21:41   ` Marek Vasut [this message]
2015-10-09  2:51   ` Ley Foon Tan
2015-10-09  8:45     ` Thomas Chou
2015-10-09 14:48       ` Marek Vasut
2015-10-13 13:16   ` Thomas Chou

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=201510082341.05707.marex@denx.de \
    --to=marex@denx.de \
    --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