diff options
author | Antony Pavlov <antonynpavlov@gmail.com> | 2021-05-11 11:36:48 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-05-12 07:35:54 +0200 |
commit | 1b2c92b76e8fd9185115c51f47056060ade5ec26 (patch) | |
tree | 9c5392745dc6b84f4e0c1f01e57352293f982835 /common | |
parent | f1d48ad3f887c8f23c907ea54e7e6850e1bea17e (diff) | |
download | barebox-1b2c92b76e8fd9185115c51f47056060ade5ec26.tar.gz barebox-1b2c92b76e8fd9185115c51f47056060ade5ec26.tar.xz |
startup: introduce global.endianness variable
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>
Link: https://lore.barebox.org/20210511083648.134890-1-antonynpavlov@gmail.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/globalvar.c | 13 |
1 files changed, 13 insertions, 0 deletions
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 |