* [PATCH] startup: introduce global.endianness variable
@ 2021-04-26 14:30 Antony Pavlov
2021-04-28 4:39 ` Antony Pavlov
2021-05-03 11:16 ` Sascha Hauer
0 siblings, 2 replies; 5+ messages in thread
From: Antony Pavlov @ 2021-04-26 14:30 UTC (permalink / raw)
To: barebox
The global.endianness variable makes it possible
to determine current endian mode from command
line or from script on bi-endian capable system.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
common/globalvar.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/common/globalvar.c b/common/globalvar.c
index a55b38b00f..75ce6331b7 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -641,6 +641,8 @@ int globalvar_add_simple_ip(const char *name, IPaddr_t *ip)
static int globalvar_init(void)
{
+ const char *endianness;
+
register_device(&global_device);
if (IS_ENABLED(CONFIG_NVVAR))
@@ -651,6 +653,13 @@ static int globalvar_init(void)
if (strlen(buildsystem_version_string) > 0)
globalvar_add_simple("buildsystem.version", buildsystem_version_string);
+ if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+ endianness = "big";
+ else
+ endianness = "little";
+
+ globalvar_add_simple("endianness", endianness);
+
return 0;
}
pure_initcall(globalvar_init);
@@ -658,6 +667,7 @@ pure_initcall(globalvar_init);
BAREBOX_MAGICVAR(global.version, "The barebox version");
BAREBOX_MAGICVAR(global.buildsystem.version,
"version of buildsystem barebox was built with");
+BAREBOX_MAGICVAR(global.endianness, "The barebox endianness");
/**
* nvvar_save - save NV variables to persistent environment
--
2.31.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] startup: introduce global.endianness variable
2021-04-26 14:30 [PATCH] startup: introduce global.endianness variable Antony Pavlov
@ 2021-04-28 4:39 ` Antony Pavlov
2021-05-03 11:16 ` Sascha Hauer
1 sibling, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2021-04-28 4:39 UTC (permalink / raw)
To: barebox, Sascha Hauer
On Mon, 26 Apr 2021 17:30:25 +0300
Antony Pavlov <antonynpavlov@gmail.com> wrote:
ping
> The global.endianness variable makes it possible
> to determine current endian mode from command
> line or from script on bi-endian capable system.
>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> common/globalvar.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/common/globalvar.c b/common/globalvar.c
> index a55b38b00f..75ce6331b7 100644
> --- a/common/globalvar.c
> +++ b/common/globalvar.c
> @@ -641,6 +641,8 @@ int globalvar_add_simple_ip(const char *name, IPaddr_t *ip)
>
> static int globalvar_init(void)
> {
> + const char *endianness;
> +
> register_device(&global_device);
>
> if (IS_ENABLED(CONFIG_NVVAR))
> @@ -651,6 +653,13 @@ static int globalvar_init(void)
> if (strlen(buildsystem_version_string) > 0)
> globalvar_add_simple("buildsystem.version", buildsystem_version_string);
>
> + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
> + endianness = "big";
> + else
> + endianness = "little";
> +
> + globalvar_add_simple("endianness", endianness);
> +
> return 0;
> }
> pure_initcall(globalvar_init);
> @@ -658,6 +667,7 @@ pure_initcall(globalvar_init);
> BAREBOX_MAGICVAR(global.version, "The barebox version");
> BAREBOX_MAGICVAR(global.buildsystem.version,
> "version of buildsystem barebox was built with");
> +BAREBOX_MAGICVAR(global.endianness, "The barebox endianness");
>
> /**
> * nvvar_save - save NV variables to persistent environment
> --
> 2.31.1
>
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] startup: introduce global.endianness variable
2021-04-26 14:30 [PATCH] startup: introduce global.endianness variable Antony Pavlov
2021-04-28 4:39 ` Antony Pavlov
@ 2021-05-03 11:16 ` Sascha Hauer
2021-05-11 6:58 ` Antony Pavlov
1 sibling, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2021-05-03 11:16 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
Hi Antony,
On Mon, Apr 26, 2021 at 05:30:25PM +0300, Antony Pavlov wrote:
> The global.endianness variable makes it possible
> to determine current endian mode from command
> line or from script on bi-endian capable system.
>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> common/globalvar.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/common/globalvar.c b/common/globalvar.c
> index a55b38b00f..75ce6331b7 100644
> --- a/common/globalvar.c
> +++ b/common/globalvar.c
> @@ -641,6 +641,8 @@ int globalvar_add_simple_ip(const char *name, IPaddr_t *ip)
>
> static int globalvar_init(void)
> {
> + const char *endianness;
> +
> register_device(&global_device);
>
> if (IS_ENABLED(CONFIG_NVVAR))
> @@ -651,6 +653,13 @@ static int globalvar_init(void)
> if (strlen(buildsystem_version_string) > 0)
> globalvar_add_simple("buildsystem.version", buildsystem_version_string);
>
> + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
> + endianness = "big";
> + else
> + endianness = "little";
PowerPC is for sure big endian, but doesn't set CONFIG_CPU_BIG_ENDIAN,
so will be erroneously be identified as little endian with this patch.
Either you fix that or depend on something like #if __BYTE_ORDER ==
__LITTLE_ENDIAN
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] startup: introduce global.endianness variable
2021-05-03 11:16 ` Sascha Hauer
@ 2021-05-11 6:58 ` Antony Pavlov
2021-05-11 7:52 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Antony Pavlov @ 2021-05-11 6:58 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On Mon, 3 May 2021 13:16:43 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:
Hi Sascha!
> On Mon, Apr 26, 2021 at 05:30:25PM +0300, Antony Pavlov wrote:
> > The global.endianness variable makes it possible
> > to determine current endian mode from command
> > line or from script on bi-endian capable system.
> >
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> > common/globalvar.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/common/globalvar.c b/common/globalvar.c
> > index a55b38b00f..75ce6331b7 100644
> > --- a/common/globalvar.c
> > +++ b/common/globalvar.c
> > @@ -641,6 +641,8 @@ int globalvar_add_simple_ip(const char *name, IPaddr_t *ip)
> >
> > static int globalvar_init(void)
> > {
> > + const char *endianness;
> > +
> > register_device(&global_device);
> >
> > if (IS_ENABLED(CONFIG_NVVAR))
> > @@ -651,6 +653,13 @@ static int globalvar_init(void)
> > if (strlen(buildsystem_version_string) > 0)
> > globalvar_add_simple("buildsystem.version", buildsystem_version_string);
> >
> > + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
> > + endianness = "big";
> > + else
> > + endianness = "little";
>
> PowerPC is for sure big endian, but doesn't set CONFIG_CPU_BIG_ENDIAN,
> so will be erroneously be identified as little endian with this patch.
> Either you fix that or depend on something like #if __BYTE_ORDER ==
> __LITTLE_ENDIAN
Barebox don't use "__BYTE_ORDER == __*_ENDIAN" solution.
Please see include/envfs.h:
#ifdef __BAREBOX__
# ifdef __LITTLE_ENDIAN
# define ENVFS_ORDER_LITTLE
# elif defined __BIG_ENDIAN
# define ENVFS_ORDER_BIG
# else
# error "could not determine byte order"
# endif
#else
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define ENVFS_ORDER_LITTLE
# elif __BYTE_ORDER == __BIG_ENDIAN
# define ENVFS_ORDER_BIG
# else
# error "could not determine byte order"
# endif
#endif
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] startup: introduce global.endianness variable
2021-05-11 6:58 ` Antony Pavlov
@ 2021-05-11 7:52 ` Sascha Hauer
0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2021-05-11 7:52 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Tue, May 11, 2021 at 09:58:26AM +0300, Antony Pavlov wrote:
> On Mon, 3 May 2021 13:16:43 +0200
> Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> Hi Sascha!
>
> > On Mon, Apr 26, 2021 at 05:30:25PM +0300, Antony Pavlov wrote:
> > > The global.endianness variable makes it possible
> > > to determine current endian mode from command
> > > line or from script on bi-endian capable system.
> > >
> > > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > > ---
> > > common/globalvar.c | 10 ++++++++++
> > > 1 file changed, 10 insertions(+)
> > >
> > > diff --git a/common/globalvar.c b/common/globalvar.c
> > > index a55b38b00f..75ce6331b7 100644
> > > --- a/common/globalvar.c
> > > +++ b/common/globalvar.c
> > > @@ -641,6 +641,8 @@ int globalvar_add_simple_ip(const char *name, IPaddr_t *ip)
> > >
> > > static int globalvar_init(void)
> > > {
> > > + const char *endianness;
> > > +
> > > register_device(&global_device);
> > >
> > > if (IS_ENABLED(CONFIG_NVVAR))
> > > @@ -651,6 +653,13 @@ static int globalvar_init(void)
> > > if (strlen(buildsystem_version_string) > 0)
> > > globalvar_add_simple("buildsystem.version", buildsystem_version_string);
> > >
> > > + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
> > > + endianness = "big";
> > > + else
> > > + endianness = "little";
> >
> > PowerPC is for sure big endian, but doesn't set CONFIG_CPU_BIG_ENDIAN,
> > so will be erroneously be identified as little endian with this patch.
> > Either you fix that or depend on something like #if __BYTE_ORDER ==
> > __LITTLE_ENDIAN
>
> Barebox don't use "__BYTE_ORDER == __*_ENDIAN" solution.
>
> Please see include/envfs.h:
Right, then #ifdef __LITTLE_ENDIAN would be correct.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-05-11 11:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 14:30 [PATCH] startup: introduce global.endianness variable Antony Pavlov
2021-04-28 4:39 ` Antony Pavlov
2021-05-03 11:16 ` Sascha Hauer
2021-05-11 6:58 ` Antony Pavlov
2021-05-11 7:52 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox