public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH v5 1/4] common: Convert ulong to phys_addr_t for image addresses
Date: Fri, 26 Feb 2016 00:05:00 +0100	[thread overview]
Message-ID: <20160225230500.3FCAF3809F9@gemini.denx.de> (raw)
In-Reply-To: <1456439779-4792-2-git-send-email-york.sun@nxp.com>

Dear York Sun,

In message <1456439779-4792-2-git-send-email-york.sun@nxp.com> you wrote:
> When dealing with image addresses, ulong has been used. Some files
> are used by both host and target. It is OK for the target, but not
> always enough for host tools including mkimage. This patch replaces
> "ulong" with "phys_addr_t" to make sure addresses are correct for
> both the target and the host.

You talk here about using "phys_addr_t"...

> -			   ulong, ulong, ulong))images->ep;
> +			   ulong, ulong, ulong))(uintptr_t)images->ep;

...but here you use  uintptr_t  , hich is something different?

> -		ulong, ulong, ulong))images->ep)(images->ft_addr,
> +		ulong, ulong, ulong))(uintptr_t)images->ep)(images->ft_addr,

Ditto.

> +	phys_addr_t os_data;
> +	ulong os_len;
>  	void *data = NULL;
>  	size_t len;
>  	int ret;
> @@ -87,11 +89,10 @@ static int boot_prep_linux(bootm_headers_t *images)
>  	if (images->legacy_hdr_valid) {
>  		hdr = images->legacy_hdr_os;
>  		if (image_check_type(hdr, IH_TYPE_MULTI)) {
> -			ulong os_data, os_len;

Why do you moe the declarations out of this block?  The variables are
only used within this block so there is no need for a wider scope?

> -			data = (void *)os_data;
> +			data = (void *)(uintptr_t)os_data;

This double cast looks scary to me, and you don;t explain it in the
commit message.  Why exactly is this needed?

> -		cmd_line_dest = (void *)images->ep + COMMAND_LINE_OFFSET;
> +		cmd_line_dest = (void *)(uintptr_t)images->ep +
> +				COMMAND_LINE_OFFSET;

Ditto.

> -	printf("Setup at %#08lx\n", images->ep);
> -	ret = setup_zimage((void *)images->ep, cmd_line_dest,
> +	printf("Setup at %#08" PRIpa "\n", images->ep);

This is really ugly...

> +	ret = setup_zimage((void *)(uintptr_t)images->ep, cmd_line_dest,

See before.

> -	debug("## Transferring control to Linux (at address %08lx, kernel %08lx) ...\n",
> +	debug("## Transferring control to Linux (at address %#08" PRIpa
> +	      ", kernel %#08" PRIpa ") ...\n",

See before...

> -		debug("*  kernel: cmdline image address = 0x%08lx\n",
> -			images->ep);
> +		debug("*  kernel: cmdline image address = %#08" PRIpa "\n",
> +		      images->ep);

Ditto.  etc. etc.

> +	/*
> +	 * In this function, data is decalred as phys_addr_t type.

s/decalred/declared/

> +	 * On some systems (eg. ARM, PowerPC) phys_addr_t can be
> +	 * "unsigned long", or "unsigned long long", depending on
> +	 * CONFIG_PHYS_64BIT.  It is safe to cast 64-bit phys_addr_t
> +	 * to 32-bit pointer for image handling because the actual
> +	 * address the image is loaded is within 32-bit space.

Who guarantees that?

> -		data = (ulong)fit_data;
> +		data = (phys_addr_t)(uintptr_t)fit_data;

This double cast looks strange to me.  Why is it needed?

> -				void *from = (void *)data;
> +				void *from = (void *)(uintptr_t)data;

Ditto.

> -			memmove((char *) dest, (char *)data, len);
> +			memmove((char *)dest, (char *)(uintptr_t)data, len);

Ditto. etc. etc.


All these double casts look somewhat wrong to me.  Why are they
needed?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Nearly everyone is in favor of going  to  heaven  but  too  many  are
hoping  they'll  live  long  enough  to see an easing of the entrance
requirements. Never appeal to a man's "better nature." he  might  not
have one.

  reply	other threads:[~2016-02-25 23:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-25 22:36 [U-Boot] [RFC PATCH v5 0/4] Enable FIT image to be loaded beyond 32-bit space York Sun
2016-02-25 22:36 ` [U-Boot] [RFC PATCH v5 1/4] common: Convert ulong to phys_addr_t for image addresses York Sun
2016-02-25 23:05   ` Wolfgang Denk [this message]
2016-02-26 17:22     ` york sun
2016-02-26 17:31       ` Simon Glass
2016-02-26 17:47         ` york sun
2016-02-26 18:05           ` Simon Glass
2016-02-26 18:09             ` york sun
2016-02-25 22:36 ` [U-Boot] [RFC PATCH v5 2/4] sandbox: Fix compiling warning York Sun
2016-02-25 22:36 ` [U-Boot] [RFC PATCH v5 3/4] common: image-fit: Use a common function to get address York Sun
2016-02-25 22:36 ` [U-Boot] [RFC PATCH v5 4/4] common: image-fit: Fix load and entry addresses in FIT image York Sun

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=20160225230500.3FCAF3809F9@gemini.denx.de \
    --to=wd@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