* [U-Boot] FDT include file problems
@ 2008-10-19 22:01 Wolfgang Denk
2008-10-20 3:10 ` Jerry Van Baren
0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2008-10-19 22:01 UTC (permalink / raw)
To: u-boot
Hello,
on some systems (for example Fedora Core 4) U-Boot builds with the
following wanrings only:
...
In file included from /home/wd/git/u-boot/include/libfdt_env.h:33,
from fdt.c:51:
/usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
In file included from /home/wd/git/u-boot/include/libfdt_env.h:33,
from fdt_ro.c:51:
/usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
In file included from /home/wd/git/u-boot/include/libfdt_env.h:33,
from fdt_rw.c:51:
/usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
In file included from /home/wd/git/u-boot/include/libfdt_env.h:33,
from fdt_strerror.c:51:
/usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
In file included from /home/wd/git/u-boot/include/libfdt_env.h:33,
from fdt_wip.c:51:
/usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
...
The suggested change works in image.h, for example like this:
=======================================================================
diff --git a/include/image.h b/include/image.h
index 82e6345..1598b61 100644
--- a/include/image.h
+++ b/include/image.h
@@ -33,27 +33,29 @@
#ifndef __IMAGE_H__
#define __IMAGE_H__
-#include <asm/byteorder.h>
-#include <command.h>
-
-#ifndef USE_HOSTCC
-#include <lmb.h>
-#include <linux/string.h>
-#include <asm/u-boot.h>
-
-#else
+#if USE_HOSTCC
+#include <endian.h>
/* new uImage format support enabled on host */
#define CONFIG_FIT 1
#define CONFIG_OF_LIBFDT 1
#define CONFIG_FIT_VERBOSE 1 /* enable fit_format_{error,warning}() */
+#else
+
+#include <lmb.h>
+#include <linux/string.h>
+#include <asm/u-boot.h>
+#include <asm/byteorder.h>
+
#endif /* USE_HOSTCC */
#if defined(CONFIG_FIT) && !defined(CONFIG_OF_LIBFDT)
#error "CONFIG_OF_LIBFDT not enabled, required by CONFIG_FIT!"
#endif
+#include <command.h>
+
#if defined(CONFIG_FIT)
#include <fdt.h>
#include <libfdt.h>
=======================================================================
However, for the FDT code this doesn't help, as we then will get
unresolved references for fdt32_to_cpu(), cpu_to_fdt32(),
fdt64_to_cpu() and cpu_to_fdt64().
The 32 bit accesses couldbe worked around by using htonl() resp.
ntohl(), but I don't know a good way for the 64 bit cases.
Is there a clean and portable way to do this?
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
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
There you go man, Keep as cool as you can. It riles them to believe
that you perceive the web they weave. Keep on being free!
^ permalink raw reply related [flat|nested] 8+ messages in thread* [U-Boot] FDT include file problems
2008-10-19 22:01 [U-Boot] FDT include file problems Wolfgang Denk
@ 2008-10-20 3:10 ` Jerry Van Baren
2008-10-20 7:23 ` Wolfgang Denk
0 siblings, 1 reply; 8+ messages in thread
From: Jerry Van Baren @ 2008-10-20 3:10 UTC (permalink / raw)
To: u-boot
On Mon, Oct 20, 2008 at 12:01:59AM +0200, Wolfgang Denk wrote:
> Hello,
>
> on some systems (for example Fedora Core 4) U-Boot builds with the
> following wanrings only:
>
> ...
> In file included from /home/wd/git/u-boot/include/libfdt_env.h:33,
> from fdt.c:51:
> /usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
[snip]
> However, for the FDT code this doesn't help, as we then will get
> unresolved references for fdt32_to_cpu(), cpu_to_fdt32(),
> fdt64_to_cpu() and cpu_to_fdt64().
>
> The 32 bit accesses couldbe worked around by using htonl() resp.
> ntohl(), but I don't know a good way for the 64 bit cases.
>
> Is there a clean and portable way to do this?
>
> Best regards,
>
> Wolfgang Denk
Hi Wolfgang,
Does this work better?
Best regards,
gvb
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] FDT include file problems
2008-10-20 3:10 ` Jerry Van Baren
@ 2008-10-20 7:23 ` Wolfgang Denk
2008-10-20 10:17 ` Jerry Van Baren
0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2008-10-20 7:23 UTC (permalink / raw)
To: u-boot
Dear Jerry Van Baren,
In message <20081020031023.GA18173@cideas.com> you wrote:
>
> > ...
> > In file included from /home/wd/git/u-boot/include/libfdt_env.h:33,
> > from fdt.c:51:
> > /usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
...
> Does this work better?
Not really:
> From 0d33fb368acac6f88c0940ff2d1c77856900abcd Mon Sep 17 00:00:00 2001
> From: Gerald Van Baren <vanbaren@cideas.com>
> Date: Sun, 19 Oct 2008 22:50:07 -0400
> Subject: [PATCH] libfdt: Use endian.h instead of asm/byteorder.h
>
> Using asm/byteorder.h directly is strongly discouraged since it is a
> private kernel header.
Hm... but you still use it?
> Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
> ---
> include/libfdt_env.h | 15 +++++++++++----
> 1 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/include/libfdt_env.h b/include/libfdt_env.h
> index 671c3a8..728a248 100644
> --- a/include/libfdt_env.h
> +++ b/include/libfdt_env.h
> @@ -33,10 +33,17 @@
> #include <asm/byteorder.h>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This has not changed?
> extern struct fdt_header *working_fdt; /* Pointer to the working fdt */
>
> -#define fdt32_to_cpu(x) __be32_to_cpu(x)
> -#define cpu_to_fdt32(x) __cpu_to_be32(x)
> -#define fdt64_to_cpu(x) __be64_to_cpu(x)
> -#define cpu_to_fdt64(x) __cpu_to_be64(x)
> +#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#define fdt32_to_cpu(x) __swab32(x)
> +#define cpu_to_fdt32(x) __swab32(x)
> +#define fdt64_to_cpu(x) __swab64(x)
> +#define cpu_to_fdt64(x) __swab64(x)
> +#else
> +#define fdt32_to_cpu(x) (x)
> +#define cpu_to_fdt32(x) (x)
> +#define fdt64_to_cpu(x) (x)
> +#define cpu_to_fdt64(x) (x)
> +#endif
If I change the code to include <asm/byteorder.h> only for the U-Boot
code but use <endian.h>, I get warnings:
../include/libfdt.h:162: warning: implicit declaration of function '__swab32'
and finally a "undefined reference to `__swab32'" error. Seems
__swab32 and __swab64 are defined only in linux/byteorder/swab.h
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
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
"One day," said a dull voice from down below, "I'm going to be back
in form again and you're going to be very sorry you said that. For a
very long time. I might even go so far as to make even more Time just
for you to be sorry in." - Terry Pratchett, _Small Gods_
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] FDT include file problems
2008-10-20 7:23 ` Wolfgang Denk
@ 2008-10-20 10:17 ` Jerry Van Baren
2008-10-20 10:51 ` Wolfgang Denk
2008-10-20 11:08 ` Wolfgang Denk
0 siblings, 2 replies; 8+ messages in thread
From: Jerry Van Baren @ 2008-10-20 10:17 UTC (permalink / raw)
To: u-boot
Wolfgang Denk wrote:
> Dear Jerry Van Baren,
>
> In message <20081020031023.GA18173@cideas.com> you wrote:
>>> ...
>>> In file included from /home/wd/git/u-boot/include/libfdt_env.h:33,
>>> from fdt.c:51:
>>> /usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
> ...
>
>> Does this work better?
>
> Not really:
[snip]
>> diff --git a/include/libfdt_env.h b/include/libfdt_env.h
>> index 671c3a8..728a248 100644
>> --- a/include/libfdt_env.h
>> +++ b/include/libfdt_env.h
>> @@ -33,10 +33,17 @@
>> #include <asm/byteorder.h>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> This has not changed?
Oops, I was rushing too much. I missed changing this to endian.h.
[snip]
> If I change the code to include <asm/byteorder.h> only for the U-Boot
> code but use <endian.h>, I get warnings:
>
> ../include/libfdt.h:162: warning: implicit declaration of function '__swab32'
>
> and finally a "undefined reference to `__swab32'" error. Seems
> __swab32 and __swab64 are defined only in linux/byteorder/swab.h
>
> Best regards,
>
> Wolfgang Denk
...and if I were not rushing so much, I would have found that myself
instead of looking stupid. :-(
Google hasn't been very helpful for answering the question of how to
handle endian issues in userland (non-kernel) code. Hmmm. Grrr. Maybe
I'm not asking it the right question.
Maybe we need to make our own copy of linux/byteorder/swab.h in u-boot?
That doesn't seem right.
Best regards,
gvb
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] FDT include file problems
2008-10-20 10:17 ` Jerry Van Baren
@ 2008-10-20 10:51 ` Wolfgang Denk
2008-10-20 11:08 ` Wolfgang Denk
1 sibling, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2008-10-20 10:51 UTC (permalink / raw)
To: u-boot
Dear Jerry Van Baren,
In message <48FC5AB3.10302@gmail.com> you wrote:
>
> ...and if I were not rushing so much, I would have found that myself
> instead of looking stupid. :-(
>
> Google hasn't been very helpful for answering the question of how to
> handle endian issues in userland (non-kernel) code. Hmmm. Grrr. Maybe
> I'm not asking it the right question.
Well, I have to admit that you did not perform better, because I've
been searching before, and I didn't find a good solution myself
either. Normally, I use the network macros for such stuff, but these
don't have any 64 bit conversions...
> Maybe we need to make our own copy of linux/byteorder/swab.h in u-boot?
> That doesn't seem right.
No, that would not be right.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
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
Real programmers can write assembly code in any language. :-)
- Larry Wall in <8571@jpl-devvax.JPL.NASA.GOV>
^ permalink raw reply [flat|nested] 8+ messages in thread* [U-Boot] FDT include file problems
2008-10-20 10:17 ` Jerry Van Baren
2008-10-20 10:51 ` Wolfgang Denk
@ 2008-10-20 11:08 ` Wolfgang Denk
2008-10-20 23:43 ` Jerry Van Baren
1 sibling, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2008-10-20 11:08 UTC (permalink / raw)
To: u-boot
Dear Jerry Van Baren,
In message <48FC5AB3.10302@gmail.com> you wrote:
>
> Google hasn't been very helpful for answering the question of how to
> handle endian issues in userland (non-kernel) code. Hmmm. Grrr. Maybe
> I'm not asking it the right question.
This patch seems to work for me:
diff --git a/include/libfdt_env.h b/include/libfdt_env.h
index 671c3a8..355ebf2 100644
--- a/include/libfdt_env.h
+++ b/include/libfdt_env.h
@@ -24,19 +24,28 @@
#ifdef USE_HOSTCC
#include <stdint.h>
#include <string.h>
+#include <endian.h>
+#include <byteswap.h>
#else
#include <linux/string.h>
#include <linux/types.h>
+#include <asm/byteorder.h>
#endif /* USE_HOSTCC */
#include <stddef.h>
-#include <asm/byteorder.h>
extern struct fdt_header *working_fdt; /* Pointer to the working fdt */
-#define fdt32_to_cpu(x) __be32_to_cpu(x)
-#define cpu_to_fdt32(x) __cpu_to_be32(x)
-#define fdt64_to_cpu(x) __be64_to_cpu(x)
-#define cpu_to_fdt64(x) __cpu_to_be64(x)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define fdt32_to_cpu(x) bswap_32(x)
+#define cpu_to_fdt32(x) bswap_32(x)
+#define fdt64_to_cpu(x) bswap_64(x)
+#define cpu_to_fdt64(x) bswap_64(x)
+#else
+#define fdt32_to_cpu(x) (x)
+#define cpu_to_fdt32(x) (x)
+#define fdt64_to_cpu(x) (x)
+#define cpu_to_fdt64(x) (x)
+#endif
/*
* Types for `void *' pointers.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
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
The speed of time is one second per second.
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [U-Boot] FDT include file problems
2008-10-20 11:08 ` Wolfgang Denk
@ 2008-10-20 23:43 ` Jerry Van Baren
2008-10-21 9:24 ` Wolfgang Denk
0 siblings, 1 reply; 8+ messages in thread
From: Jerry Van Baren @ 2008-10-20 23:43 UTC (permalink / raw)
To: u-boot
Wolfgang Denk wrote:
> Dear Jerry Van Baren,
>
> In message <48FC5AB3.10302@gmail.com> you wrote:
>> Google hasn't been very helpful for answering the question of how to
>> handle endian issues in userland (non-kernel) code. Hmmm. Grrr. Maybe
>> I'm not asking it the right question.
>
> This patch seems to work for me:
>
> diff --git a/include/libfdt_env.h b/include/libfdt_env.h
> index 671c3a8..355ebf2 100644
> --- a/include/libfdt_env.h
> +++ b/include/libfdt_env.h
> @@ -24,19 +24,28 @@
> #ifdef USE_HOSTCC
> #include <stdint.h>
> #include <string.h>
> +#include <endian.h>
> +#include <byteswap.h>
> #else
> #include <linux/string.h>
> #include <linux/types.h>
> +#include <asm/byteorder.h>
> #endif /* USE_HOSTCC */
>
> #include <stddef.h>
> -#include <asm/byteorder.h>
> extern struct fdt_header *working_fdt; /* Pointer to the working fdt */
>
> -#define fdt32_to_cpu(x) __be32_to_cpu(x)
> -#define cpu_to_fdt32(x) __cpu_to_be32(x)
> -#define fdt64_to_cpu(x) __be64_to_cpu(x)
> -#define cpu_to_fdt64(x) __cpu_to_be64(x)
> +#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#define fdt32_to_cpu(x) bswap_32(x)
> +#define cpu_to_fdt32(x) bswap_32(x)
> +#define fdt64_to_cpu(x) bswap_64(x)
> +#define cpu_to_fdt64(x) bswap_64(x)
> +#else
> +#define fdt32_to_cpu(x) (x)
> +#define cpu_to_fdt32(x) (x)
> +#define fdt64_to_cpu(x) (x)
> +#define cpu_to_fdt64(x) (x)
> +#endif
>
> /*
> * Types for `void *' pointers.
>
> Best regards,
>
> Wolfgang Denk
Dear Wolfgang,
This works for me too. Do you want to apply it directly? That would be
fastest and easiest.
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
Thanks,
gvb
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] FDT include file problems
2008-10-20 23:43 ` Jerry Van Baren
@ 2008-10-21 9:24 ` Wolfgang Denk
0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2008-10-21 9:24 UTC (permalink / raw)
To: u-boot
Dear Jerry Van Baren,
In message <48FD17B1.7070909@gmail.com> you wrote:
>
> > This patch seems to work for me:
...
> This works for me too. Do you want to apply it directly? That would be
> fastest and easiest.
>
> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
Thanks - I'll post a proper patch first, including theother change
(in include/image.h).
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
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
Boss, n.: According to the Oxford English Dictionary, in the Middle
Ages the words "boss" and "botch" were largely synonymous, except
that boss, in addition to meaning "a supervisor of workers" also
meant "an ornamental stud."
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-10-21 9:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-19 22:01 [U-Boot] FDT include file problems Wolfgang Denk
2008-10-20 3:10 ` Jerry Van Baren
2008-10-20 7:23 ` Wolfgang Denk
2008-10-20 10:17 ` Jerry Van Baren
2008-10-20 10:51 ` Wolfgang Denk
2008-10-20 11:08 ` Wolfgang Denk
2008-10-20 23:43 ` Jerry Van Baren
2008-10-21 9:24 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox