diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-03-05 08:53:56 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-03-05 08:53:56 +0100 |
commit | cce3ed31230cf60ddbc653b3ace1fb64e05bbddb (patch) | |
tree | 5e0ea9edfdcdf9982303d8a83d40aee41ccfe3c7 /common | |
parent | dc90f050c2512ffe80c2c466295056baec0f021f (diff) | |
parent | 8d8382ec72d8a4a9ab0d53b07fd19b5248b0e8ce (diff) | |
download | barebox-cce3ed31230cf60ddbc653b3ace1fb64e05bbddb.tar.gz barebox-cce3ed31230cf60ddbc653b3ace1fb64e05bbddb.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 15 | ||||
-rw-r--r-- | common/console_common.c | 42 | ||||
-rw-r--r-- | common/misc.c | 26 |
3 files changed, 63 insertions, 20 deletions
diff --git a/common/Kconfig b/common/Kconfig index 93b1d89274..25de2485cd 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -632,6 +632,13 @@ config BOOTM_FITIMAGE_SIGNATURE Additionally the barebox device tree needs a /signature node with the public key with which the image has been signed. +config BOOTM_FITIMAGE_PUBKEY + string "Path to dtsi containing pubkey" + default "../fit/pubkey.dtsi" + depends on BOOTM_FITIMAGE_SIGNATURE + help + Set Path to a dts snippet which holds the public keys for FIT images. + config BOOTM_FORCE_SIGNED_IMAGES bool prompt "Force booting of signed images" @@ -744,6 +751,14 @@ config CONSOLE_ACTIVATE_NONE endchoice +config CONSOLE_ALLOW_COLOR + prompt "Allow colored console output during boot" + bool + help + If enabled, colored output is allowed during boot. This is the + compile time default for colored console output. After boot it + can be controlled using global.allow_color. + config PBL_CONSOLE depends on PBL_IMAGE depends on !CONSOLE_NONE diff --git a/common/console_common.c b/common/console_common.c index d051458de4..00e020bd35 100644 --- a/common/console_common.c +++ b/common/console_common.c @@ -33,6 +33,15 @@ #ifndef CONFIG_CONSOLE_NONE +static const char *colored_log_level[] = { + [MSG_EMERG] = "\033[31mEMERG:\033[0m ", /* red */ + [MSG_ALERT] = "\033[31mALERT:\033[0m ", /* red */ + [MSG_CRIT] = "\033[31mCRITICAL:\033[0m ", /* red */ + [MSG_ERR] = "\033[31mERROR:\033[0m ", /* red */ + [MSG_WARNING] = "\033[33mWARNING:\033[0m ", /* yellow */ + [MSG_NOTICE] = "\033[34mNOTICE:\033[0m ", /* blue */ +}; + int barebox_loglevel = CONFIG_DEFAULT_LOGLEVEL; LIST_HEAD(barebox_logbuf); @@ -102,6 +111,18 @@ nolog: puts(str); } +static void print_colored_log_level(const int level) +{ + if (!console_allow_color()) + return; + if (level >= ARRAY_SIZE(colored_log_level)) + return; + if (!colored_log_level[level]) + return; + + pr_puts(level, colored_log_level[level]); +} + int pr_print(int level, const char *fmt, ...) { va_list args; @@ -111,6 +132,8 @@ int pr_print(int level, const char *fmt, ...) if (!IS_ENABLED(CONFIG_LOGBUF) && level > barebox_loglevel) return 0; + print_colored_log_level(level); + va_start(args, fmt); i = vsprintf(printbuffer, fmt, args); va_end(args); @@ -129,6 +152,8 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...) if (!IS_ENABLED(CONFIG_LOGBUF) && level > barebox_loglevel) return 0; + print_colored_log_level(level); + if (dev->driver && dev->driver->name) ret += sprintf(printbuffer, "%s ", dev->driver->name); @@ -145,15 +170,28 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...) return ret; } -static int loglevel_init(void) +#ifdef CONFIG_CONSOLE_ALLOW_COLOR +static unsigned int __console_allow_color = 1; +#else +static unsigned int __console_allow_color = 0; +#endif + +bool console_allow_color(void) +{ + return __console_allow_color; +} + +static int console_common_init(void) { if (IS_ENABLED(CONFIG_LOGBUF)) globalvar_add_simple_int("log_max_messages", &barebox_log_max_messages, "%d"); + globalvar_add_simple_bool("allow_color", &__console_allow_color); + return globalvar_add_simple_int("loglevel", &barebox_loglevel, "%d"); } -device_initcall(loglevel_init); +device_initcall(console_common_init); void log_print(unsigned flags) { diff --git a/common/misc.c b/common/misc.c index 0888f1f4f6..665f72be7e 100644 --- a/common/misc.c +++ b/common/misc.c @@ -141,20 +141,15 @@ static char *model; */ void barebox_set_model(const char *__model) { - if (IS_ENABLED(CONFIG_GLOBALVAR)) { - globalvar_add_simple("model", __model); - } else { - free(model); - model = xstrdup(__model); - } + globalvar_add_simple_string("model", &model); + + free(model); + model = xstrdup(__model); } EXPORT_SYMBOL(barebox_set_model); const char *barebox_get_model(void) { - if (IS_ENABLED(CONFIG_GLOBALVAR)) - return getenv("global.model"); - return model; } EXPORT_SYMBOL(barebox_get_model); @@ -170,19 +165,14 @@ static char *hostname; */ void barebox_set_hostname(const char *__hostname) { - if (IS_ENABLED(CONFIG_GLOBALVAR)) { - globalvar_add_simple("hostname", __hostname); - } else { - free(hostname); - hostname = xstrdup(__hostname); - } + globalvar_add_simple_string("hostname", &hostname); + + free(hostname); + hostname = xstrdup(__hostname); } const char *barebox_get_hostname(void) { - if (IS_ENABLED(CONFIG_GLOBALVAR)) - return getenv("global.hostname"); - return hostname; } EXPORT_SYMBOL(barebox_get_hostname); |