All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Chou <thomas@wytron.com.tw>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Fix board init code to use a valid C runtime environment
Date: Tue, 10 Nov 2015 09:14:01 +0800	[thread overview]
Message-ID: <564144D9.3010108@wytron.com.tw> (raw)
In-Reply-To: <1447114831-18627-1-git-send-email-albert.u.boot@aribaud.net>

Hi Albert,

On 2015?11?10? 08:20, Albert ARIBAUD wrote:
> board_init_f_mem() alters the C runtime environment's
> stack it ls actually already using. This is not a valid
> C runtime environment and may conflict with the C compiler's
> expectations.
>
> Split board_init_f_mem into C functions which do not
> alter their own stack and therefore function in a valid C
> runtime environment.
>
> NOTE: this has not been tested with all architectures.
>
> Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
> ---
>   arch/arc/lib/start.S            | 20 +++++++++++++---
>   arch/arm/lib/crt0.S             | 10 ++++++--
>   arch/arm/lib/crt0_64.S          | 12 +++++++---
>   arch/microblaze/cpu/start.S     |  4 ++--
>   arch/nios2/cpu/start.S          | 17 ++++++++++++--
>   arch/powerpc/cpu/ppc4xx/start.S | 18 ++++++++++----
>   arch/x86/cpu/start.S            | 10 ++++++--
>   arch/x86/lib/fsp/fsp_common.c   |  2 +-
>   common/init/board_init.c        | 33 +++++++++++++++-----------
>   include/common.h                | 52 +++++++++++++++++++++++++----------------
>   10 files changed, 126 insertions(+), 52 deletions(-)
>

Apply the patch.

$ git am "/work/tmp/[U-Boot] [PATCH] Fix board init code to use a valid 
C runtime environment.eml"
Applying: Fix board init code to use a valid C runtime environment
/work/nios2-linux/u-boot/.git/rebase-apply/patch:91: trailing whitespace.
	
/work/nios2-linux/u-boot/.git/rebase-apply/patch:292: trailing whitespace.
  *
/work/nios2-linux/u-boot/.git/rebase-apply/patch:309: trailing whitespace.
  *
/work/nios2-linux/u-boot/.git/rebase-apply/patch:325: trailing whitespace.
  *
/work/nios2-linux/u-boot/.git/rebase-apply/patch:337: trailing whitespace.
  *
warning: 5 lines add whitespace errors.

Make.

   LD      arch/nios2/lib/built-in.o
   CC      common/init/board_init.o
common/init/board_init.c:61:6: error: conflicting types for 
'board_init_f_malloc'
  void board_init_f_malloc(ulong malloc_base)
       ^
In file included from common/init/board_init.c:10:0:
include/common.h:265:7: note: previous declaration of 
'board_init_f_malloc' was here
  ulong board_init_f_malloc(ulong malloc_base);
        ^
scripts/Makefile.build:277: recipe for target 'common/init/board_init.o' 
failed
make[2]: *** [common/init/board_init.o] Error 1
scripts/Makefile.build:422: recipe for target 'common/init' failed
make[1]: *** [common/init] Error 2
Makefile:1205: recipe for target 'common' failed
make: *** [common] Error 2

Fix common.h.

diff --git a/include/common.h b/include/common.h
index dbc2808..7eb3ba8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -262,7 +262,7 @@ ulong board_init_f_malloc_size(void);
   *
   * @malloc_base: the base of the malloc arena
   */
-ulong board_init_f_malloc(ulong malloc_base);
+void board_init_f_malloc(ulong malloc_base);

  /**
   * arch_setup_gd() - Set up the global_data pointer

Make again.

   LDS     u-boot.lds
   LD      u-boot
arch/nios2/cpu/start.o: In function `_reloc':
/work/nios2-linux/u-boot/arch/nios2/cpu/start.S:111: undefined reference 
to `board_init_gd_size'
/work/nios2-linux/u-boot/arch/nios2/cpu/start.S:120: undefined reference 
to `board_init_malloc_size'
Makefile:1187: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1

Fix start.S.

diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
index 4d5f0b0..c163ce1 100644
--- a/arch/nios2/cpu/start.S
+++ b/arch/nios2/cpu/start.S
@@ -108,7 +108,7 @@ _reloc:

  	/* Allocate and zero GD, update SP */
  	movhi	r2, %hi(board_init_f_gd_size at h)
-	ori	r2, r2, %lo(board_init_gd_size at h)
+	ori	r2, r2, %lo(board_init_f_gd_size at h)
  	callr	r2
  	sub	sp, sp, r4
  	mov	r4, sp
@@ -117,7 +117,7 @@ _reloc:
  	callr	r2
  	/* Allocate malloc arena, update SP */
  	movhi	r2, %hi(board_init_f_malloc_size at h)
-	ori	r2, r2, %lo(board_init_malloc_size at h)
+	ori	r2, r2, %lo(board_init_f_malloc_size at h)
  	callr	r2
  	sub	sp, sp, r4
  	mov	r4, sp

Make and run, but failed to boot. I will gdb and tell you the trace later.

Best regards,
Thomas

  reply	other threads:[~2015-11-10  1:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-10  0:20 [U-Boot] [PATCH] Fix board init code to use a valid C runtime environment Albert ARIBAUD
2015-11-10  1:14 ` Thomas Chou [this message]
2015-11-10  6:06   ` Albert ARIBAUD
2015-11-10  3:54 ` Bin Meng
2015-11-10  7:14   ` [U-Boot] [PATCH] Fix board init code to use a valid C runtime environment (LONG, sorry) Albert ARIBAUD
2015-11-10 20:04 ` [U-Boot] [PATCH] Fix board init code to use a valid C runtime environment Simon Glass
2015-11-10 23:04   ` Albert ARIBAUD

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=564144D9.3010108@wytron.com.tw \
    --to=thomas@wytron.com.tw \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.