* [PATCH V2] startup: introduce global.endianness variable
@ 2020-04-06 12:13 Antony Pavlov
2020-04-06 12:44 ` Antony Pavlov
0 siblings, 1 reply; 5+ messages in thread
From: Antony Pavlov @ 2020-04-06 12:13 UTC (permalink / raw)
To: barebox
The global.endianness variable make 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 c87f2c9339..264833f88c 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -591,6 +591,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))
@@ -598,11 +600,19 @@ static int globalvar_init(void)
globalvar_add_simple("version", UTS_RELEASE);
+ if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+ endianness = "big";
+ else
+ endianness = "little";
+
+ globalvar_add_simple("endianness", endianness);
+
return 0;
}
pure_initcall(globalvar_init);
BAREBOX_MAGICVAR_NAMED(global_version, global.version, "The barebox version");
+BAREBOX_MAGICVAR_NAMED(global_endianness, global.endianness, "The barebox endianness");
/**
* nvvar_save - save NV variables to persistent environment
--
2.25.0
_______________________________________________
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 V2] startup: introduce global.endianness variable
2020-04-06 12:13 [PATCH V2] startup: introduce global.endianness variable Antony Pavlov
@ 2020-04-06 12:44 ` Antony Pavlov
2020-04-14 9:36 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Antony Pavlov @ 2020-04-06 12:44 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On Mon, 6 Apr 2020 15:13:25 +0300
Antony Pavlov <antonynpavlov@gmail.com> wrote:
Hi Sascha,
The global.version (and global.endianness) variable can
be easely modified by user.
Can we make it immutable?
--
Best regards,
Antony Pavlov
> The global.endianness variable make 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 c87f2c9339..264833f88c 100644
> --- a/common/globalvar.c
> +++ b/common/globalvar.c
> @@ -591,6 +591,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))
> @@ -598,11 +600,19 @@ static int globalvar_init(void)
>
> globalvar_add_simple("version", UTS_RELEASE);
>
> + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
> + endianness = "big";
> + else
> + endianness = "little";
> +
> + globalvar_add_simple("endianness", endianness);
> +
> return 0;
> }
> pure_initcall(globalvar_init);
>
> BAREBOX_MAGICVAR_NAMED(global_version, global.version, "The barebox version");
> +BAREBOX_MAGICVAR_NAMED(global_endianness, global.endianness, "The barebox endianness");
>
> /**
> * nvvar_save - save NV variables to persistent environment
> --
> 2.25.0
>
_______________________________________________
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 V2] startup: introduce global.endianness variable
2020-04-06 12:44 ` Antony Pavlov
@ 2020-04-14 9:36 ` Sascha Hauer
0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2020-04-14 9:36 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Mon, Apr 06, 2020 at 03:44:04PM +0300, Antony Pavlov wrote:
> On Mon, 6 Apr 2020 15:13:25 +0300
> Antony Pavlov <antonynpavlov@gmail.com> wrote:
>
> Hi Sascha,
>
> The global.version (and global.endianness) variable can
> be easely modified by user.
> Can we make it immutable?
There's currently no way to make variables registered with
globalvar_add_* readonly. What you can do is:
dev_add_param_fixed(&global_device, "version", UTS_RELEASE);
It would be nice to have a little globalvar_add_fixed() function which
does that. Besides the endianess it would be good to use it for the
version string as well.
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
* [PATCH v2] startup: introduce global.endianness variable
@ 2021-05-11 8:36 Antony Pavlov
2021-05-12 5:36 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Antony Pavlov @ 2021-05-11 8:36 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 | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/common/globalvar.c b/common/globalvar.c
index a55b38b00f..8bb5015ce4 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,16 @@ static int globalvar_init(void)
if (strlen(buildsystem_version_string) > 0)
globalvar_add_simple("buildsystem.version", buildsystem_version_string);
+#ifdef __BIG_ENDIAN
+ endianness = "big";
+#elif defined(__LITTLE_ENDIAN)
+ endianness = "little";
+#else
+#error "could not determine byte order"
+#endif
+
+ globalvar_add_simple("endianness", endianness);
+
return 0;
}
pure_initcall(globalvar_init);
@@ -658,6 +670,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 v2] startup: introduce global.endianness variable
2021-05-11 8:36 [PATCH v2] " Antony Pavlov
@ 2021-05-12 5:36 ` Sascha Hauer
0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2021-05-12 5:36 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Tue, May 11, 2021 at 11:36:48AM +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 | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
Applied, thanks
Sascha
>
> diff --git a/common/globalvar.c b/common/globalvar.c
> index a55b38b00f..8bb5015ce4 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,16 @@ static int globalvar_init(void)
> if (strlen(buildsystem_version_string) > 0)
> globalvar_add_simple("buildsystem.version", buildsystem_version_string);
>
> +#ifdef __BIG_ENDIAN
> + endianness = "big";
> +#elif defined(__LITTLE_ENDIAN)
> + endianness = "little";
> +#else
> +#error "could not determine byte order"
> +#endif
> +
> + globalvar_add_simple("endianness", endianness);
> +
> return 0;
> }
> pure_initcall(globalvar_init);
> @@ -658,6 +670,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
>
>
--
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-12 5:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 12:13 [PATCH V2] startup: introduce global.endianness variable Antony Pavlov
2020-04-06 12:44 ` Antony Pavlov
2020-04-14 9:36 ` Sascha Hauer
2021-05-11 8:36 [PATCH v2] " Antony Pavlov
2021-05-12 5:36 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox